Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions internal/testdisk/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ func MakeFakePartitionTable(mntPoints ...string) *disk.PartitionTable {
payload = swap
case "raw":
payload = &disk.Raw{
SourcePipeline: "build",
SourcePath: "/usr/lib/modules/5.0/aboot.img",
SourcePath: "/usr/lib/modules/5.0/aboot.img",
}
default:
payload = &disk.Filesystem{
Expand Down
3 changes: 3 additions & 0 deletions pkg/disk/partition_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ type partitionTableFeatures struct {
EXT4 bool
LUKS bool
Swap bool
Raw bool
}

// features examines all of the PartitionTable entities and returns a struct
Expand Down Expand Up @@ -881,6 +882,8 @@ func (pt *PartitionTable) features() partitionTableFeatures {
case "ext4":
ptFeatures.EXT4 = true
}
case *Raw:
ptFeatures.Raw = true
case *Swap:
ptFeatures.Swap = true
case *LUKSContainer:
Expand Down
6 changes: 2 additions & 4 deletions pkg/disk/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
// Raw defines the payload for a raw partition. It's similar to a
// [Filesystem] but with fewer fields. It is a [PayloadEntity].
type Raw struct {
SourcePipeline string
SourcePath string
SourcePath string `json:"source_path" yaml:"source_path"`
}

func init() {
Expand All @@ -25,7 +24,6 @@ func (s *Raw) Clone() Entity {
}

return &Raw{
SourcePipeline: s.SourcePipeline,
SourcePath: s.SourcePath,
SourcePath: s.SourcePath,
}
}
6 changes: 6 additions & 0 deletions pkg/image/bootc_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes
var copyFilesFrom map[string][]string
var ensureDirs []*fsnode.Directory

var customSourcePipeline = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(super nitpick) it would be slightly idiomatic to just have:

-       var customSourcePipeline = ""
+       var customSourcePipeline string

here.

if *img.ContainerSource != *img.BuildContainerSource {
// If we're using a different build container from the target container then we copy
// the bootc customization file directories from the target container. This includes the
Expand Down Expand Up @@ -79,6 +80,8 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes
EnsureDirs: ensureDirs,
})
targetBuildPipeline.Checkpoint()

customSourcePipeline = targetBuildPipeline.Name()
}

buildContainers := []container.SourceSpec{*img.BuildContainerSource}
Expand All @@ -97,6 +100,9 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes
var hostPipeline manifest.Build

rawImage := manifest.NewRawBootcImage(buildPipeline, containers, img.platform)
if customSourcePipeline != "" {
rawImage.SourcePipeline = customSourcePipeline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked a bit into writing a test for this but I couldn't come up with something nice :( I think we should just do an end-to-end test with something like #1828 that generates a manifest and then we can check the source pipeline settings (or a maybe even a real one in addition that creates a custom bootc container with a real disk.yaml and a real payload, but definitely followup material for us, don't worry about it :)

}
rawImage.PartitionTable = img.PartitionTable
rawImage.Users = img.OSCustomizations.Users
rawImage.Groups = img.OSCustomizations.Groups
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/anaconda_installer_iso_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (p *AnacondaInstallerISOTree) serialize() osbuild.Pipeline {
Size: fmt.Sprintf("%d", p.PartitionTable.Size),
}))

for _, stage := range osbuild.GenFsStages(p.PartitionTable, filename) {
for _, stage := range osbuild.GenFsStages(p.PartitionTable, filename, p.anacondaPipeline.Name()) {
pipeline.AddStage(stage)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/coi_iso_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (p *CoreOSISOTree) serialize() osbuild.Pipeline {
Size: fmt.Sprintf("%d", p.PartitionTable.Size),
}))

