diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f633c57 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +all: build + +build: + go get "github.com/probandula/figlet4go" + go build . diff --git a/json_loader.go b/json_loader.go index 41f1076..44e25b3 100644 --- a/json_loader.go +++ b/json_loader.go @@ -8,10 +8,15 @@ import ( ) type Package struct { - Name, Zip, Url, Fetch, Plan string - Branch, Command string // If this is git repository, what branch/tag do we check out before building? - BinDir, LibDir string //Where do we find the binary files, relative to the top level directory of the installed package? - BinDirs, Deletes []string + Name string //Name of the package + Zip string //Full archive name, including extension + Url string //URL to download the archive from + Fetch string //Fetch method (e.g. wget, curl, git, svn, etc) + Plan string //Build plan (e.g. make, cmake, etc) + Branch, Command string // If this is git repository, what branch/tag do we check out before building? + BinDir, LibDir string //Where do we find the binary files after the build, relative to the top level directory of the installed package? + BinDirs []string //If there are multiple directories to add to the path. Both BinDir and BinDirs are added to the path. + Deletes []string } func LoadJSON(filename string) Package { diff --git a/packages-osx/racketprogs.json b/packages-osx/racketprogs.json new file mode 100644 index 0000000..fa828c5 --- /dev/null +++ b/packages-osx/racketprogs.json @@ -0,0 +1,8 @@ +{ + "Name" : "racketprogs", + "Zip" : "", + "Url" : "https://gitlab.com/donomii/racketprogs", + "Fetch" : "git", + "Branch" : "master", + "Plan" : "gitAndMake" +} diff --git a/packages-windows/dcss-git.json b/packages-windows/dcss-git.json deleted file mode 100644 index 48968bb..0000000 --- a/packages-windows/dcss-git.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Name" : "DCSS", - "Zip" : "", - "Url" : "https://github.com/crawl/crawl", - "Fetch" : "git", - "Branch" : "master", - "Plan" : "cmake" -} diff --git a/packages-windows/go-1.10.3.json b/packages-windows/go-1.10.3.json deleted file mode 100644 index 9bceb4c..0000000 --- a/packages-windows/go-1.10.3.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Name" : "go", - "Zip" : "go1.13.4.windows-amd64.zip", - "Url" : "https://dl.google.com/go/go1.13.4.windows-amd64.zip", - "Fetch" : "web", - "Plan" : "zipWithDirectory", - "Type" : "application", - "BinDir": "/bin" -} diff --git a/packages-windows/racketprogs.json b/packages-windows/racketprogs.json new file mode 100644 index 0000000..fa828c5 --- /dev/null +++ b/packages-windows/racketprogs.json @@ -0,0 +1,8 @@ +{ + "Name" : "racketprogs", + "Zip" : "", + "Url" : "https://gitlab.com/donomii/racketprogs", + "Fetch" : "git", + "Branch" : "master", + "Plan" : "gitAndMake" +} diff --git a/updater.go b/updater.go index 8bea352..0c13485 100644 --- a/updater.go +++ b/updater.go @@ -18,6 +18,7 @@ import ( "github.com/kardianos/osext" "github.com/donomii/goof" "github.com/probandula/figlet4go" + "github.com/donomii/goof" ) var wg sync.WaitGroup @@ -229,19 +230,13 @@ func makeOpt(optName, optVal string) string { } func unTar(b Config, zipPath string) { - p2 := strings.Replace(zipPath, ".gz", "", -1) - p2 = strings.Replace(zipPath, ".tgz", ".tar", -1) - p2 = strings.Replace(p2, ".lzma", "", -1) - p2 = strings.Replace(p2, ".bz2", "", -1) - splits := strings.Split(p2, "/") + zipPath = strings.ReplaceAll(zipPath, "\\", "/") + splits := strings.Split(zipPath, "/") fname := splits[len(splits)-1] if _, err := os.Stat(zipPath); err == nil { - if isWindows() { - unSevenZ(b, zipPath) - } else { - doCommand("tar", []string{"-xzvf", zipPath}) - doCommand("tar", []string{"-xjvf", zipPath}) - } + unSevenZ(b, zipPath) + doCommand("tar", []string{"-xzvf", zipPath, "--force-local"}) + doCommand("tar", []string{"-xjvf", zipPath, "--force-local"}) } else { log.Println("Could not find ", fname) } @@ -257,7 +252,8 @@ func unTgzLib(b Config, zipPath string) { //unSevenZ(b, fname) } else { - doCommand("tar", []string{"-xzvf", zipPath}) + doCommand("tar", []string{"-xzvf", zipPath, "--force-local"}) + doCommand("tar", []string{"-xjvf", zipPath, "--force-local"}) } } else { log.Println("Could not extract ", fname) @@ -473,6 +469,7 @@ func doFetch(p Package, b Config) { doCommand("git", []string{"clone", url, name, "--recursive"}) os.Chdir(name) doCommand("git", []string{"checkout", branch}) + doCommand("git", []string{"pull"}) doCommand("git", []string{"submodule", "foreach", "--recursive", "git", "checkout", "master"}) os.Chdir(cwd) } @@ -525,14 +522,14 @@ func doAll(p Package, b Config) { targetDir := b.InstallDir doFetch(p, b) - cwd, _ := os.Getwd() + initialDir, _ := os.Getwd() os.Chdir(targetDir) //unBzLib(b, p.Name) //unTgzLib(b, p.Name) plan := p.Plan - os.Chdir(cwd) + os.Chdir(initialDir) if plan == "standardConfigure" { standardConfigureBuild(b, p.Name, ".", []string{makeOpt("prefix", targetDir)}) //, makeOpt("with-sysroot", targetDir) } else if plan == "goGetAndMake" { @@ -556,14 +553,24 @@ func doAll(p Package, b Config) { } if p.BinDir != "" { - subPaths = append(subPaths, b.InstallDir+"/"+p.Name+"/"+p.BinDir) + subPaths = append(subPaths, b.SourceDir+"/"+p.Name+"/"+p.BinDir) } + for _, v := range p.BinDirs { subPaths = append(subPaths, b.InstallDir+"/"+p.Name+"/"+v) } + + //Cleanup build files, if required for _, v := range p.Deletes { os.Remove(b.InstallDir + "/" + p.Name + "/" + v) } + + os.Chdir(b.InstallDir+"/"+p.Name) + fmt.Println("Current directory: ", goof.Cwd()) + distZipPath := "dist.zip" + //Package up the binaries from the dist/ directory into a zip file + doCommand("zip", []string{"-r", distZipPath, "dist/"}) + os.Chdir(initialDir) } func figSay(s string) {