added automatic mozilla-release download

This commit is contained in:
partisan 2025-04-13 19:21:04 +02:00
parent e5c95924d5
commit a13f43086f
6 changed files with 477 additions and 194 deletions

View file

@ -10,62 +10,68 @@ import (
// ApplyPatches handles cloning, updating, and applying patches
func ApplyPatches(sourcePath string, patchesRepo string, patchesPath string, patchesCloneDir string, skipUpdateRepo bool) error {
// Define the full patches path
fullPatchesPath := filepath.Join(patchesCloneDir, patchesPath) // Cleaned path without double slashes
fullPatchesPath := filepath.Join(patchesCloneDir, patchesPath)
fmt.Printf("Source Path: %s\n", sourcePath)
fmt.Printf("Patches Clone Directory: %s\n", patchesCloneDir)
fmt.Printf("Patches Repository URL: %s\n", patchesRepo)
fmt.Printf("Patches Path: %s\n", fullPatchesPath)
// Print configuration with consistent style
fmt.Printf("🔧 Config:\n")
fmt.Printf(" ├─ Source Path: %s\n", sourcePath)
fmt.Printf(" ├─ Patches Clone Dir: %s\n", patchesCloneDir)
fmt.Printf(" ├─ Patches Repo: %s\n", patchesRepo)
fmt.Printf(" └─ Patches Path: %s\n", fullPatchesPath)
// Check if the patches directory already exists
if _, err := os.Stat(patchesCloneDir); os.IsNotExist(err) {
// Clone the patches repository
fmt.Println("Patches directory does not exist. Proceeding to clone.")
fmt.Println("📥 Cloning patches repository...")
cmdClone := exec.Command("git", "clone", patchesRepo, patchesCloneDir)
cmdClone.Stdout = os.Stdout
cmdClone.Stderr = os.Stderr
if err := cmdClone.Run(); err != nil {
return fmt.Errorf("failed to clone patches repository: %v", err)
return fmt.Errorf("❌ Failed to clone patches repository: %v", err)
}
fmt.Println("Patches repository cloned successfully.")
fmt.Println("Patches repository cloned successfully")
} else {
if !skipUpdateRepo {
// If the directory exists, fetch and pull the latest changes
fmt.Println("Patches directory already exists. Fetching latest changes.")
fmt.Println("🔄 Updating patches repository...")
// Fetch updates
cmdFetch := exec.Command("git", "fetch", "--all")
cmdFetch.Dir = patchesCloneDir
cmdFetch.Stdout = os.Stdout
cmdFetch.Stderr = os.Stderr
if err := cmdFetch.Run(); err != nil {
return fmt.Errorf("failed to fetch updates for patches repository: %v", err)
return fmt.Errorf("❌ Failed to fetch updates: %v", err)
}
// Reset to latest
cmdReset := exec.Command("git", "reset", "--hard", "origin/main")
cmdReset.Dir = patchesCloneDir
cmdReset.Stdout = os.Stdout
cmdReset.Stderr = os.Stderr
if err := cmdReset.Run(); err != nil {
return fmt.Errorf("failed to reset patches repository to latest state: %v", err)
return fmt.Errorf("❌ Failed to reset repository: %v", err)
}
fmt.Println("Patches repository updated successfully.")
fmt.Println("✅ Patches repository updated")
} else {
fmt.Println("⏩ Skipping patches update (requested by user)")
}
}
// Verify the patches directory exists
if _, err := os.Stat(fullPatchesPath); os.IsNotExist(err) {
return fmt.Errorf("patches path not found: %s", fullPatchesPath)
return fmt.Errorf("❌ Patches path not found: %s", fullPatchesPath)
}
// Apply the patches using `run.sh`
applyCmd := exec.Command("go", "run", ".", "--path", sourcePath, "--patches", fullPatchesPath)
applyCmd.Dir = patchesCloneDir // Run from the patches directory
applyCmd.Dir = patchesCloneDir
applyCmd.Stdout = os.Stdout
applyCmd.Stderr = os.Stderr
fmt.Println("Applying patches...")
if err := applyCmd.Run(); err != nil {
return fmt.Errorf("failed to apply patches: %v", err)
return fmt.Errorf("❌ Failed to apply patches: %v", err)
}
fmt.Println("Patches applied successfully.")
fmt.Println("🎉 Patches applied successfully")
return nil
}