Skip to content

Commit

Permalink
Fix system updates for Nobara (#661)
Browse files Browse the repository at this point in the history
* Fix system updates for Nobara

* fmt

* Add os-release test for Nobara

* Make requested changes

* cargo fmt
  • Loading branch information
thecatcore authored Jan 24, 2024
1 parent 10e1e17 commit 3ed763b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
44 changes: 43 additions & 1 deletion src/steps/os/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum Distribution {
Exherbo,
NixOS,
KDENeon,
Nobara,
}

impl Distribution {
Expand All @@ -53,7 +54,7 @@ impl Distribution {
Some("alpine") => Distribution::Alpine,
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
Some("clear-linux-os") => Distribution::ClearLinux,
Some("fedora") | Some("nobara") => {
Some("fedora") => {
return if let Some(variant) = variant {
if variant.contains(&"Silverblue")
|| variant.contains(&"Kinoite")
Expand All @@ -69,6 +70,7 @@ impl Distribution {
};
}

Some("nobara") => Distribution::Nobara,
Some("void") => Distribution::Void,
Some("debian") | Some("pureos") | Some("Deepin") => Distribution::Debian,
Some("arch") | Some("manjaro-arm") | Some("garuda") | Some("artix") => Distribution::Arch,
Expand Down Expand Up @@ -152,6 +154,7 @@ impl Distribution {
Distribution::Bedrock => update_bedrock(ctx),
Distribution::OpenMandriva => upgrade_openmandriva(ctx),
Distribution::PCLinuxOS => upgrade_pclinuxos(ctx),
Distribution::Nobara => upgrade_nobara(ctx),
}
}

Expand Down Expand Up @@ -229,6 +232,40 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
Ok(())
}

fn upgrade_nobara(ctx: &ExecutionContext) -> Result<()> {
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
let pkg_manager = require("dnf")?;

let mut update_command = ctx.run_type().execute(sudo);
update_command.arg(&pkg_manager);

if ctx.config().yes(Step::System) {
update_command.arg("-y");
}

update_command.arg("update");
// See https://nobaraproject.org/docs/upgrade-troubleshooting/how-do-i-update-the-system/
update_command.args([
"rpmfusion-nonfree-release",
"rpmfusion-free-release",
"fedora-repos",
"nobara-repos",
]);
update_command.arg("--refresh").status_checked()?;

let mut upgrade_command = ctx.run_type().execute(sudo);
upgrade_command.arg(&pkg_manager);

if ctx.config().yes(Step::System) {
upgrade_command.arg("-y");
}

upgrade_command.arg("distro-sync");

upgrade_command.status_checked()?;
Ok(())
}

fn upgrade_fedora_immutable(ctx: &ExecutionContext) -> Result<()> {
let ostree = require("rpm-ostree")?;
let mut command = ctx.run_type().execute(ostree);
Expand Down Expand Up @@ -1115,4 +1152,9 @@ mod tests {
fn test_solus() {
test_template(include_str!("os_release/solus"), Distribution::Solus);
}

#[test]
fn test_nobara() {
test_template(include_str!("os_release/nobara"), Distribution::Nobara);
}
}
23 changes: 23 additions & 0 deletions src/steps/os/os_release/nobara
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
NAME="Nobara Linux"
VERSION="39 (GNOME Edition)"
ID=nobara
ID_LIKE="rhel centos fedora"
VERSION_ID=39
VERSION_CODENAME=""
PLATFORM_ID="platform:f39"
PRETTY_NAME="Nobara Linux 39 (GNOME Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=nobara-logo-icon
CPE_NAME="cpe:/o:nobaraproject:nobara:39"
DEFAULT_HOSTNAME="nobara"
HOME_URL="https://nobaraproject.org/"
DOCUMENTATION_URL="https://www.nobaraproject.org/"
SUPPORT_URL="https://www.nobaraproject.org/"
BUG_REPORT_URL="https://gitlab.com/gloriouseggroll/nobara-images"
REDHAT_BUGZILLA_PRODUCT="Nobara"
REDHAT_BUGZILLA_PRODUCT_VERSION=39
REDHAT_SUPPORT_PRODUCT="Nobara"
REDHAT_SUPPORT_PRODUCT_VERSION=39
SUPPORT_END=2024-05-14
VARIANT="GNOME Edition"
VARIANT_ID=gnome

0 comments on commit 3ed763b

Please sign in to comment.