Skip to content

Commit

Permalink
cmd/build: add -target-arch flag
Browse files Browse the repository at this point in the history
This flag allows to set the target architecture for the build. This
is most useful for `-manifest-only` and the intended use-case is
generating reference images for `otk`. But it could also be used
with `qemu-user` and should work equally well as `bib` (maybe
better as the "regular" distro code tends to use less of the
modern system calls that tend to be problematic like `openat2`).
  • Loading branch information
mvo5 committed Sep 4, 2024
1 parent 09db08d commit 95e39d3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ func run() error {
flag.Var(&checkpoints, "checkpoints", "comma-separated list of pipeline names to checkpoint (passed to osbuild --checkpoint)")

// image selection args
var distroName, imgTypeName, configFile string
var distroName, imgTypeName, configFile, targetArch string
flag.StringVar(&distroName, "distro", "", "distribution (required)")
flag.StringVar(&imgTypeName, "type", "", "image type name (required)")
flag.StringVar(&configFile, "config", "", "build config file")
flag.StringVar(&targetArch, "target-arch", "", "target architecture to use, mostly for -manifest-only")

flag.Parse()

Expand Down Expand Up @@ -232,7 +233,12 @@ func run() error {
return fmt.Errorf("invalid or unsupported distribution: %q", distroName)
}

archName := arch.Current().String()
var archName string
if targetArch != "" {
archName = targetArch
} else {
archName = arch.Current().String()
}
arch, err := distribution.GetArch(archName)
if err != nil {
return fmt.Errorf("invalid arch name %q for distro %q: %s\n", archName, distroName, err.Error())
Expand Down

0 comments on commit 95e39d3

Please sign in to comment.