Skip to content

Commit 18c5a1d

Browse files
authored
Merge pull request #1314 from Johan-Liebert1/composefs-backend
Composefs-native backend
2 parents 04f048f + 3d2385d commit 18c5a1d

File tree

16 files changed

+1295
-370
lines changed

16 files changed

+1295
-370
lines changed

Cargo.lock

Lines changed: 11 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/lib/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ tini = "1.3.0"
5656
comfy-table = "7.1.1"
5757
thiserror = { workspace = true }
5858
canon-json = { workspace = true }
59-
openat = "0.1.21"
60-
openat-ext = "0.2.3"
59+
nom = "8.0.0"
6160

6261
[dev-dependencies]
6362
similar-asserts = { workspace = true }

crates/lib/src/bls_config.rs

Lines changed: 0 additions & 88 deletions
This file was deleted.

crates/lib/src/cli.rs

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use ostree_container::store::PrepareResult;
2020
use ostree_ext::composefs::fsverity;
2121
use ostree_ext::composefs::fsverity::FsVerityHashValue;
2222
use ostree_ext::container as ostree_container;
23-
use ostree_ext::container_utils::{composefs_booted, ostree_booted};
23+
use ostree_ext::container_utils::ostree_booted;
2424
use ostree_ext::keyfileext::KeyFileExt;
2525
use ostree_ext::ostree;
2626
use schemars::schema_for;
@@ -36,7 +36,7 @@ use crate::progress_jsonl::{ProgressWriter, RawProgressFd};
3636
use crate::spec::Host;
3737
use crate::spec::ImageReference;
3838
use crate::status::composefs_deployment_status;
39-
use crate::utils::sigpolicy_from_opt;
39+
use crate::utils::{composefs_booted, sigpolicy_from_opt};
4040

4141
/// Shared progress options
4242
#[derive(Debug, Parser, PartialEq, Eq)]
@@ -798,13 +798,29 @@ async fn upgrade_composefs(_opts: UpgradeOpts) -> Result<()> {
798798
};
799799

800800
let boot_type = BootType::from(&entry);
801+
let mut boot_digest = None;
801802

802803
match boot_type {
803-
BootType::Bls => setup_composefs_bls_boot(BootSetupType::Upgrade, repo, &id, entry),
804-
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry),
805-
}?;
804+
BootType::Bls => {
805+
boot_digest = Some(setup_composefs_bls_boot(
806+
BootSetupType::Upgrade,
807+
repo,
808+
&id,
809+
entry,
810+
)?)
811+
}
806812

807-
write_composefs_state(&Utf8PathBuf::from("/sysroot"), id, imgref, true, boot_type)?;
813+
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry)?,
814+
};
815+
816+
write_composefs_state(
817+
&Utf8PathBuf::from("/sysroot"),
818+
id,
819+
imgref,
820+
true,
821+
boot_type,
822+
boot_digest,
823+
)?;
808824

809825
Ok(())
810826
}
@@ -966,18 +982,27 @@ async fn switch_composefs(opts: SwitchOpts) -> Result<()> {
966982
};
967983

968984
let boot_type = BootType::from(&entry);
985+
let mut boot_digest = None;
969986

970987
match boot_type {
971-
BootType::Bls => setup_composefs_bls_boot(BootSetupType::Upgrade, repo, &id, entry),
972-
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry),
973-
}?;
988+
BootType::Bls => {
989+
boot_digest = Some(setup_composefs_bls_boot(
990+
BootSetupType::Upgrade,
991+
repo,
992+
&id,
993+
entry,
994+
)?)
995+
}
996+
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry)?,
997+
};
974998

975999
write_composefs_state(
9761000
&Utf8PathBuf::from("/sysroot"),
9771001
id,
9781002
&target_imgref,
9791003
true,
9801004
boot_type,
1005+
boot_digest,
9811006
)?;
9821007

9831008
Ok(())

crates/lib/src/composefs_consts.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// composefs= paramter in kernel cmdline
2+
pub const COMPOSEFS_CMDLINE: &str = "composefs=";
3+
/// composefs=? paramter in kernel cmdline. The `?` signifies that the fs-verity validation is
4+
/// optional in case the filesystem doesn't support it.
5+
pub const COMPOSEFS_INSECURE_CMDLINE: &str = "composefs=?";
6+
7+
/// Directory to store transient state, such as staged deployemnts etc
8+
pub(crate) const COMPOSEFS_TRANSIENT_STATE_DIR: &str = "/run/composefs";
9+
/// File created in /run/composefs to record a staged-deployment
10+
pub(crate) const COMPOSEFS_STAGED_DEPLOYMENT_FNAME: &str = "staged-deployment";
11+
12+
/// Absolute path to composefs-native state directory
13+
pub(crate) const STATE_DIR_ABS: &str = "/sysroot/state/deploy";
14+
/// Relative path to composefs-native state directory. Relative to /sysroot
15+
pub(crate) const STATE_DIR_RELATIVE: &str = "state/deploy";
16+
/// Relative path to the shared 'var' directory. Relative to /sysroot
17+
pub(crate) const SHARED_VAR_PATH: &str = "state/os/default/var";
18+
19+
/// Section in .origin file to store boot related metadata
20+
pub(crate) const ORIGIN_KEY_BOOT: &str = "boot";
21+
/// Whether the deployment was booted with BLS or UKI
22+
pub(crate) const ORIGIN_KEY_BOOT_TYPE: &str = "boot_type";
23+
/// Key to store the SHA256 sum of vmlinuz + initrd for a deployment
24+
pub(crate) const ORIGIN_KEY_BOOT_DIGEST: &str = "digest";
25+
26+
/// Filename for `loader/entries`
27+
pub(crate) const BOOT_LOADER_ENTRIES: &str = "entries";
28+
/// Filename for staged boot loader entries
29+
pub(crate) const STAGED_BOOT_LOADER_ENTRIES: &str = "entries.staged";
30+
/// Filename for rollback boot loader entries
31+
pub(crate) const ROLLBACK_BOOT_LOADER_ENTRIES: &str = STAGED_BOOT_LOADER_ENTRIES;
32+
33+
/// Filename for grub user config
34+
pub(crate) const USER_CFG: &str = "user.cfg";
35+
/// Filename for staged grub user config
36+
pub(crate) const USER_CFG_STAGED: &str = "user.cfg.staged";
37+
/// Filename for rollback grub user config
38+
pub(crate) const USER_CFG_ROLLBACK: &str = USER_CFG_STAGED;

0 commit comments

Comments
 (0)