Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Add -p and -i (fix #2 fix #11)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish committed Nov 4, 2018
1 parent a76b6af commit e956dc5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub enum ErrorKind {

#[fail(display = "Error calling sync")]
Sync,

#[fail(display = "Error caused by the interactive mode")]
Interactive,
}

impl Fail for Error {
Expand Down
31 changes: 19 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,21 @@ SystemMaxUse=16M
enum App {
#[structopt(name = "create", about = "Create a new Arch Linux USB")]
Create {
#[structopt(
parse(from_os_str),
help = "Path starting with /dev/disk/by-id for the USB drive"
)]
/// Path starting with /dev/disk/by-id for the USB drive
#[structopt(parse(from_os_str),)]
disk: PathBuf,

#[structopt(
short = "p",
long = "extra-packages",
value_name = "package",
help = "Additional pacakges to install"
)]
/// Additional pacakges to install
#[structopt(short = "p", long = "extra-packages", value_name = "package",)]
extra_packages: Vec<String>,

/// Enter interactive chroot before unmounting the drive
#[structopt(short = "i", long = "interactive")]
interactive: bool,
},
}

fn create(disk: PathBuf, extra_packages: Vec<String>) -> Result<(), Error> {
fn create(disk: PathBuf, extra_packages: Vec<String>, interactive: bool) -> Result<(), Error> {
let sgdisk = Tool::find("sgdisk")?;
let sync = Tool::find("sync")?;
let pacstrap = Tool::find("pacstrap")?;
Expand Down Expand Up @@ -183,6 +181,14 @@ fn create(disk: PathBuf, extra_packages: Vec<String>) -> Result<(), Error> {
.arg(format!("grub-install --target=i386-pc --boot-directory /boot {} && grub-install --target=x86_64-efi --efi-directory /boot --boot-directory /boot --removable && grub-mkconfig -o /boot/grub/grub.cfg", disk.display()))
.run(ErrorKind::Bootloader)?;

if interactive {
info!("Dropping you to chroot. Do as you wish to customize the installation");
arch_chroot
.execute()
.arg(mount_point.path())
.run(ErrorKind::Interactive)?;
}

info!("Unmounting filesystems");
drop(mount_stack);
sync.execute().run(ErrorKind::Sync)?;
Expand Down Expand Up @@ -216,7 +222,8 @@ fn main() {
App::Create {
disk,
extra_packages,
} => create(disk, extra_packages),
interactive,
} => create(disk, extra_packages, interactive),
};

match result {
Expand Down

0 comments on commit e956dc5

Please sign in to comment.