Skip to content

Commit 1cb0ba4

Browse files
committed
bib: Update for osbuild-image arch.FromString API changes
arch.FromString can now return an error
1 parent 64b870c commit 1cb0ba4

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

bib/cmd/bootc-image-builder/main.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,23 @@ func manifestFromCobra(cmd *cobra.Command, args []string, pbar progress.Progress
217217
}
218218
}
219219

220-
if targetArch != "" && arch.FromString(targetArch) != arch.Current() {
221-
// TODO: detect if binfmt_misc for target arch is
222-
// available, e.g. by mounting the binfmt_misc fs into
223-
// the container and inspects the files or by
224-
// including tiny statically linked target-arch
225-
// binaries inside our bib container
226-
fmt.Fprintf(os.Stderr, "WARNING: target-arch is experimental and needs an installed 'qemu-user' package\n")
227-
if slices.Contains(imgTypes, "iso") {
228-
return nil, nil, fmt.Errorf("cannot build iso for different target arches yet")
220+
if targetArch != "" {
221+
target, err := arch.FromString(targetArch)
222+
if err != nil {
223+
return nil, nil, err
224+
}
225+
if target != arch.Current() {
226+
// TODO: detect if binfmt_misc for target arch is
227+
// available, e.g. by mounting the binfmt_misc fs into
228+
// the container and inspects the files or by
229+
// including tiny statically linked target-arch
230+
// binaries inside our bib container
231+
fmt.Fprintf(os.Stderr, "WARNING: target-arch is experimental and needs an installed 'qemu-user' package\n")
232+
if slices.Contains(imgTypes, "iso") {
233+
return nil, nil, fmt.Errorf("cannot build iso for different target arches yet")
234+
}
235+
cntArch = target
229236
}
230-
cntArch = arch.FromString(targetArch)
231237
}
232238
// TODO: add "target-variant", see https://github.com/osbuild/bootc-image-builder/pull/139/files#r1467591868
233239

0 commit comments

Comments
 (0)