Merge remote-tracking branch 'origin-tar-black/feature/sudoloop'

Signed-off-by: trivernis <trivernis@protonmail.com>
i18n
trivernis 2 years ago
commit 33a68d654a
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -13,6 +13,10 @@ pub struct Args {
/// Complete operation without prompting user /// Complete operation without prompting user
#[clap(long = "noconfirm", global = true)] #[clap(long = "noconfirm", global = true)]
pub no_confirm: bool, 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)] #[derive(Debug, Clone, Subcommand)]
@ -80,10 +84,10 @@ pub struct SearchArgs {
#[derive(Default, Debug, Clone, Parser)] #[derive(Default, Debug, Clone, Parser)]
pub struct QueryArgs { pub struct QueryArgs {
/// Lists AUR/foreign packages /// Lists AUR/foreign packages
#[clap(long, short)] #[clap(long, short, from_global)]
pub aur: bool, pub aur: bool,
/// Lists repo/native packages /// Lists repo/native packages
#[clap(long, short)] #[clap(long, short, from_global)]
pub repo: bool, pub repo: bool,
} }

@ -45,6 +45,10 @@ impl ShellCommand {
Self::new("bash") Self::new("bash")
} }
pub fn sudo() -> Self {
Self::new("sudo")
}
fn new<S: ToString>(command: S) -> Self { fn new<S: ToString>(command: S) -> Self {
Self { Self {
command: command.to_string(), command: command.to_string(),

@ -15,6 +15,12 @@ mod sort;
pub mod structs; pub mod structs;
#[macro_use] #[macro_use]
pub(crate) mod utils; pub(crate) mod utils;
mod sudoloop;
pub use clean::*;
pub use initialise::*;
pub use sort::*;
pub use sudoloop::*;
#[macro_export] #[macro_export]
macro_rules! uwu { macro_rules! uwu {

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

@ -6,7 +6,7 @@ use internal::error::SilentUnwrap;
use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs}; use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs};
use crate::internal::detect; use crate::internal::detect;
use crate::internal::exit_code::AppExitCode; use crate::internal::exit_code::AppExitCode;
use crate::internal::{init, sort, structs::Options}; use crate::internal::{init, sort, start_sudoloop, structs::Options};
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
@ -34,6 +34,10 @@ fn main() {
init(options); init(options);
if args.sudoloop {
start_sudoloop();
}
match args.subcommand.unwrap_or_default() { match args.subcommand.unwrap_or_default() {
Operation::Install(install_args) => cmd_install(install_args, options), Operation::Install(install_args) => cmd_install(install_args, options),
Operation::Remove(remove_args) => cmd_remove(remove_args, options), Operation::Remove(remove_args) => cmd_remove(remove_args, options),

@ -137,7 +137,7 @@ pub fn aur_install(a: Vec<String>, options: Options) {
crate::operations::aur_install(md_sorted.aur, newopts); 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 { if options.asdeps {
makepkg_args.push("--asdeps") makepkg_args.push("--asdeps")
} }

Loading…
Cancel
Save