ksud: Add command to shrink image

This commit is contained in:
weishu
2024-01-30 13:23:49 +08:00
parent d43b40572d
commit 7cb5fb47e1
2 changed files with 13 additions and 0 deletions

View File

@@ -172,6 +172,9 @@ enum Module {
/// list all modules /// list all modules
List, List,
/// Shrink module image size
Shrink,
} }
#[derive(clap::Subcommand, Debug)] #[derive(clap::Subcommand, Debug)]
@@ -251,6 +254,7 @@ pub fn run() -> Result<()> {
Module::Enable { id } => module::enable_module(&id), Module::Enable { id } => module::enable_module(&id),
Module::Disable { id } => module::disable_module(&id), Module::Disable { id } => module::disable_module(&id),
Module::List => module::list_modules(), Module::List => module::list_modules(),
Module::Shrink => module::shrink_image(),
} }
} }
Commands::Install => event::install(), Commands::Install => event::install(),

View File

@@ -673,3 +673,12 @@ pub fn list_modules() -> Result<()> {
println!("{}", serde_json::to_string_pretty(&modules)?); println!("{}", serde_json::to_string_pretty(&modules)?);
Ok(()) Ok(())
} }
pub fn shrink_image() -> Result<()> {
Command::new("resize2fs")
.arg("-M")
.arg(defs::MODULE_IMG)
.stdout(Stdio::piped())
.status()?;
Ok(())
}