From 507684d5eeb94a93d1519549426d158bdf4b2e61 Mon Sep 17 00:00:00 2001 From: mpl Date: Tue, 1 May 2018 10:13:49 -0700 Subject: [PATCH] misc/docker: fix release tools Change-Id: Ie7e75d88a4fbc7df753aedbfb00d77d1899962e1 --- misc/docker/dock.go | 14 ++++++------- misc/docker/release/build-binaries.go | 22 ++++++++++---------- misc/docker/release/zip-source.go | 30 +++++++++++---------------- misc/monthly.go | 18 ++++++++-------- 4 files changed, 39 insertions(+), 45 deletions(-) diff --git a/misc/docker/dock.go b/misc/docker/dock.go index 1850bbb3c..76d04df1b 100644 --- a/misc/docker/dock.go +++ b/misc/docker/dock.go @@ -190,11 +190,11 @@ func zipSource(ctxDir string) { } setReleaseTarballName() // can't use os.Rename because invalid cross-device link error likely - cmd = exec.Command("mv", filepath.Join(ctxDir, "camlistore-src.zip"), releaseTarball) + cmd = exec.Command("mv", filepath.Join(ctxDir, "perkeep-src.zip"), releaseTarball) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - log.Fatalf("Error moving source zip from %v to %v: %v", filepath.Join(ctxDir, "camlistore-src.zip"), releaseTarball, err) + log.Fatalf("Error moving source zip from %v to %v: %v", filepath.Join(ctxDir, "perkeep-src.zip"), releaseTarball, err) } fmt.Printf("Perkeep source successfully zipped in %v\n", releaseTarball) } @@ -253,13 +253,13 @@ func publicACL(proj string) []storage.ACLRule { } // uploadReleaseTarball uploads the generated tarball of binaries in -// camlistore-release/VERSION/camlistoreVERSION-REV-CONTENTS.EXT. It then makes a copy in -// the same bucket and path, as camlistoreVERSION-CONTENTS.EXT. +// camlistore-release/VERSION/perkeepVERSION-REV-CONTENTS.EXT. It then makes a copy in +// the same bucket and path, as perkeepVERSION-CONTENTS.EXT. func uploadReleaseTarball() { proj := "camlistore-website" bucket := "camlistore-release" tarball := *flagVersion + "/" + filepath.Base(releaseTarball) - versionedTarball := strings.Replace(tarball, "camlistore"+*flagVersion, "camlistore"+*flagVersion+"-"+rev(), 1) + versionedTarball := strings.Replace(tarball, "perkeep"+*flagVersion, "perkeep"+*flagVersion+"-"+rev(), 1) log.Printf("Uploading %s/%s ...", bucket, versionedTarball) @@ -420,9 +420,9 @@ func setReleaseTarballName() { extension = ".tar.gz" } if *flagVersion != "" { - filename = "camlistore" + *flagVersion + "-" + contents + extension + filename = "perkeep" + *flagVersion + "-" + contents + extension } else { - filename = "camlistore-" + contents + extension + filename = "perkeep-" + contents + extension } releaseTarball = path.Join(dockDir, "release", filename) } diff --git a/misc/docker/release/build-binaries.go b/misc/docker/release/build-binaries.go index 9528ae907..eac1c1196 100644 --- a/misc/docker/release/build-binaries.go +++ b/misc/docker/release/build-binaries.go @@ -46,8 +46,8 @@ var ( func usage() { fmt.Fprintf(os.Stderr, "Usage:\n") - fmt.Fprintf(os.Stderr, "%s --rev=camlistore_revision\n", os.Args[0]) - fmt.Fprintf(os.Stderr, "%s --rev=WIP:/path/to/camli/source/dir\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "%s --rev=perkeep_revision\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "%s --rev=WIP:/path/to/perkeep/source/dir\n", os.Args[0]) flag.PrintDefaults() example(os.Args[0]) os.Exit(1) @@ -55,8 +55,8 @@ func usage() { func example(program string) { fmt.Fprintf(os.Stderr, "Examples:\n") - fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume=/tmp/camli-build/camlistore.org:/OUT camlistore/go %s --rev=4e8413c5012c\n", program) - fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume=/tmp/camli-build/camlistore.org:/OUT --volume=~/camlistore.org:/IN camlistore/go %s --rev=WIP:/IN\n", program) + fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume=/tmp/camli-build/perkeep.org:/OUT perkeep/go %s --rev=4e8413c5012c\n", program) + fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume=/tmp/camli-build/perkeep.org:/OUT --volume=~/perkeep.org:/IN perkeep/go %s --rev=WIP:/IN\n", program) } func isWIP() bool { @@ -96,23 +96,23 @@ func getCamliSrc() { } // we insert the version in the VERSION file, so make.go does no need git // in the container to detect the Perkeep version. - check(os.Chdir("/gopath/src/camlistore.org")) + check(os.Chdir("/gopath/src/perkeep.org")) check(ioutil.WriteFile("VERSION", []byte(version()), 0777)) } func mirrorCamliSrc(srcDir string) { check(os.MkdirAll("/gopath/src", 0777)) - cmd := exec.Command("cp", "-a", srcDir, "/gopath/src/camlistore.org") + cmd := exec.Command("cp", "-a", srcDir, "/gopath/src/perkeep.org") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - log.Fatalf("Error mirroring camlistore source from %v: %v", srcDir, err) + log.Fatalf("Error mirroring perkeep source from %v: %v", srcDir, err) } } func fetchCamliSrc() { - check(os.MkdirAll("/gopath/src/camlistore.org", 0777)) - check(os.Chdir("/gopath/src/camlistore.org")) + check(os.MkdirAll("/gopath/src/perkeep.org", 0777)) + check(os.Chdir("/gopath/src/perkeep.org")) res, err := http.Get("https://camlistore.googlesource.com/camlistore/+archive/" + *flagRev + ".tar.gz") check(err) @@ -145,7 +145,7 @@ func fetchCamliSrc() { } func build() { - check(os.Chdir("/gopath/src/camlistore.org")) + check(os.Chdir("/gopath/src/perkeep.org")) oldPath := os.Getenv("PATH") os.Setenv("GOPATH", "/gopath") os.Setenv("PATH", "/usr/local/go/bin:"+oldPath) @@ -156,7 +156,7 @@ func build() { if err := cmd.Run(); err != nil { log.Fatalf("Error building all Perkeep binaries for %v in go container: %v", *buildOS, err) } - srcDir := "bin" + srcDir := "/gopath/bin" if *buildOS != "linux" { // TODO(mpl): probably bail early if GOARCH != amd64. Or do we want to distribute for other arches? srcDir = path.Join(srcDir, *buildOS+"_amd64") diff --git a/misc/docker/release/zip-source.go b/misc/docker/release/zip-source.go index 442358bf0..e0425aaa7 100644 --- a/misc/docker/release/zip-source.go +++ b/misc/docker/release/zip-source.go @@ -45,7 +45,7 @@ var ( flagSanity = flag.Bool("sanity", true, "Check before making the zip that its contents pass the \"go run make.go\" test.") ) -const tmpSource = "/tmp/camlistore.org" +const tmpSource = "/tmp/perkeep.org" var ( // Everything that should be included in the release. @@ -53,7 +53,6 @@ var ( rootNames = map[string]bool{ "app": true, "AUTHORS": false, - "bin": true, "BUILDING": false, "clients": true, "cmd": true, @@ -64,21 +63,22 @@ var ( "dev": true, "doc": true, "Dockerfile": false, + "Gopkg.lock": false, + "Gopkg.toml": false, "internal": true, "lib": true, "Makefile": false, "make.go": false, "misc": true, - "old": true, "pkg": true, - "README": false, + "README.md": false, "server": true, "TESTS": false, "TODO": false, "vendor": true, "website": true, } - tarballSrc = path.Join(*flagOutDir, "camlistore.org") + tarballSrc = path.Join(*flagOutDir, "src", "perkeep.org") ) func usage() { @@ -90,8 +90,8 @@ func usage() { func example() { fmt.Fprintf(os.Stderr, "Examples:\n") - fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume /tmp/camlirelease:/OUT --volume $GOPATH/src/camlistore.org/misc/docker/release/cut-source.go:/usr/local/bin/cut-source.go:ro --volume $GOPATH/src/camlistore.org:/IN:ro camlistore/go /usr/local/go/bin/go run /usr/local/bin/zip-source.go --rev WIP:/IN\n") - fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume /tmp/camlirelease:/OUT --volume $GOPATH/src/camlistore.org/misc/docker/release/zip-source.go:/usr/local/bin/cut-source.go:ro camlistore/go /usr/local/go/bin/go run /usr/local/bin/cut-source.go --rev=4e8413c5012c\n") + fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume /tmp/camlirelease:/OUT --volume $GOPATH/src/perkeep.org/misc/docker/release/cut-source.go:/usr/local/bin/cut-source.go:ro --volume $GOPATH/src/perkeep.org:/IN:ro perkeep/go /usr/local/go/bin/go run /usr/local/bin/zip-source.go --rev WIP:/IN\n") + fmt.Fprintf(os.Stderr, "\tdocker run --rm --volume /tmp/camlirelease:/OUT --volume $GOPATH/src/perkeep.org/misc/docker/release/zip-source.go:/usr/local/bin/cut-source.go:ro perkeep/go /usr/local/go/bin/go run /usr/local/bin/cut-source.go --rev=4e8413c5012c\n") } func isWIP() bool { @@ -139,7 +139,7 @@ func mirrorCamliSrc(srcDir string) { cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - log.Fatalf("Error mirroring camlistore source from %v: %v", srcDir, err) + log.Fatalf("Error mirroring perkeep source from %v: %v", srcDir, err) } } @@ -260,29 +260,23 @@ func checkBuild() { check(os.Chdir(tarballSrc)) check(os.Setenv("PATH", os.Getenv("PATH")+":/usr/local/go/bin/")) check(os.Setenv("CAMLI_GOPHERJS_GOROOT", "/usr/local/go")) + check(os.Setenv("GOPATH", *flagOutDir)) cmd := exec.Command("go", "run", "make.go") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { log.Fatalf("could not build Perkeep from tarball contents: %v", err) } - // cleanup - check(os.RemoveAll(path.Join(tarballSrc, "tmp"))) - binDir := path.Join(tarballSrc, "bin") - check(os.Rename(path.Join(binDir, "README"), "README.bin")) - check(os.RemoveAll(binDir)) - check(os.MkdirAll(binDir, 0755)) - check(os.Rename("README.bin", path.Join(binDir, "README"))) } func pack() { - zipFile := path.Join(*flagOutDir, "camlistore-src.zip") - check(os.Chdir(*flagOutDir)) + zipFile := path.Join(*flagOutDir, "perkeep-src.zip") + check(os.Chdir(filepath.Join(*flagOutDir, "src"))) fw, err := os.Create(zipFile) check(err) w := zip.NewWriter(fw) - check(filepath.Walk("camlistore.org", func(filePath string, fi os.FileInfo, err error) error { + check(filepath.Walk("perkeep.org", func(filePath string, fi os.FileInfo, err error) error { if err != nil { return err } diff --git a/misc/monthly.go b/misc/monthly.go index 6e925cd33..2a068b778 100644 --- a/misc/monthly.go +++ b/misc/monthly.go @@ -56,7 +56,7 @@ var ( flagRev = flag.String("rev", "", "Perkeep revision to build (tag or commit hash). For development purposes, you can instead specify the path to a local Perkeep source tree from which to build, with the form \"WIP:/path/to/dir\".") flagDate = flag.String("date", "", "The release date to use in the file names to be uploaded, in the YYYYMMDD format. Defaults to today's date.") flagUpload = flag.Bool("upload", true, "Upload all the generated tarballs and zip archives.") - flagSkipGen = flag.Bool("skipgen", false, "Do not recreate the release tarballs, and directly use the ones found in camlistore.org/misc/docker/release. Use -upload=false and -skipgen=true to only generate the monthly release page.") + flagSkipGen = flag.Bool("skipgen", false, "Do not recreate the release tarballs, and directly use the ones found in perkeep.org/misc/docker/release. Use -upload=false and -skipgen=true to only generate the monthly release page.") flagStatsFrom = flag.String("stats_from", "", "Also generate commit statistics on the release page, starting from the given commit, and ending at the one given as -rev.") // TODO(mpl): make sanity run the tests too, once they're more reliable. flagSanity = flag.Bool("sanity", true, "Verify 'go run make.go' succeeds when building the source tarball. Abort everything if not.") @@ -110,7 +110,7 @@ func genDownloads() error { wg.Add(1) go func() { defer wg.Done() - upload(filepath.Join(releaseDir, "camlistore-src.zip")) + upload(filepath.Join(releaseDir, "perkeep-src.zip")) }() // gen the binaries tarballs: @@ -134,7 +134,7 @@ func genDownloads() error { wg.Add(1) go func(osType string) { defer wg.Done() - filename := "camlistore-" + osType + ".tar.gz" + filename := "perkeep-" + osType + ".tar.gz" if osType == "windows" { filename = strings.Replace(filename, ".tar.gz", ".zip", 1) } @@ -149,7 +149,7 @@ func upload(srcPath string) { if !*flagUpload { return } - destName := strings.Replace(filepath.Base(srcPath), "camlistore", "camlistore-"+releaseDate.Format(fileDateFormat), 1) + destName := strings.Replace(filepath.Base(srcPath), "perkeep", "perkeep-"+releaseDate.Format(fileDateFormat), 1) versionedTarball := "monthly/" + destName log.Printf("Uploading %s/%s ...", bucket, versionedTarball) @@ -278,7 +278,7 @@ Perkeep version