Skip to content

Commit c89561a

Browse files
alexlarssonachilleas-k
authored andcommitted
bib: Update to new osbuild-image arch.FromString() API
arch.FromString can now return an error
1 parent 3bd606d commit c89561a

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
@@ -216,17 +216,23 @@ func manifestFromCobra(cmd *cobra.Command, args []string, pbar progress.Progress
216216
}
217217
}
218218

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

0 commit comments

Comments
 (0)