-
Notifications
You must be signed in to change notification settings - Fork 97
Basic support for aboot support in bootc-image-builder #1782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package disk | ||
|
|
||
| import ( | ||
| "reflect" | ||
| ) | ||
|
|
||
| // Raw defines the payload for a raw partition. It's similar to a | ||
| // [Filesystem] but with fewer fields. It is a [PayloadEntity]. | ||
|
mvo5 marked this conversation as resolved.
|
||
| type Raw struct { | ||
| SourcePipeline string | ||
| SourcePath string | ||
| } | ||
|
|
||
| func init() { | ||
| payloadEntityMap["raw"] = reflect.TypeOf(Raw{}) | ||
| } | ||
|
|
||
| func (s *Raw) EntityName() string { | ||
| return "raw" | ||
| } | ||
|
|
||
| func (s *Raw) Clone() Entity { | ||
| if s == nil { | ||
| return nil | ||
| } | ||
|
|
||
| return &Raw{ | ||
| SourcePipeline: s.SourcePipeline, | ||
| SourcePath: s.SourcePath, | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package disk_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/osbuild/images/pkg/disk" | ||
| ) | ||
|
|
||
| func TestImplementsInterfacesCompileTimeCheckRaw(t *testing.T) { | ||
| var _ = disk.PayloadEntity(&disk.Raw{}) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,29 @@ package osbuild | |
|
|
||
| import ( | ||
| "fmt" | ||
| "path/filepath" | ||
| "slices" | ||
| "strings" | ||
|
|
||
| "github.com/osbuild/images/internal/common" | ||
| "github.com/osbuild/images/pkg/disk" | ||
| ) | ||
|
|
||
| // Helper to create the `devices` option for the stage with the right | ||
| // name such that the last device is the target. | ||
| func getDevicesForFsStage(path []disk.Entity, filename string) map[string]Device { | ||
| stageDevices, lastName := getDevices(path, filename, true) | ||
|
|
||
| // The last device in the chain must be named "device", | ||
| // because that's the device that mkfs and write-device stages | ||
| // run on. See the stage schemas for reference. | ||
| lastDevice := stageDevices[lastName] | ||
| delete(stageDevices, lastName) | ||
| stageDevices["device"] = lastDevice | ||
|
|
||
| return stageDevices | ||
| } | ||
|
|
||
| // GenFsStages generates a list of stages that create the filesystem and other | ||
| // related entities. Specifically, it creates stages for: | ||
| // - org.osbuild.mkfs.*: for all filesystems and btrfs volumes | ||
|
|
@@ -20,15 +36,7 @@ func GenFsStages(pt *disk.PartitionTable, filename string) []*Stage { | |
| genStage := func(ent disk.Entity, path []disk.Entity) error { | ||
| switch e := ent.(type) { | ||
| case *disk.Filesystem: | ||
| // TODO: extract last device renaming into helper | ||
| stageDevices, lastName := getDevices(path, filename, true) | ||
|
|
||
| // The last device in the chain must be named "device", because that's | ||
| // the device that mkfs stages run on. See the stage schemas for | ||
| // reference. | ||
| lastDevice := stageDevices[lastName] | ||
| delete(stageDevices, lastName) | ||
| stageDevices["device"] = lastDevice | ||
| stageDevices := getDevicesForFsStage(path, filename) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ Thanks for consolidating this! |
||
|
|
||
| switch e.GetFSType() { | ||
| case "xfs": | ||
|
|
@@ -57,14 +65,7 @@ func GenFsStages(pt *disk.PartitionTable, filename string) []*Stage { | |
| panic(fmt.Sprintf("unknown fs type: %s", e.GetFSType())) | ||
| } | ||
| case *disk.Btrfs: | ||
| stageDevices, lastName := getDevices(path, filename, true) | ||
|
|
||
| // The last device in the chain must be named "device", because that's | ||
| // the device that mkfs stages run on. See the stage schemas for | ||
| // reference. | ||
| lastDevice := stageDevices[lastName] | ||
| delete(stageDevices, lastName) | ||
| stageDevices["device"] = lastDevice | ||
| stageDevices := getDevicesForFsStage(path, filename) | ||
|
|
||
| options := &MkfsBtrfsStageOptions{ | ||
| UUID: e.UUID, | ||
|
|
@@ -84,21 +85,22 @@ func GenFsStages(pt *disk.PartitionTable, filename string) []*Stage { | |
| mount := *NewBtrfsMount("volume", "device", "/", "", "") | ||
| stages = append(stages, NewBtrfsSubVol(&BtrfsSubVolOptions{subvolumes}, &stageDevices, &[]Mount{mount})) | ||
| case *disk.Swap: | ||
| // TODO: extract last device renaming into helper | ||
| stageDevices, lastName := getDevices(path, filename, true) | ||
|
|
||
| // The last device in the chain must be named "device", because that's | ||
| // the device that the mkswap stage runs on. See the stage schema | ||
| // for reference. | ||
| lastDevice := stageDevices[lastName] | ||
| delete(stageDevices, lastName) | ||
| stageDevices["device"] = lastDevice | ||
| stageDevices := getDevicesForFsStage(path, filename) | ||
|
|
||
| options := &MkswapStageOptions{ | ||
| UUID: e.UUID, | ||
| Label: e.Label, | ||
| } | ||
| stages = append(stages, NewMkswapStage(options, stageDevices)) | ||
| case *disk.Raw: | ||
| stageDevices := getDevicesForFsStage(path, filename) | ||
|
|
||
| inputName := "tree" | ||
| options := &WriteDeviceStageOptions{ | ||
| From: fmt.Sprintf("input://%s", filepath.Join(inputName, e.SourcePath)), | ||
| } | ||
| inputs := NewPipelineTreeInputs(inputName, e.SourcePipeline) | ||
| stages = append(stages, NewWriteDeviceStage(options, inputs, stageDevices)) | ||
|
mvo5 marked this conversation as resolved.
|
||
| } | ||
| return nil | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package osbuild | ||
|
|
||
| type WriteDeviceStageOptions struct { | ||
| From string `json:"from"` | ||
| } | ||
|
|
||
| func (WriteDeviceStageOptions) isStageOptions() {} | ||
|
|
||
| func NewWriteDeviceStage(options *WriteDeviceStageOptions, inputs Inputs, devices map[string]Device) *Stage { | ||
| return &Stage{ | ||
| Type: "org.osbuild.write-device", | ||
| Options: options, | ||
| Inputs: inputs, | ||
| Devices: devices, | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.