Apt arguments (fix #669)
This commit is contained in:
@@ -160,6 +160,7 @@ pub struct Linux {
|
||||
yay_arguments: Option<String>,
|
||||
trizen_arguments: Option<String>,
|
||||
dnf_arguments: Option<String>,
|
||||
apt_arguments: Option<String>,
|
||||
enable_tlmgr: Option<bool>,
|
||||
redhat_distro_sync: Option<bool>,
|
||||
emerge_sync_flags: Option<String>,
|
||||
@@ -608,7 +609,16 @@ impl Config {
|
||||
.unwrap_or("--devel")
|
||||
}
|
||||
|
||||
/// Extra yay arguments
|
||||
/// Extra apt arguments
|
||||
#[allow(dead_code)]
|
||||
pub fn apt_arguments(&self) -> Option<&str> {
|
||||
self.config_file
|
||||
.linux
|
||||
.as_ref()
|
||||
.and_then(|linux| linux.apt_arguments.as_deref())
|
||||
}
|
||||
|
||||
/// Extra dnf arguments
|
||||
#[allow(dead_code)]
|
||||
pub fn dnf_arguments(&self) -> Option<&str> {
|
||||
self.config_file
|
||||
|
||||
@@ -88,14 +88,13 @@ impl Distribution {
|
||||
print_separator("System update");
|
||||
let sudo = ctx.sudo();
|
||||
let run_type = ctx.run_type();
|
||||
let yes = ctx.config().yes();
|
||||
let cleanup = ctx.config().cleanup();
|
||||
|
||||
match self {
|
||||
Distribution::Arch => upgrade_arch_linux(ctx),
|
||||
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx),
|
||||
Distribution::ClearLinux => upgrade_clearlinux(&sudo, run_type),
|
||||
Distribution::Debian => upgrade_debian(&sudo, cleanup, run_type, yes),
|
||||
Distribution::Debian => upgrade_debian(ctx),
|
||||
Distribution::Gentoo => upgrade_gentoo(ctx),
|
||||
Distribution::Suse => upgrade_suse(&sudo, run_type),
|
||||
Distribution::Void => upgrade_void(&sudo, run_type),
|
||||
@@ -352,24 +351,27 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn upgrade_debian(sudo: &Option<PathBuf>, cleanup: bool, run_type: RunType, yes: bool) -> Result<()> {
|
||||
if let Some(sudo) = &sudo {
|
||||
fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
let apt = which("apt-fast").unwrap_or_else(|| PathBuf::from("/usr/bin/apt-get"));
|
||||
run_type.execute(&sudo).arg(&apt).arg("update").check_run()?;
|
||||
ctx.run_type().execute(&sudo).arg(&apt).arg("update").check_run()?;
|
||||
|
||||
let mut command = run_type.execute(&sudo);
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
command.arg(&apt).arg("dist-upgrade");
|
||||
if yes {
|
||||
if ctx.config().yes() {
|
||||
command.arg("-y");
|
||||
}
|
||||
if let Some(args) = ctx.config().apt_arguments() {
|
||||
command.args(args.split_whitespace());
|
||||
}
|
||||
command.check_run()?;
|
||||
|
||||
if cleanup {
|
||||
run_type.execute(&sudo).arg(&apt).arg("clean").check_run()?;
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&sudo).arg(&apt).arg("clean").check_run()?;
|
||||
|
||||
let mut command = run_type.execute(&sudo);
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
command.arg(&apt).arg("autoremove");
|
||||
if yes {
|
||||
if ctx.config().yes() {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.check_run()?;
|
||||
|
||||
Reference in New Issue
Block a user