diff --git a/main.go b/main.go index 2857a50..e98d4cf 100644 --- a/main.go +++ b/main.go @@ -2,9 +2,7 @@ package main import ( "flag" - "fmt" "log" - "os" _ "github.com/codingsince1985/checksum" ) @@ -17,39 +15,14 @@ func main() { sdir := *source_dir tdir := *target_dir br := *branch + var source_dir_branch string = sdir + br + "/" var target_dir_branch string = tdir + br + "/" + + //generate manifest file for branch err := generate_manifest(source_dir_branch) if err != nil { log.Println("Error generating Manifest file: ", err) } release_branch(*branch, source_dir_branch, target_dir_branch) } - -func release_branch(branch string, source_dir string, target_dir string) { - checkOldFolder, _ := os.ReadDir(source_dir) - checkNewFolder, _ := os.ReadDir(target_dir) - var newImages bool = false - if len(checkOldFolder) > 0 { - newImages = true - } - - if newImages { - // delete old firmware files in public folder - for _, file := range checkNewFolder { - err := os.Remove(target_dir + file.Name()) - if err != nil { - log.Println("error deleting file: ", err) - } else { - log.Println("removed file: ", file.Name()) - } - } - - //move new files to folder - for _, file := range checkOldFolder { - os.Rename(source_dir+file.Name(), target_dir+file.Name()) - fmt.Println("moved file: ", file.Name()) - } - - } -} diff --git a/manifest.go b/manifest.go index 3838561..d18032c 100644 --- a/manifest.go +++ b/manifest.go @@ -14,13 +14,14 @@ import ( ) func generate_manifest(dir string) error { - files, err := get_files(dir) + sysdir := dir + "sysupgrade/" + files, err := get_files(sysdir) if err != nil { - log.Println("Error reading Image Files in folder: ", dir) + log.Println("Error reading Image Files in folder: ", sysdir) return err } - file_struct := split_filenames(files, dir) - build_manifest(file_struct, dir) + file_struct := split_filenames(files, sysdir) + build_manifest(file_struct, sysdir) return err } diff --git a/release.go b/release.go new file mode 100644 index 0000000..6e86729 --- /dev/null +++ b/release.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "log" + "os" +) + +func release_branch(branch string, source_dir string, target_dir string) { + checkOldFolder, _ := os.ReadDir(source_dir) + checkNewFolder, _ := os.ReadDir(target_dir) + var newImages bool = false + if len(checkOldFolder) > 0 { + newImages = true + } + + if newImages { + // delete old firmware files in public folder + for _, file := range checkNewFolder { + err := os.Remove(target_dir + file.Name()) + if err != nil { + log.Println("error deleting file: ", err) + } else { + log.Println("removed file: ", file.Name()) + } + } + + //move new files to folder + for _, file := range checkOldFolder { + os.Rename(source_dir+file.Name(), target_dir+file.Name()) + fmt.Println("moved file: ", file.Name()) + } + + } +}