Add a flag for installing extra packages (fix #11)

This commit is contained in:
Roey Darwish Dror 2018-11-04 16:41:17 +02:00
parent 1ded17b500
commit b325104190
2 changed files with 22 additions and 4 deletions

View File

@ -32,6 +32,9 @@ this tool will refuse to work with drive paths which don't start with `/dev/disk
After the installation is done you can either boot from it immediately or use `arch-chroot` to After the installation is done you can either boot from it immediately or use `arch-chroot` to
perform further customizations before your first boot. perform further customizations before your first boot.
### Flags
* `-p / --extra-packages` - Specify extra packages to install. For example: `-p htop tmux`
## What exactly does it do? ## What exactly does it do?
This tool doesn't aspire to be a generic installer for Arch Linux. Instead, it does the minimum This tool doesn't aspire to be a generic installer for Arch Linux. Instead, it does the minimum

View File

@ -37,12 +37,23 @@ HOOKS=(base udev block filesystems keyboard fsck)";
enum App { enum App {
#[structopt(name = "create", about = "Create a new Arch Linux USB")] #[structopt(name = "create", about = "Create a new Arch Linux USB")]
Create { Create {
#[structopt(parse(from_os_str))] #[structopt(
parse(from_os_str),
help = "Path starting with /dev/disk/by-id for the USB drive"
)]
disk: PathBuf, disk: PathBuf,
#[structopt(
short = "p",
long = "extra-packages",
value_name = "package",
help = "Additional pacakges to install"
)]
extra_packages: Vec<String>,
}, },
} }
fn create(disk: PathBuf) -> Result<(), Error> { fn create(disk: PathBuf, extra_packages: Vec<String>) -> Result<(), Error> {
let sgdisk = Tool::find("sgdisk")?; let sgdisk = Tool::find("sgdisk")?;
let sync = Tool::find("sync")?; let sync = Tool::find("sync")?;
let pacstrap = Tool::find("pacstrap")?; let pacstrap = Tool::find("pacstrap")?;
@ -125,7 +136,8 @@ fn create(disk: PathBuf) -> Result<(), Error> {
"networkmanager", "networkmanager",
"btrfs-progs", "btrfs-progs",
"broadcom-wl", "broadcom-wl",
]).run(ErrorKind::Pacstrap)?; ]).args(extra_packages)
.run(ErrorKind::Pacstrap)?;
let fstab = genfstab let fstab = genfstab
.execute() .execute()
@ -189,7 +201,10 @@ fn main() {
} }
let result = match app { let result = match app {
App::Create { disk } => create(disk), App::Create {
disk,
extra_packages,
} => create(disk, extra_packages),
}; };
match result { match result {