diff --git a/src/args.rs b/src/args.rs index 3d1e667..8a78826 100644 --- a/src/args.rs +++ b/src/args.rs @@ -13,6 +13,10 @@ pub struct Args { /// Complete operation without prompting user #[clap(long = "noconfirm", global = true)] pub no_confirm: bool, + + /// Loops sudo in the background to ensure it doesn't time out during long builds + #[clap(long = "sudoloop")] + pub sudoloop: bool, } #[derive(Debug, Clone, Subcommand)] @@ -80,10 +84,10 @@ pub struct SearchArgs { #[derive(Default, Debug, Clone, Parser)] pub struct QueryArgs { /// Lists AUR/foreign packages - #[clap(long, short)] + #[clap(long, short, from_global)] pub aur: bool, /// Lists repo/native packages - #[clap(long, short)] + #[clap(long, short, from_global)] pub repo: bool, } diff --git a/src/internal/commands.rs b/src/internal/commands.rs index 660e314..f2df391 100644 --- a/src/internal/commands.rs +++ b/src/internal/commands.rs @@ -45,6 +45,10 @@ impl ShellCommand { Self::new("bash") } + pub fn sudo() -> Self { + Self::new("sudo") + } + fn new(command: S) -> Self { Self { command: command.to_string(), diff --git a/src/internal/mod.rs b/src/internal/mod.rs index 914d54e..87befd6 100644 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -15,6 +15,12 @@ mod sort; pub mod structs; #[macro_use] pub(crate) mod utils; +mod sudoloop; + +pub use clean::*; +pub use initialise::*; +pub use sort::*; +pub use sudoloop::*; #[macro_export] macro_rules! uwu { diff --git a/src/internal/sudoloop.rs b/src/internal/sudoloop.rs new file mode 100644 index 0000000..a4f6b3a --- /dev/null +++ b/src/internal/sudoloop.rs @@ -0,0 +1,16 @@ +use crate::ShellCommand; +use std::thread; +use std::time::Duration; + +/// Loop sudo so it doesn't time out +pub fn start_sudoloop() { + prompt_sudo(); + std::thread::spawn(|| loop { + prompt_sudo(); + thread::sleep(Duration::from_secs(3 * 60)) + }); +} + +fn prompt_sudo() { + while ShellCommand::sudo().arg("-v").wait_success().is_err() {} +} diff --git a/src/main.rs b/src/main.rs index 459a5e3..ee61b35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use internal::error::SilentUnwrap; use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs}; use crate::internal::detect; use crate::internal::exit_code::AppExitCode; -use crate::internal::{init, sort, structs::Options}; +use crate::internal::{init, sort, start_sudoloop, structs::Options}; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; @@ -34,6 +34,10 @@ fn main() { init(options); + if args.sudoloop { + start_sudoloop(); + } + match args.subcommand.unwrap_or_default() { Operation::Install(install_args) => cmd_install(install_args, options), Operation::Remove(remove_args) => cmd_remove(remove_args, options), diff --git a/src/operations/aur_install.rs b/src/operations/aur_install.rs index dfe3714..065f443 100644 --- a/src/operations/aur_install.rs +++ b/src/operations/aur_install.rs @@ -137,7 +137,7 @@ pub fn aur_install(a: Vec, options: Options) { crate::operations::aur_install(md_sorted.aur, newopts); } - let mut makepkg_args = vec!["-rsic", "--skippgp"]; + let mut makepkg_args = vec!["-rsci", "--skippgp"]; if options.asdeps { makepkg_args.push("--asdeps") }