for _, stage := range osbuild.GenFsStages(p.PartitionTable, filename) {
for _, stage := range osbuild.GenFsStages(p.PartitionTable, filename, p.payloadPipeline.Name()) {
pipeline.AddStage(stage)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (p *RawImage) serialize() osbuild.Pipeline {
panic("no partition table in live image")
}

for _, stage := range osbuild.GenImagePrepareStages(pt, p.Filename(), p.PartTool) {
for _, stage := range osbuild.GenImagePrepareStages(pt, p.Filename(), p.PartTool, p.treePipeline.Name()) {
pipeline.AddStage(stage)
}

Expand Down
8 changes: 6 additions & 2 deletions pkg/manifest/raw_bootc.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type RawBootcImage struct {
// MountUnits creates systemd .mount units to describe the filesystem
// instead of writing to /etc/fstab
MountUnits bool

// Source pipeline for files written to raw partitions
SourcePipeline string
}

func (p RawBootcImage) Filename() string {
Expand All @@ -64,7 +67,8 @@ func NewRawBootcImage(buildPipeline Build, containers []container.SourceSpec, pl
filename: "disk.img",
platform: platform,

containers: containers,
containers: containers,
SourcePipeline: buildPipeline.Name(),
}
buildPipeline.addDependent(p)
return p
Expand Down Expand Up @@ -133,7 +137,7 @@ func (p *RawBootcImage) serialize() osbuild.Pipeline {
panic(fmt.Errorf("no partition table in live image"))
}

for _, stage := range osbuild.GenImagePrepareStages(pt, p.filename, osbuild.PTSfdisk) {
for _, stage := range osbuild.GenImagePrepareStages(pt, p.filename, osbuild.PTSfdisk, p.SourcePipeline) {
pipeline.AddStage(stage)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/raw_ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p *RawOSTreeImage) serialize() osbuild.Pipeline {
panic("no partition table in live image")
}

for _, stage := range osbuild.GenImagePrepareStages(pt, p.Filename(), osbuild.PTSfdisk) {
for _, stage := range osbuild.GenImagePrepareStages(pt, p.Filename(), osbuild.PTSfdisk, p.treePipeline.Name()) {
pipeline.AddStage(stage)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/osbuild/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (
PTSgdisk PartTool = "sgdisk"
)

func GenImagePrepareStages(pt *disk.PartitionTable, filename string, partTool PartTool) []*Stage {
func GenImagePrepareStages(pt *disk.PartitionTable, filename string, partTool PartTool, sourcePipeline string) []*Stage {
stages := make([]*Stage, 0)

// create an empty file of the given size via `org.osbuild.truncate`
Expand Down Expand Up @@ -106,7 +106,7 @@ func GenImagePrepareStages(pt *disk.PartitionTable, filename string, partTool Pa

// Generate all the filesystems, subvolumes, and swap areas on partitons
// and devices
s = GenFsStages(pt, filename)
s = GenFsStages(pt, filename, sourcePipeline)
stages = append(stages, s...)

return stages
Expand Down
2 changes: 1 addition & 1 deletion pkg/osbuild/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestGenImageKernelOptionsBtrfsNotRootCmdlineGenerated(t *testing.T) {
func TestGenImagePrepareStages(t *testing.T) {
pt := testdisk.MakeFakeBtrfsPartitionTable("/", "/boot")
filename := "image.raw"
actualStages := GenImagePrepareStages(pt, filename, PTSfdisk)
actualStages := GenImagePrepareStages(pt, filename, PTSfdisk, "build")

assert.Equal(t, []*Stage{
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/osbuild/mkfs_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func getDevicesForFsStage(path []disk.Entity, filename string) map[string]Device
// - org.osbuild.mkfs.*: for all filesystems and btrfs volumes
// - org.osbuild.btrfs.subvol: for all btrfs subvolumes
// - org.osbuild.mkswap: for swap areas
func GenFsStages(pt *disk.PartitionTable, filename string) []*Stage {
func GenFsStages(pt *disk.PartitionTable, filename string, soucePipeline string) []*Stage {
stages := make([]*Stage, 0, len(pt.Partitions))

genStage := func(ent disk.Entity, path []disk.Entity) error {
Expand Down Expand Up @@ -99,7 +99,7 @@ func GenFsStages(pt *disk.PartitionTable, filename string) []*Stage {
options := &WriteDeviceStageOptions{
From: fmt.Sprintf("input://%s", filepath.Join(inputName, e.SourcePath)),
}
inputs := NewPipelineTreeInputs(inputName, e.SourcePipeline)
inputs := NewPipelineTreeInputs(inputName, soucePipeline)
stages = append(stages, NewWriteDeviceStage(options, inputs, stageDevices))
}
return nil
Expand Down
10 changes: 5 additions & 5 deletions pkg/osbuild/mkfs_stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestNewMkfsStage(t *testing.T) {

func TestGenFsStages(t *testing.T) {
pt := testdisk.MakeFakePartitionTable("/", "/boot", "/boot/efi", "swap")
stages := GenFsStages(pt, "file.img")
stages := GenFsStages(pt, "file.img", "build")
assert.Equal(t, []*Stage{
{
Type: "org.osbuild.mkfs.ext4",
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestGenFsStages(t *testing.T) {
func TestGenFsStagesBtrfs(t *testing.T) {
// Let's put there /extra to make sure that / and /extra creates only one btrfs partition
pt := testdisk.MakeFakeBtrfsPartitionTable("/", "/boot", "/boot/efi", "/extra", "swap")
stages := GenFsStages(pt, "file.img")
stages := GenFsStages(pt, "file.img", "build")
assert.Equal(t, []*Stage{
{
Type: "org.osbuild.mkfs.ext4",
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestGenFsStagesBtrfs(t *testing.T) {

func TestGenFsStagesLVM(t *testing.T) {
pt := testdisk.MakeFakeLVMPartitionTable("/", "/boot", "/boot/efi", "/home", "swap")
stages := GenFsStages(pt, "file.img")
stages := GenFsStages(pt, "file.img", "build")
assert.Equal(t, []*Stage{
{
Type: "org.osbuild.mkfs.ext4",
Expand Down Expand Up @@ -365,7 +365,7 @@ func TestGenFsStagesLVM(t *testing.T) {

func TestGenFsStagesRaw(t *testing.T) {
pt := testdisk.MakeFakePartitionTable("/", "/boot", "/boot/efi", "raw")
stages := GenFsStages(pt, "file.img")
stages := GenFsStages(pt, "file.img", "build")
assert.Equal(t, []*Stage{
{
Type: "org.osbuild.mkfs.ext4",
Expand Down Expand Up @@ -448,6 +448,6 @@ func TestGenFsStagesUnhappy(t *testing.T) {
}

assert.PanicsWithValue(t, "unknown fs type: ext2", func() {
GenFsStages(pt, "file.img")
GenFsStages(pt, "file.img", "build")
})
}
Loading