Add pacman_conf argument for alma create. (#68)

This commit is contained in:
Hans Gaiser 2021-01-07 19:29:55 +01:00 committed by Philip Mueller
parent 0680de7c42
commit a6984b0b84
2 changed files with 16 additions and 0 deletions

View File

@ -38,6 +38,12 @@ pub struct CreateCommand {
#[structopt(parse(from_os_str))]
pub path: Option<PathBuf>,
/// 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<PathBuf>,
/// Additional packages to install
#[structopt(short = "p", long = "extra-packages", value_name = "package")]
pub extra_packages: Vec<String>,

View File

@ -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()