@@ -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,42 @@ 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 .Args = append (gobuild .Args , "-v" )
288+
289+ for key , value := range target .Env {
290+ gobuild .Env = append (gobuild .Env , key + "=" + value )
291+ }
292+ outputName := fmt .Sprintf ("keeper-%s" , target .Name )
293+
294+ args := slices .Clone (gobuild .Args )
295+ args = append (args , "-o" , executablePath (outputName ))
296+ args = append (args , "./cmd/keeper" )
297+ build .MustRun (& exec.Cmd {Path : gobuild .Path , Args : args , Env : gobuild .Env })
298+ }
299+ }
300+
237301// buildFlags returns the go tool flags for building.
238302func buildFlags (env build.Environment , staticLinking bool , buildTags []string ) (flags []string ) {
239303 var ld []string
@@ -272,6 +336,8 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
272336 if len (buildTags ) > 0 {
273337 flags = append (flags , "-tags" , strings .Join (buildTags , "," ))
274338 }
339+ // We use -trimpath to avoid leaking local paths into the built executables.
340+ flags = append (flags , "-trimpath" )
275341 return flags
276342}
277343
@@ -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