Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ composefs = { version = "0.3.0", path = "crates/composefs", default-features = f
composefs-oci = { version = "0.3.0", path = "crates/composefs-oci", default-features = false }
composefs-boot = { version = "0.3.0", path = "crates/composefs-boot", default-features = false }
composefs-http = { version = "0.3.0", path = "crates/composefs-http", default-features = false }
composefs-ostree = { version = "0.3.0", path = "crates/composefs-ostree", default-features = false }

[profile.dev.package.sha2]
# this is *really* slow otherwise
Expand Down
4 changes: 3 additions & 1 deletion crates/cfsctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ rust-version.workspace = true
version.workspace = true

[features]
default = ['pre-6.15', 'oci']
default = ['pre-6.15', 'oci','ostree']
http = ['composefs-http']
oci = ['composefs-oci']
ostree = ['composefs-ostree']
rhel9 = ['composefs/rhel9']
'pre-6.15' = ['composefs/pre-6.15']

Expand All @@ -24,6 +25,7 @@ composefs = { workspace = true }
composefs-boot = { workspace = true }
composefs-oci = { workspace = true, optional = true }
composefs-http = { workspace = true, optional = true }
composefs-ostree = { workspace = true, optional = true }
env_logger = { version = "0.11.0", default-features = false }
hex = { version = "0.4.0", default-features = false }
rustix = { version = "1.0.0", default-features = false, features = ["fs", "process"] }
Expand Down
75 changes: 75 additions & 0 deletions crates/cfsctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,31 @@ enum OciCommand {
},
}

#[cfg(feature = "ostree")]
#[derive(Debug, Subcommand)]
enum OstreeCommand {
PullLocal {
ostree_repo_path: PathBuf,
ostree_ref: String,
#[clap(long)]
base_name: Option<String>,
},
Pull {
ostree_repo_url: String,
ostree_ref: String,
#[clap(long)]
base_name: Option<String>,
},
CreateImage {
commit_name: String,
#[clap(long)]
image_name: Option<String>,
},
Inspect {
commit_name: String,
},
}

/// Common options for reading a filesystem from a path
#[derive(Debug, Parser)]
struct FsReadOptions {
Expand Down Expand Up @@ -151,6 +176,12 @@ enum Command {
#[clap(subcommand)]
cmd: OciCommand,
},
/// Commands for dealing with OSTree commits
#[cfg(feature = "ostree")]
Ostree {
#[clap(subcommand)]
cmd: OstreeCommand,
},
/// Mounts a composefs, possibly enforcing fsverity of the image
Mount {
/// the name of the image to mount, either an fs-verity hash or prefixed with 'ref/'
Expand Down Expand Up @@ -374,6 +405,50 @@ where
let id = fs.compute_image_id();
println!("{}", id.to_hex());
}
#[cfg(feature = "ostree")]
Command::Ostree { cmd: ostree_cmd } => match ostree_cmd {
OstreeCommand::PullLocal {
ref ostree_repo_path,
ref ostree_ref,
base_name,
} => {
let verity = composefs_ostree::pull_local(
&Arc::new(repo),
ostree_repo_path,
ostree_ref,
base_name.as_deref(),
)
.await?;

println!("verity {}", verity.to_hex());
}
OstreeCommand::Pull {
ref ostree_repo_url,
ref ostree_ref,
base_name,
} => {
let verity = composefs_ostree::pull(
&Arc::new(repo),
ostree_repo_url,
ostree_ref,
base_name.as_deref(),
)
.await?;

println!("verity {}", verity.to_hex());
}
OstreeCommand::CreateImage {
ref commit_name,
ref image_name,
} => {
let fs = composefs_ostree::create_filesystem(&repo, commit_name)?;
let image_id = fs.commit_image(&repo, image_name.as_deref())?;
println!("{}", image_id.to_id());
}
OstreeCommand::Inspect { ref commit_name } => {
composefs_ostree::inspect(&repo, commit_name)?;
}
},
Command::CreateImage {
fs_opts,
ref image_name,
Expand Down
29 changes: 29 additions & 0 deletions crates/composefs-ostree/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "composefs-ostree"
description = "ostree support for composefs"
keywords = ["composefs", "ostree"]

edition.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[dependencies]
anyhow = { version = "1.0.87", default-features = false }
composefs = { workspace = true }
configparser = { version = "3.1.0", features = [] }
flate2 = { version = "1.1.2", default-features = true }
gvariant = { version = "0.5.0", default-features = true}
hex = { version = "0.4.0", default-features = false, features = ["std"] }
rustix = { version = "1.0.0", default-features = false, features = ["fs", "mount", "process", "std"] }
sha2 = { version = "0.10.1", default-features = false }
zerocopy = { version = "0.8.0", default-features = false, features = ["derive", "std"] }
reqwest = { version = "0.12.15", features = ["zstd"] }

[dev-dependencies]
similar-asserts = "1.7.0"

[lints]
workspace = true
Loading
Loading