Skip to content

Commit

Permalink
manifest/RawOSTreeImage: don't hardcode FS root mount name
Browse files Browse the repository at this point in the history
The `RawOSTreeImage` `serialize()` method made an assumption when
generating the org.osbuild.copy stage options, that the mount name
for the filesystem root is "root". While this worked so far, the
method should not rely on this behavior, since it would break if
we change the implementation of escaping mountpoint paths.

Modify the function to determine the mount name of the Entity
based on the mountpoint path while iterating over all partition table
entities. Specifically, use the mount name of the one with mountpoint
`/`.

Signed-off-by: Tomáš Hozza <[email protected]>
  • Loading branch information
thozza authored and achilleas-k committed Nov 3, 2023
1 parent f935073 commit 430cb77
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/manifest/raw_ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,24 @@ func (p *RawOSTreeImage) serialize() osbuild.Pipeline {
"ostree-tree": *osbuild.NewOSTreeCheckoutInput("org.osbuild.source", commitChecksum),
}

// Find the FS root mount name to use as the destination root
// for the target when copying the boot files.
var fsRootMntName string
for _, mnt := range *bootCopyMounts {
if mnt.Target == "/" {
fsRootMntName = mnt.Name
break
}
}

if fsRootMntName == "" {
panic("no mount found for the filesystem root")
}

for _, paths := range bootFiles {
bootCopyOptions.Paths = append(bootCopyOptions.Paths, osbuild.CopyStagePath{
From: fmt.Sprintf("input://ostree-tree/%s%s", commitChecksum, paths[0]),
To: fmt.Sprintf("mount://root%s", paths[1]),
To: fmt.Sprintf("mount://%s%s", fsRootMntName, paths[1]),
})
}

Expand Down

0 comments on commit 430cb77

Please sign in to comment.