From a6984b0b8498c5d00344821cea0794315d2f3209 Mon Sep 17 00:00:00 2001 From: Hans Gaiser Date: Thu, 7 Jan 2021 19:29:55 +0100 Subject: [PATCH] Add pacman_conf argument for alma create. (#68) --- src/args.rs | 6 ++++++ src/main.rs | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/args.rs b/src/args.rs index 346f4c4..5c360ac 100644 --- a/src/args.rs +++ b/src/args.rs @@ -38,6 +38,12 @@ pub struct CreateCommand { #[structopt(parse(from_os_str))] pub path: Option, + /// Path to a pacman.conf file which will be used to pacstrap packages into the image. + /// + /// This pacman.conf will also be copied into the resulting Arch Linux image. + #[structopt(short = "c", long = "pacman-conf", value_name = "pacman_conf")] + pub pacman_conf: Option, + /// Additional packages to install #[structopt(short = "p", long = "extra-packages", value_name = "package")] pub extra_packages: Vec, diff --git a/src/main.rs b/src/main.rs index 136afe0..49b301d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -234,9 +234,15 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> { packages.extend(constants::AUR_DEPENDENCIES.iter().map(|s| String::from(*s))); + let pacman_conf_path = command + .pacman_conf + .unwrap_or_else(|| "/etc/pacman.conf".into()); + info!("Bootstrapping system"); pacstrap .execute() + .arg("-C") + .arg(&pacman_conf_path) .arg("-c") .arg(mount_point.path()) .args(packages) @@ -244,6 +250,10 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> { .run() .context("Pacstrap error")?; + // Copy pacman.conf to the image. + fs::copy(pacman_conf_path, mount_point.path().join("etc/pacman.conf")) + .context("Failed copying pacman.conf")?; + let fstab = fix_fstab( &genfstab .execute()