makes rpm-ostree configurable (#712)
This commit makes it possible to *not* to use `rpm-ostree` even on systems where it is detected. This commit is fully backwards compatible with previous releases, and without changing the config file all previous behaviors are the exact same. This commit adds the `rpm_ostree` field in the `[linux]` table of the configuration, and defaults to `true`. This means Topgrade will first check if `/usr/bin/rpm-ostree` exists, and only if so then check if the user does not want to use `rpm-ostree` via the configuration. If the user *does not* want to use `rpm-ostree`, then normal operation continues checking for DNF or YUM. This makes it possible for people where `rpm-ostree` is installed, but where the system is not an `ostree` based distribtuion. This happens when people are using things like `osbuild-composer` to build images, or Cockpit with the Compose feature enabled (which uses `osbuild-composer` internally). An alternative to this commit would be to make the config field a negative such as `no_rpm_ostree`, however that goes against the norm in other fields. Closes #710
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
#emerge_sync_flags = "-q"
|
||||
#emerge_update_flags = "-uDNa --with-bdeps=y world"
|
||||
#redhat_distro_sync = false
|
||||
#rpm_ostree = false
|
||||
|
||||
[windows]
|
||||
# Manually select Windows updates
|
||||
|
||||
@@ -159,6 +159,7 @@ pub struct Linux {
|
||||
apt_arguments: Option<String>,
|
||||
enable_tlmgr: Option<bool>,
|
||||
redhat_distro_sync: Option<bool>,
|
||||
rpm_ostree: Option<bool>,
|
||||
emerge_sync_flags: Option<String>,
|
||||
emerge_update_flags: Option<String>,
|
||||
}
|
||||
@@ -669,6 +670,16 @@ impl Config {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Use rpm-ostree in *when rpm-ostree is detected* (default: true)
|
||||
#[allow(dead_code)]
|
||||
pub fn rpm_ostree(&self) -> bool {
|
||||
self.config_file
|
||||
.linux
|
||||
.as_ref()
|
||||
.and_then(|linux| linux.rpm_ostree)
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
/// Should we ignore failures for this step
|
||||
pub fn ignore_failure(&self, step: Step) -> bool {
|
||||
self.config_file
|
||||
|
||||
@@ -237,15 +237,17 @@ fn upgrade_arch_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(ostree) = Path::new("/usr/bin/rpm-ostree").if_exists() {
|
||||
let mut command = ctx.run_type().execute(ostree);
|
||||
command.arg("upgrade");
|
||||
if ctx.config().yes() {
|
||||
command.arg("-y");
|
||||
}
|
||||
let _ = if let Some(ostree) = Path::new("/usr/bin/rpm-ostree").if_exists() {
|
||||
if ctx.config().rpm_ostree() {
|
||||
let mut command = ctx.run_type().execute(ostree);
|
||||
command.arg("upgrade");
|
||||
if ctx.config().yes() {
|
||||
command.arg("-y");
|
||||
}
|
||||
|
||||
return command.check_run();
|
||||
}
|
||||
return command.check_run();
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
let mut command = ctx.run_type().execute(&sudo);
|
||||
|
||||
Reference in New Issue
Block a user