Skip to content

Commit 0897684

Browse files
authored
Merge pull request #102 from cgwalters/fs-no-xfsfreeze
Two crate bumps and use `fsfreeze`
2 parents 5303993 + 15de723 commit 0897684

File tree

8 files changed

+24
-22
lines changed

8 files changed

+24
-22
lines changed

cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ platforms = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "powerpc64
1919
[dependencies]
2020
anyhow = "1.0"
2121
bootc-lib = { version = "0.1", path = "../lib" }
22-
clap = "3.2"
22+
clap = "4.2"
2323
libc = "0.2.92"
2424
tokio = { version = "1", features = ["macros"] }
2525
log = "0.4.0"

lib/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ rust-version = "1.64.0"
1111
[dependencies]
1212
anyhow = "1.0"
1313
camino = { version = "1.0.4", features = ["serde1"] }
14-
ostree-ext = "0.10.6"
15-
clap = { version= "3.2", features = ["derive"] }
16-
clap_mangen = { version = "0.1", optional = true }
17-
cap-std-ext = "1.0.1"
14+
ostree-ext = "0.11"
15+
clap = { version= "4.2", features = ["derive"] }
16+
clap_mangen = { version = "0.2", optional = true }
17+
cap-std-ext = "2"
1818
hex = "^0.4"
1919
fn-error-context = "0.2.0"
2020
gvariant = "0.4.0"
@@ -25,7 +25,7 @@ once_cell = "1.9"
2525
openssl = "^0.10"
2626
nix = ">= 0.24, < 0.26"
2727
regex = "1.7.1"
28-
rustix = { "version" = "0.36", features = ["thread"] }
28+
rustix = { "version" = "0.37", features = ["thread", "process"] }
2929
serde = { features = ["derive"], version = "1.0.125" }
3030
serde_json = "1.0.64"
3131
serde_with = ">= 1.9.4, < 2"

