updated patching process

This commit is contained in:
partisan 2024-12-08 14:34:31 +01:00
parent 7840cb8b39
commit 1e5d7528f6
4 changed files with 134 additions and 43 deletions

46
main.go
View file

@ -8,7 +8,7 @@ import (
"os/exec"
"path/filepath"
"runtime" // for detecting system architecture and platform
"spitfire/spitfire"
"spitfire-builder/spitfire"
"time"
//"errors"
)
@ -141,7 +141,7 @@ func main() {
fmt.Printf("Resolved uploadPath: %s\n", uploadPath)
}
if all || buildFlag {
if all || buildFlag || patches || clean || update {
BuildProcess()
}
@ -152,24 +152,24 @@ func main() {
spitfire.PrintErrors()
}
// BuildProcess handles the build process: downloading, cleaning, configuring, and building the project.
// Update the BuildProcess function to pass patchesRepo
func BuildProcess() {
sourcePath, err := spitfire.ResolvePath("./mozilla-central")
if err != nil {
log.Fatalf("Error resolving source path: %v", err)
}
patchesDir, err := spitfire.ResolvePath(filepath.Join(sourcePath, "Spitfire"))
if err != nil {
log.Fatalf("Error resolving patches directory: %v", err)
}
if all {
spitfire.DownloadSource(sourcePath, sourceRepo)
spitfire.DiscardChanges(sourcePath)
spitfire.CleanBuild(sourcePath)
spitfire.UpdateRepo(sourcePath)
spitfire.UpdatePatches(patchesDir, patchesRepo, sourcePath)
// Pass patchesRepo to ApplyPatches
if err := spitfire.ApplyPatches(sourcePath, patchesRepo); err != nil {
log.Fatalf("Error during patch application: %v", err)
}
spitfire.Configure(sourcePath)
spitfire.Build(sourcePath)
if run {
@ -185,7 +185,11 @@ func BuildProcess() {
fmt.Println("Mozilla repository updated.")
} else if patches {
spitfire.DownloadSource(sourcePath, sourceRepo)
spitfire.UpdatePatches(patchesDir, patchesRepo, sourcePath)
// Pass patchesRepo to ApplyPatches
if err := spitfire.ApplyPatches(sourcePath, patchesRepo); err != nil {
log.Fatalf("Error during patch application: %v", err)
}
fmt.Println("Patches updated.")
} else if buildFlag {
spitfire.Configure(sourcePath)
@ -283,28 +287,6 @@ func PackageAndUploadProcess() {
}
}
// // waitForPath checks if a path exists, waiting for up to maxWait seconds and retrying every interval seconds.
// func waitForPath(path string, maxWait int, interval int) error {
// waited := 0
// for {
// if PathExists(path) {
// return nil // Path exists
// }
// if waited >= maxWait {
// return errors.New("path does not exist after waiting")
// }
// fmt.Printf("Waiting for path %s to exist...\n", path)
// time.Sleep(time.Duration(interval) * time.Second)
// waited += interval
// }
// }
// // PathExists checks if the path exists
// func PathExists(path string) bool {
// _, err := os.Stat(path)
// return !os.IsNotExist(err)
// }
// restoreWorkingDirectory restores the initial working directory after any operation that might change it.
func restoreWorkingDirectory() {
err := os.Chdir(initialDir)