Skip to content

Commit 3598602

Browse files
alexlarssonachilleas-k
authored andcommitted
Write boot partition for aboot images
If the target image contains an aboot.img, then we automatically write it to the A slot boot partition.
1 parent 6461a64 commit 3598602

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"math"
88
"math/big"
99
"math/rand"
10+
"path/filepath"
1011
"slices"
1112
"strconv"
1213
"strings"
@@ -251,6 +252,28 @@ func genPartitionTable(c *ManifestConfig, customizations *blueprint.Customizatio
251252
}
252253
}
253254

255+
if c.SourceInfo != nil && c.SourceInfo.KernelInfo != nil && c.SourceInfo.KernelInfo.HasAbootImg {
256+
idx := slices.IndexFunc(partitionTable.Partitions, func(part disk.Partition) bool {
257+
// The aboot support in ostree supports both traditional android verified boot and
258+
// ukiboot. For aboot, the partition is labeled "boot_a", as described in
259+
// https://source.android.com/docs/core/ota/ab/ab_implement
260+
// For ukibooot (https://gitlab.com/CentOS/automotive/src/ukiboot) the partition
261+
// either has label ukiboot_a (GPT) or type 0x46 (MBR).
262+
return part.Label == "boot_a" || part.Label == "ukiboot_a" || part.Type == "46"
263+
})
264+
if idx >= 0 {
265+
sourcePipeline := "build"
266+
if c.BuildSourceInfo != nil {
267+
sourcePipeline = "target"
268+
}
269+
270+
partitionTable.Partitions[idx].Payload = &disk.Raw{
271+
SourcePipeline: sourcePipeline,
272+
SourcePath: filepath.Join("/usr/lib/modules/", c.SourceInfo.KernelInfo.Version, "aboot.img"),
273+
}
274+
}
275+
}
276+
254277
return partitionTable, nil
255278
}
256279

0 commit comments

Comments
 (0)