Skip to content

Commit f541e34

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

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,9 @@ func findMountableSizeableFor(pt *disk.PartitionTable, needle string) (disk.Moun
375375
func TestGenPartitionTableSetsRootfsForAllFilesystemsXFS(t *testing.T) {
376376
rng := bib.CreateRand()
377377

378+
a, _ := arch.FromString("amd64")
378379
cnf := &bib.ManifestConfig{
379-
Architecture: arch.FromString("amd64"),
380+
Architecture: a,
380381
RootFSType: "xfs",
381382
}
382383
cus := &blueprint.Customizations{
@@ -406,8 +407,9 @@ func TestGenPartitionTableSetsRootfsForAllFilesystemsXFS(t *testing.T) {
406407
func TestGenPartitionTableSetsRootfsForAllFilesystemsBtrfs(t *testing.T) {
407408
rng := bib.CreateRand()
408409

410+
a, _ := arch.FromString("amd64")
409411
cnf := &bib.ManifestConfig{
410-
Architecture: arch.FromString("amd64"),
412+
Architecture: a,
411413
RootFSType: "btrfs",
412414
}
413415
cus := &blueprint.Customizations{}
@@ -429,8 +431,9 @@ func TestGenPartitionTableSetsRootfsForAllFilesystemsBtrfs(t *testing.T) {
429431
func TestGenPartitionTableDiskCustomizationRunsValidateLayoutConstraints(t *testing.T) {
430432
rng := bib.CreateRand()
431433

434+
a, _ := arch.FromString("amd64")
432435
cnf := &bib.ManifestConfig{
433-
Architecture: arch.FromString("amd64"),
436+
Architecture: a,
434437
RootFSType: "xfs",
435438
}
436439
cus := &blueprint.Customizations{
@@ -650,8 +653,9 @@ func TestGenPartitionTableDiskCustomizationSizes(t *testing.T) {
650653
},
651654
} {
652655
t.Run(tc.name, func(t *testing.T) {
656+
a, _ := arch.FromString("amd64")
653657
cnf := &bib.ManifestConfig{
654-
Architecture: arch.FromString("amd64"),
658+
Architecture: a,
655659
RootFSType: "xfs",
656660
RootfsMinsize: tc.rootfsMinSize,
657661
}

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)