Skip to content

Commit

Permalink
manifest: write custom /etc/fstab in RawBootcImage
Browse files Browse the repository at this point in the history
With the new uniform way to handle writing to the bootc image deployment
we can now support a custom `/etc/fstab` again. Similar to what we
do for users [0] and groups [1] we allow also writing a custom fstab
now.

This will need osbuild/osbuild#1727 and also
probably a port of the fstab module to schema_2.

[0] #571
[1] #593
  • Loading branch information
mvo5 authored and ondrejbudai committed Apr 16, 2024
1 parent e83a229 commit ffb1918
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/manifest/raw_bootc.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ func (p *RawBootcImage) serialize() osbuild.Pipeline {
mounts = append(mounts, *osbuild.NewOSTreeDeploymentMountDefault("ostree.deployment", osbuild.OSTreeMountSourceMount))
mounts = append(mounts, *osbuild.NewBindMount("bind-ostree-deployment-to-tree", "mount://", "tree://"))

// we always include the fstab stage
fstabStage := osbuild.NewFSTabStage(osbuild.NewFSTabStageOptions(pt))
fstabStage.Mounts = mounts
fstabStage.Devices = devices
pipeline.AddStage(fstabStage)

// customize the image
if len(p.Groups) > 0 {
groupsStage := osbuild.GenGroupsStage(p.Groups)
Expand Down
29 changes: 29 additions & 0 deletions pkg/manifest/raw_bootc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,32 @@ func TestRawBootcImageSerializeCustomizationGenCorrectStages(t *testing.T) {
}
}
}

func RawBootcImageSerializeCommonPipelines(t *testing.T) {
expectedCommonStages := []string{
"org.osbuild.truncate",
"org.osbuild.sfdisk",
"org.osbuild.mkfs.ext4",
"org.osbuild.mkfs.ext4",
"org.osbuild.mkfs.fat",
"org.osbuild.bootc.install-to-filesystem",
"org.osbuild.fstab",
}
rawBootcPipeline := makeFakeRawBootcPipeline()
pipeline := rawBootcPipeline.Serialize()

pipelineStages := make([]string, len(pipeline.Stages))
for i, st := range pipeline.Stages {
pipelineStages[i] = st.Type
}
assert.Equal(t, expectedCommonStages, pipelineStages[0:len(expectedCommonStages)])
}

func RawBootcImageSerializeFstabPipelineHasBootcMounts(t *testing.T) {
rawBootcPipeline := makeFakeRawBootcPipeline()
pipeline := rawBootcPipeline.Serialize()

stage := manifest.FindStage("org.osbuild.fstab", pipeline.Stages)
assert.NotNil(t, stage)
assertBootcDeploymentAndBindMount(t, stage)
}

0 comments on commit ffb1918

Please sign in to comment.