-
Notifications
You must be signed in to change notification settings - Fork 131
composefs-native/uki: Handle UKI addons #1573
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
Draft
Johan-Liebert1
wants to merge
27
commits into
bootc-dev:composefs-backend
Choose a base branch
from
Johan-Liebert1:uki-addons
base: composefs-backend
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
2bd9e4c
WIP: composefs backend
Johan-Liebert1 c45dab5
Rework composefs_booted to use kernel cmdline
cgwalters d562f07
composefs/status: Read UKI entries to check for queued rollback
Johan-Liebert1 839b858
parser/grub: Use String instead of &str
Johan-Liebert1 9f7ca60
composefs/rollback: Handle UKI rollback
Johan-Liebert1 e95af76
composefs/state: Use atomic writes for origin and staged deployment f…
Johan-Liebert1 db48741
composefs/boot/bls: Handle duplicate VMLinuz + Initrd
Johan-Liebert1 7e05aa6
parser/bls: `impl Display` for BLSConfig
Johan-Liebert1 a6bcfbe
lib/composefs: Centralize constants
Johan-Liebert1 f2d77c1
composefs/state: Name state directory `default`
Johan-Liebert1 1425225
parser/bls: Add tests for bls parser
Johan-Liebert1 e9206ff
install/composefs/uki: Write only staged + booted menuentry on upgrade
Johan-Liebert1 64f5ec3
rollback/composefs: Print whether we are reverting the queued rollback
Johan-Liebert1 f3ab5b3
refactor: Pass boot dir to boot entry readers
Johan-Liebert1 f65d5dd
test: Add tests for reading boot entries
Johan-Liebert1 0fb6edd
Drop duplicate bls_config
cgwalters 01bade0
install: Use read_file from composefs-boot
cgwalters 7435396
install: Fix cargo fmt
cgwalters a324f58
status: Use constant for composefs
cgwalters 705eaf8
status: Enhance composefs cmdline parsing to handle ?
cgwalters 20bd11f
composefs-backend: store boot assets in ESP during install
p5 b45ef30
Post-rebase fixups:
jeckersb a8313cb
composefs/install/bls: Fix empty version in config
Johan-Liebert1 d7adf7d
Merge pull request #1558 from Johan-Liebert1/bls-version-fix
cgwalters 1d8606c
composefs/install: Copy /etc contents to state
Johan-Liebert1 fd703ec
Merge pull request #1560 from Johan-Liebert1/bind-mnt-etc
cgwalters 5a03150
composefs-native/uki: Handle UKI addons
Johan-Liebert1 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
pub(crate) mod state; |
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,47 @@ | ||
use std::process::Command; | ||
|
||
use anyhow::{Context, Result}; | ||
use bootc_utils::CommandRunExt; | ||
use camino::Utf8PathBuf; | ||
use fn_error_context::context; | ||
|
||
use rustix::{ | ||
fs::{open, Mode, OFlags, CWD}, | ||
mount::{unmount, UnmountFlags}, | ||
path::Arg, | ||
}; | ||
|
||
/// Mounts an EROFS image and copies the pristine /etc to the deployment's /etc | ||
#[context("Copying etc")] | ||
pub(crate) fn copy_etc_to_state( | ||
sysroot_path: &Utf8PathBuf, | ||
erofs_id: &String, | ||
state_path: &Utf8PathBuf, | ||
) -> Result<()> { | ||
let sysroot_fd = open( | ||
sysroot_path.as_std_path(), | ||
OFlags::PATH | OFlags::DIRECTORY | OFlags::CLOEXEC, | ||
Mode::empty(), | ||
) | ||
.context("Opening sysroot")?; | ||
|
||
let composefs_fd = bootc_initramfs_setup::mount_composefs_image(&sysroot_fd, &erofs_id, false)?; | ||
|
||
let tempdir = tempfile::tempdir().context("Creating tempdir")?; | ||
|
||
bootc_initramfs_setup::mount_at_wrapper(composefs_fd, CWD, tempdir.path())?; | ||
|
||
// TODO: Replace this with a function to cap_std_ext | ||
let cp_ret = Command::new("cp") | ||
.args([ | ||
"-a", | ||
&format!("{}/etc/.", tempdir.path().as_str()?), | ||
&format!("{state_path}/etc/."), | ||
]) | ||
.run_capture_stderr(); | ||
|
||
// Unmount regardless of copy succeeding | ||
unmount(tempdir.path(), UnmountFlags::DETACH).context("Unmounting composefs")?; | ||
|
||
cp_ret | ||
} |
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,35 @@ | ||
/// composefs= paramter in kernel cmdline | ||
pub const COMPOSEFS_CMDLINE: &str = "composefs"; | ||
|
||
/// Directory to store transient state, such as staged deployemnts etc | ||
pub(crate) const COMPOSEFS_TRANSIENT_STATE_DIR: &str = "/run/composefs"; | ||
/// File created in /run/composefs to record a staged-deployment | ||
pub(crate) const COMPOSEFS_STAGED_DEPLOYMENT_FNAME: &str = "staged-deployment"; | ||
|
||
/// Absolute path to composefs-native state directory | ||
pub(crate) const STATE_DIR_ABS: &str = "/sysroot/state/deploy"; | ||
/// Relative path to composefs-native state directory. Relative to /sysroot | ||
pub(crate) const STATE_DIR_RELATIVE: &str = "state/deploy"; | ||
/// Relative path to the shared 'var' directory. Relative to /sysroot | ||
pub(crate) const SHARED_VAR_PATH: &str = "state/os/default/var"; | ||
|
||
/// Section in .origin file to store boot related metadata | ||
pub(crate) const ORIGIN_KEY_BOOT: &str = "boot"; | ||
/// Whether the deployment was booted with BLS or UKI | ||
pub(crate) const ORIGIN_KEY_BOOT_TYPE: &str = "boot_type"; | ||
/// Key to store the SHA256 sum of vmlinuz + initrd for a deployment | ||
pub(crate) const ORIGIN_KEY_BOOT_DIGEST: &str = "digest"; | ||
|
||
/// Filename for `loader/entries` | ||
pub(crate) const BOOT_LOADER_ENTRIES: &str = "entries"; | ||
/// Filename for staged boot loader entries | ||
pub(crate) const STAGED_BOOT_LOADER_ENTRIES: &str = "entries.staged"; | ||
/// Filename for rollback boot loader entries | ||
pub(crate) const ROLLBACK_BOOT_LOADER_ENTRIES: &str = STAGED_BOOT_LOADER_ENTRIES; | ||
|
||
/// Filename for grub user config | ||
pub(crate) const USER_CFG: &str = "user.cfg"; | ||
/// Filename for staged grub user config | ||
pub(crate) const USER_CFG_STAGED: &str = "user.cfg.staged"; | ||
/// Filename for rollback grub user config | ||
pub(crate) const USER_CFG_ROLLBACK: &str = USER_CFG_STAGED; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to
setup_composefs_bls_boot
here uses&entry
, but a similar call inupgrade_composefs
(line 961) usesentry
. In both functions,entry
is of type&ComposefsBootEntry
. While using&entry
works due to auto-dereferencing, for consistency and clarity it would be better to useentry
in both places.entry,