From 3ed763b88422d01ca0ad8a7d016a800213bc6ed6 Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+thecatcore@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:29:20 +0100 Subject: [PATCH] Fix system updates for Nobara (#661) * Fix system updates for Nobara * fmt * Add os-release test for Nobara * Make requested changes * cargo fmt --- src/steps/os/linux.rs | 44 +++++++++++++++++++++++++++++++++- src/steps/os/os_release/nobara | 23 ++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/steps/os/os_release/nobara diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index f6142db4..d6662e59 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -39,6 +39,7 @@ pub enum Distribution { Exherbo, NixOS, KDENeon, + Nobara, } impl Distribution { @@ -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") @@ -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, @@ -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), } } @@ -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); @@ -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); + } } diff --git a/src/steps/os/os_release/nobara b/src/steps/os/os_release/nobara new file mode 100644 index 00000000..7fc2ca68 --- /dev/null +++ b/src/steps/os/os_release/nobara @@ -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