Skip to content

Commit 1102422

Browse files
committed
container: Add export --format=tar command
Implement bootc container export command to export container filesystems as bootable tar archives with proper metadata preservation and bootc- specific features. Key features: - Export container filesystems to tar format - Preserve file permissions, ownership, and metadata - Kernel relocation from /usr/lib/modules to /boot for legacy compatibility - Support for output to file or stdout - Comprehensive error handling and validation - Basic test coverage for core functionality Fixes #1957 Assisted-by: OpenCode (Sonnet 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 5d6dd67 commit 1102422

File tree

4 files changed

+651
-0
lines changed

4 files changed

+651
-0
lines changed

crates/lib/src/cli.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,32 @@ pub(crate) enum ContainerOpts {
415415
#[clap(last = true)]
416416
args: Vec<OsString>,
417417
},
418+
/// Export container filesystem as a tar archive.
419+
///
420+
/// This command exports the container filesystem in a bootable format with proper
421+
/// SELinux labeling and optional kernel relocation for legacy compatibility.
422+
/// The output is written to stdout by default or to a specified file.
423+
///
424+
/// Example:
425+
/// bootc container export /target > output.tar
426+
Export {
427+
/// Format for export output
428+
#[clap(long, default_value = "tar")]
429+
format: ExportFormat,
430+
431+
/// Output file (defaults to stdout)
432+
#[clap(long, short = 'o')]
433+
output: Option<Utf8PathBuf>,
434+
435+
/// Path to the container filesystem root
436+
target: Utf8PathBuf,
437+
},
438+
}
439+
440+
#[derive(Debug, Clone, ValueEnum, PartialEq, Eq)]
441+
pub(crate) enum ExportFormat {
442+
/// Export as tar archive
443+
Tar,
418444
}
419445

420446
/// Subcommands which operate on images.
@@ -1626,6 +1652,11 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
16261652
kargs,
16271653
args,
16281654
} => crate::ukify::build_ukify(&rootfs, &kargs, &args),
1655+
ContainerOpts::Export {
1656+
format,
1657+
target,
1658+
output,
1659+
} => crate::container_export::export(&format, &target, output.as_deref()).await,
16291660
},
16301661
Opt::Completion { shell } => {
16311662
use clap_complete::aot::generate;

0 commit comments

Comments
 (0)