@@ -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
@@ -272,6 +337,8 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
272337 if len (buildTags ) > 0 {
273338 flags = append (flags , "-tags" , strings .Join (buildTags , "," ))
274339 }
340+ // We use -trimpath to avoid leaking local paths into the built executables.
341+ flags = append (flags , "-trimpath" )
275342 return flags
276343}
277344
@@ -281,24 +348,23 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
281348
282349func doTest (cmdline []string ) {
283350 var (
284- dlgo = flag .Bool ("dlgo" , false , "Download Go and build with it" )
285- arch = flag .String ("arch" , "" , "Run tests for given architecture" )
286- cc = flag .String ("cc" , "" , "Sets C compiler binary" )
287- coverage = flag .Bool ("coverage" , false , "Whether to record code coverage" )
288- verbose = flag .Bool ("v" , false , "Whether to log verbosely" )
289- race = flag .Bool ("race" , false , "Execute the race detector" )
290- short = flag .Bool ("short" , false , "Pass the 'short'-flag to go test" )
291- cachedir = flag .String ("cachedir" , "./build/cache" , "directory for caching downloads" )
292- skipspectests = flag .Bool ("skip-spectests" , false , "Skip downloading execution-spec-tests fixtures" )
293- threads = flag .Int ("p" , 1 , "Number of CPU threads to use for testing" )
351+ dlgo = flag .Bool ("dlgo" , false , "Download Go and build with it" )
352+ arch = flag .String ("arch" , "" , "Run tests for given architecture" )
353+ cc = flag .String ("cc" , "" , "Sets C compiler binary" )
354+ coverage = flag .Bool ("coverage" , false , "Whether to record code coverage" )
355+ verbose = flag .Bool ("v" , false , "Whether to log verbosely" )
356+ race = flag .Bool ("race" , false , "Execute the race detector" )
357+ short = flag .Bool ("short" , false , "Pass the 'short'-flag to go test" )
358+ cachedir = flag .String ("cachedir" , "./build/cache" , "directory for caching downloads" )
359+ threads = flag .Int ("p" , 1 , "Number of CPU threads to use for testing" )
294360 )
295361 flag .CommandLine .Parse (cmdline )
296362
297363 // Load checksums file (needed for both spec tests and dlgo)
298364 csdb := download .MustLoadChecksums ("build/checksums.txt" )
299365
300366 // Get test fixtures.
301- if ! * skipspectests {
367+ if ! * short {
302368 downloadSpecTestFixtures (csdb , * cachedir )
303369 }
304370
@@ -630,6 +696,32 @@ func doArchive(cmdline []string) {
630696 }
631697}
632698
699+ func doKeeperArchive (cmdline []string ) {
700+ var (
701+ signer = flag .String ("signer" , "" , `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)` )
702+ signify = flag .String ("signify" , "" , `Environment variable holding the signify key (e.g. LINUX_SIGNIFY_KEY)` )
703+ upload = flag .String ("upload" , "" , `Destination to upload the archives (usually "gethstore/builds")` )
704+ )
705+ flag .CommandLine .Parse (cmdline )
706+
707+ var (
708+ env = build .Env ()
709+ vsn = version .Archive (env .Commit )
710+ keeper = "keeper-" + vsn + ".tar.gz"
711+ )
712+ maybeSkipArchive (env )
713+ files := []string {"COPYING" }
714+ for _ , target := range keeperTargets {
715+ files = append (files , executablePath (fmt .Sprintf ("keeper-%s" , target .Name )))
716+ }
717+ if err := build .WriteArchive (keeper , files ); err != nil {
718+ log .Fatal (err )
719+ }
720+ if err := archiveUpload (keeper , * upload , * signer , * signify ); err != nil {
721+ log .Fatal (err )
722+ }
723+ }
724+
633725func archiveBasename (arch string , archiveVersion string ) string {
634726 platform := runtime .GOOS + "-" + arch
635727 if arch == "arm" {
0 commit comments