lib/src/cli.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
use anyhow::{Context, Result};
66
use camino::Utf8PathBuf;
7-
use cap_std_ext::rustix;
87
use clap::Parser;
98
use fn_error_context::context;
109
use ostree::{gio, glib};
@@ -145,7 +144,7 @@ pub(crate) async fn ensure_self_unshared_mount_namespace() -> Result<()> {
145144
return Ok(());
146145
}
147146
if std::env::var_os(recurse_env).is_some() {
148-
let am_pid1 = cap_std_ext::rustix::process::getpid().is_init();
147+
let am_pid1 = rustix::process::getpid().is_init();
149148
if am_pid1 {
150149
tracing::debug!("We are pid 1");
151150
return Ok(());
@@ -237,7 +236,7 @@ pub(crate) fn require_root() -> Result<()> {
237236
if !uid.is_root() {
238237
anyhow::bail!("This command requires root privileges");
239238
}
240-
if !rustix::thread::is_in_capability_bounding_set(rustix::thread::Capability::SystemAdmin)? {
239+
if !rustix::thread::capability_is_in_bounding_set(rustix::thread::Capability::SystemAdmin)? {
241240
anyhow::bail!("This command requires full root privileges (CAP_SYS_ADMIN)");
242241
}
243242
Ok(())
@@ -263,10 +262,10 @@ async fn prepare_for_write() -> Result<()> {
263262
async fn upgrade(opts: UpgradeOpts) -> Result<()> {
264263
prepare_for_write().await?;
265264
let sysroot = &get_locked_sysroot().await?;
266-
let repo = &sysroot.repo().unwrap();
265+
let repo = &sysroot.repo();
267266
let booted_deployment = &sysroot.require_booted_deployment()?;
268267
let status = crate::status::DeploymentStatus::from_deployment(booted_deployment, true)?;
269-
let osname = booted_deployment.osname().unwrap();
268+
let osname = booted_deployment.osname();
270269
let origin = booted_deployment
271270
.origin()
272271
.ok_or_else(|| anyhow::anyhow!("Deployment is missing an origin"))?;
@@ -279,7 +278,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
279278
"Booted deployment contains local rpm-ostree modifications; cannot upgrade via bootc"
280279
));
281280
}
282-
let commit = booted_deployment.csum().unwrap();
281+
let commit = booted_deployment.csum();
283282
let state = ostree_container::store::query_image_commit(repo, &commit)?;
284283
let digest = state.manifest_digest.as_str();
285284
let fetched = pull(repo, &imgref, opts.quiet).await?;
@@ -308,8 +307,8 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
308307
let booted_deployment = &sysroot.require_booted_deployment()?;
309308
let (origin, booted_image) = crate::utils::get_image_origin(booted_deployment)?;
310309
let booted_refspec = origin.optional_string("origin", "refspec")?;
311-
let osname = booted_deployment.osname().unwrap();
312-
let repo = &sysroot.repo().unwrap();
310+
let osname = booted_deployment.osname();
311+
let repo = &sysroot.repo();
313312

314313
let transport = ostree_container::Transport::try_from(opts.transport.as_str())?;
315314
let imgref = ostree_container::ImageReference {

lib/src/docgen.rs

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ fn generate_one(directory: &Utf8Path, cmd: Command) -> Result<()> {
3636

3737
for subcmd in cmd.get_subcommands().filter(|c| !c.is_hide_set()) {
3838
let subname = format!("{}-{}", name, subcmd.get_name());
39+
// SAFETY: Latest clap 4 requires names are &'static - this is
40+
// not long-running production code, so we just leak the names here.
41+
let subname = &*std::boxed::Box::leak(subname.into_boxed_str());
42+
let subcmd = subcmd.clone().name(subname).alias(subname).version(version);
3943
generate_one(directory, subcmd.clone().name(subname).version(version))?;
4044
}
4145
Ok(())

lib/src/install.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use camino::Utf8PathBuf;
2020
use cap_std::fs::Dir;
2121
use cap_std_ext::cap_std;
2222
use cap_std_ext::prelude::CapStdExtDirExt;
23-
use cap_std_ext::rustix::fs::MetadataExt;
23+
use rustix::fs::MetadataExt;
2424

2525
use fn_error_context::context;
2626
use ostree::gio;
@@ -518,7 +518,7 @@ async fn initialize_ostree_root_from_self(
518518
.next()
519519
.ok_or_else(|| anyhow::anyhow!("Failed to find deployment"))?;
520520
// SAFETY: There must be a path
521-
let path = sysroot.deployment_dirpath(&deployment).unwrap();
521+
let path = sysroot.deployment_dirpath(&deployment);
522522
let root = rootfs_dir
523523
.open_dir(path.as_str())
524524
.context("Opening deployment dir")?;
@@ -531,7 +531,7 @@ async fn initialize_ostree_root_from_self(
531531
writeln!(f, "{}", root_setup.boot.to_fstab())?;
532532
f.flush()?;
533533

534-
let uname = cap_std_ext::rustix::process::uname();
534+
let uname = rustix::process::uname();
535535

536536
let aleph = InstallAleph {
537537
image: src_imageref.imgref.name.clone(),
@@ -670,7 +670,7 @@ pub(crate) fn finalize_filesystem(fs: &Utf8Path) -> Result<()> {
670670
.run()?;
671671
// Finally, freezing (and thawing) the filesystem will flush the journal, which means the next boot is clean.
672672
for a in ["-f", "-u"] {
673-
Task::new("Flushing filesystem journal", "xfs_freeze")
673+
Task::new("Flushing filesystem journal", "fsfreeze")
674674
.quiet()
675675
.args([a, fs.as_str()])
676676
.run()?;

lib/src/install/baseline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use camino::Utf8Path;
1717
use camino::Utf8PathBuf;
1818
use cap_std::fs::Dir;
1919
use cap_std_ext::cap_std;
20-
use clap::ArgEnum;
20+
use clap::ValueEnum;
2121
use fn_error_context::context;
2222
use serde::{Deserialize, Serialize};
2323

lib/src/privtests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::process::Command;
22

33
use anyhow::Result;
44
use camino::{Utf8Path, Utf8PathBuf};
5-
use cap_std_ext::rustix;
65
use fn_error_context::context;
76
use rustix::fd::AsFd;
87
use xshell::{cmd, Shell};

lib/src/status.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl DeploymentStatus {
6565
let staged = deployment.is_staged();
6666
let pinned = deployment.is_pinned();
6767
let image = get_image_origin(deployment)?.1;
68-
let checksum = deployment.csum().unwrap().to_string();
68+
let checksum = deployment.csum().to_string();
6969
let deploy_serial = (!staged).then(|| deployment.bootserial().try_into().unwrap());
7070
let supported = deployment
7171
.origin()
@@ -119,7 +119,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
119119
return Ok(());
120120
}
121121
let sysroot = super::cli::get_locked_sysroot().await?;
122-
let repo = &sysroot.repo().unwrap();
122+
let repo = &sysroot.repo();
123123
let booted_deployment = sysroot.booted_deployment();
124124

125125
let deployments = get_deployments(&sysroot, booted_deployment.as_ref(), opts.booted)?;

0 commit comments

Comments
 (0)