@@ -31,6 +31,9 @@ Available commands are:
3131 install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables
3232 test [ -coverage ] [ packages... ] -- runs the tests
3333
34+ keeper [ -dlgo ]
35+ keeper-archive [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ]
36+
3437 archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts
3538 importkeys -- imports signing keys from env
3639 debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
8689 executablePath ("clef" ),
8790 }
8891
92+ // Keeper build targets with their configurations
93+ keeperTargets = []struct {
94+ Name string
95+ GOOS string
96+ GOARCH string
97+ CC string
98+ Tags string
99+ Env map [string ]string
100+ }{
101+ {
102+ Name : "ziren" ,
103+ GOOS : "linux" ,
104+ GOARCH : "mipsle" ,
105+ // enable when cgo works
106+ // CC: "mipsel-linux-gnu-gcc",
107+ Tags : "ziren" ,
108+ Env : map [string ]string {"GOMIPS" : "softfloat" , "CGO_ENABLED" : "0" },
109+ },
110+ {
111+ Name : "example" ,
112+ Tags : "example" ,
113+ },
114+ }
115+
89116 // A debian package is created for all executables listed here.
90117 debExecutables = []debExecutable {
91118 {
@@ -178,6 +205,10 @@ func main() {
178205 doPurge (os .Args [2 :])
179206 case "sanitycheck" :
180207 doSanityCheck ()
208+ case "keeper" :
209+ doInstallKeeper (os .Args [2 :])
210+ case "keeper-archive" :
211+ doKeeperArchive (os .Args [2 :])
181212 default :
182213 log .Fatal ("unknown command " , os .Args [1 ])
183214 }
@@ -212,9 +243,6 @@ func doInstall(cmdline []string) {
212243 // Configure the build.
213244 gobuild := tc .Go ("build" , buildFlags (env , * staticlink , buildTags )... )
214245
215- // We use -trimpath to avoid leaking local paths into the built executables.
216- gobuild .Args = append (gobuild .Args , "-trimpath" )
217-
218246 // Show packages during build.
219247 gobuild .Args = append (gobuild .Args , "-v" )
220248
@@ -234,6 +262,43 @@ func doInstall(cmdline []string) {
234262 }
235263}
236264
265+ // doInstallKeeper builds keeper binaries for all supported targets.
266+ func doInstallKeeper (cmdline []string ) {
267+ var dlgo = flag .Bool ("dlgo" , false , "Download Go and build with it" )
268+
269+ flag .CommandLine .Parse (cmdline )
270+ env := build .Env ()
271+
272+ // Configure the toolchain.
273+ tc := build.GoToolchain {}
274+ if * dlgo {
275+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
276+ tc .Root = build .DownloadGo (csdb )
277+ }
278+
279+ for _ , target := range keeperTargets {
280+ log .Printf ("Building keeper-%s" , target .Name )
281+
282+ // Configure the build.
283+ tc .GOARCH = target .GOARCH
284+ tc .GOOS = target .GOOS
285+ tc .CC = target .CC
286+ gobuild := tc .Go ("build" , buildFlags (env , true , []string {target .Tags })... )
287+ gobuild .Dir = "./cmd/keeper"
288+ gobuild .Args = append (gobuild .Args , "-v" )
289+
290+ for key , value := range target .Env {
291+ gobuild .Env = append (gobuild .Env , key + "=" + value )
292+ }
293+ outputName := fmt .Sprintf ("keeper-%s" , target .Name )
294+
295+ args := slices .Clone (gobuild .Args )
296+ args = append (args , "-o" , executablePath (outputName ))
297+ args = append (args , "." )
298+ build .MustRun (& exec.Cmd {Path : gobuild .Path , Args : args , Env : gobuild .Env })
299+ }
300+ }
301+
237302// buildFlags returns the go tool flags for building.
238303func buildFlags (env build.Environment , staticLinking bool , buildTags []string ) (flags []string ) {
239304 var ld []string
@@ -275,6 +340,8 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
275340 if len (buildTags ) > 0 {
276341 flags = append (flags , "-tags" , strings .Join (buildTags , "," ))
277342 }
343+ // We use -trimpath to avoid leaking local paths into the built executables.
344+ flags = append (flags , "-trimpath" )
278345 return flags
279346}
280347
@@ -284,24 +351,23 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
284351
285352func doTest (cmdline []string ) {
286353 var (
287- dlgo = flag .Bool ("dlgo" , false , "Download Go and build with it" )
288- arch = flag .String ("arch" , "" , "Run tests for given architecture" )
289- cc = flag .String ("cc" , "" , "Sets C compiler binary" )
290- coverage = flag .Bool ("coverage" , false , "Whether to record code coverage" )
291- verbose = flag .Bool ("v" , false , "Whether to log verbosely" )
292- race = flag .Bool ("race" , false , "Execute the race detector" )
293- short = flag .Bool ("short" , false , "Pass the 'short'-flag to go test" )
294- cachedir = flag .String ("cachedir" , "./build/cache" , "directory for caching downloads" )
295- skipspectests = flag .Bool ("skip-spectests" , false , "Skip downloading execution-spec-tests fixtures" )
296- threads = flag .Int ("p" , 1 , "Number of CPU threads to use for testing" )
354+ dlgo = flag .Bool ("dlgo" , false , "Download Go and build with it" )
355+ arch = flag .String ("arch" , "" , "Run tests for given architecture" )
356+ cc = flag .String ("cc" , "" , "Sets C compiler binary" )
357+ coverage = flag .Bool ("coverage" , false , "Whether to record code coverage" )
358+ verbose = flag .Bool ("v" , false , "Whether to log verbosely" )
359+ race = flag .Bool ("race" , false , "Execute the race detector" )
360+ short = flag .Bool ("short" , false , "Pass the 'short'-flag to go test" )
361+ cachedir = flag .String ("cachedir" , "./build/cache" , "directory for caching downloads" )
362+ threads = flag .Int ("p" , 1 , "Number of CPU threads to use for testing" )
297363 )
298364 flag .CommandLine .Parse (cmdline )
299365
300366 // Load checksums file (needed for both spec tests and dlgo)
301367 csdb := download .MustLoadChecksums ("build/checksums.txt" )
302368
303369 // Get test fixtures.
304- if ! * skipspectests {
370+ if ! * short {
305371 downloadSpecTestFixtures (csdb , * cachedir )
306372 }
307373
@@ -633,6 +699,32 @@ func doArchive(cmdline []string) {
633699 }
634700}
635701
702+ func doKeeperArchive (cmdline []string ) {
703+ var (
704+ signer = flag .String ("signer" , "" , `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)` )
705+ signify = flag .String ("signify" , "" , `Environment variable holding the signify key (e.g. LINUX_SIGNIFY_KEY)` )
706+ upload = flag .String ("upload" , "" , `Destination to upload the archives (usually "gethstore/builds")` )
707+ )
708+ flag .CommandLine .Parse (cmdline )
709+
710+ var (
711+ env = build .Env ()
712+ vsn = version .Archive (env .Commit )
713+ keeper = "keeper-" + vsn + ".tar.gz"
714+ )
715+ maybeSkipArchive (env )
716+ files := []string {"COPYING" }
717+ for _ , target := range keeperTargets {
718+ files = append (files , executablePath (fmt .Sprintf ("keeper-%s" , target .Name )))
719+ }
720+ if err := build .WriteArchive (keeper , files ); err != nil {
721+ log .Fatal (err )
722+ }
723+ if err := archiveUpload (keeper , * upload , * signer , * signify ); err != nil {
724+ log .Fatal (err )
725+ }
726+ }
727+
636728func archiveBasename (arch string , archiveVersion string ) string {
637729 platform := runtime .GOOS + "-" + arch
638730 if arch == "arm" {
0 commit comments