Add ability to disable package managers (fix #206)

This commit is contained in:
Roey Darwish Dror
2019-09-28 14:49:24 +03:00
parent f6b4bb00b2
commit cfce9775df
2 changed files with 49 additions and 30 deletions

View File

@@ -24,6 +24,8 @@ type Commands = BTreeMap<String, String>;
pub enum Step {
/// Don't perform system upgrade
System,
/// Don't perform upgrades of package managers
PackageManagers,
/// Don't pull git repositories
GitRepos,
/// Don't upgrade Vim packages or configuration files

View File

@@ -176,6 +176,8 @@ fn run() -> Result<(), Error> {
}
#[cfg(windows)]
{
if config.should_run(Step::PackageManagers) {
execute(
&mut report,
"Chocolatey",
@@ -183,32 +185,47 @@ fn run() -> Result<(), Error> {
config.no_retry(),
)?;
#[cfg(windows)]
execute(&mut report, "Scoop", || windows::run_scoop(run_type), config.no_retry())?;
}
}
#[cfg(unix)]
{
if config.should_run(Step::PackageManagers) {
execute(
&mut report,
"brew",
|| unix::run_homebrew(config.cleanup(), run_type),
config.no_retry(),
)?;
}
execute(&mut report, "nix", || unix::run_nix(run_type), config.no_retry())?;
}
#[cfg(target_os = "dragonfly")]
{
if config.should_run(Step::PackageManagers) {
execute(
&mut report,
"DragonFly BSD Packages",
|| dragonfly::upgrade_packages(sudo.as_ref(), run_type),
config.no_retry(),
)?;
}
}
#[cfg(target_os = "freebsd")]
{
if config.should_run(Step::PackageManagers) {
execute(
&mut report,
"FreeBSD Packages",
|| freebsd::upgrade_packages(sudo.as_ref(), run_type),
config.no_retry(),
)?;
#[cfg(unix)]
execute(&mut report, "nix", || unix::run_nix(run_type), config.no_retry())?;
}
}
let emacs = emacs::Emacs::new(&base_dirs);
if config.should_run(Step::Emacs) {
@@ -405,7 +422,7 @@ fn run() -> Result<(), Error> {
#[cfg(target_os = "linux")]
{
if config.should_run(Step::System) {
if config.should_run(Step::PackageManagers) {
execute(
&mut report,
"Flatpak",
@@ -551,7 +568,7 @@ fn run() -> Result<(), Error> {
if report.data().iter().all(|(_, succeeded)| *succeeded) {
Ok(())
} else {
Err(ErrorKind::StepFailed)?
Err(ErrorKind::StepFailed.into())
}
}