feat: Add support for Wolfi (#672)
* feat: Add support for Wolfi This adds support for updating Wolfi via Topgrade * chore(wolfi): Add os release info and unit test * chore(wolfi): Don't check ID_LIKE as it is unique
This commit is contained in:
@@ -20,6 +20,7 @@ static OS_RELEASE_PATH: &str = "/etc/os-release";
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Distribution {
|
||||
Alpine,
|
||||
Wolfi,
|
||||
Arch,
|
||||
Bedrock,
|
||||
CentOS,
|
||||
@@ -52,6 +53,7 @@ impl Distribution {
|
||||
|
||||
Ok(match id {
|
||||
Some("alpine") => Distribution::Alpine,
|
||||
Some("wolfi") => Distribution::Wolfi,
|
||||
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
|
||||
Some("clear-linux-os") => Distribution::ClearLinux,
|
||||
Some("fedora") => {
|
||||
@@ -136,6 +138,7 @@ impl Distribution {
|
||||
|
||||
match self {
|
||||
Distribution::Alpine => upgrade_alpine_linux(ctx),
|
||||
Distribution::Wolfi => upgrade_wolfi_linux(ctx),
|
||||
Distribution::Arch => archlinux::upgrade_arch_linux(ctx),
|
||||
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx),
|
||||
Distribution::FedoraImmutable => upgrade_fedora_immutable(ctx),
|
||||
@@ -201,6 +204,14 @@ fn upgrade_alpine_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
fn upgrade_wolfi_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
let apk = require("apk")?;
|
||||
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
||||
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(ostree) = which("rpm-ostree") {
|
||||
if ctx.config().rpm_ostree() {
|
||||
@@ -1021,6 +1032,11 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_wolfi() {
|
||||
test_template(include_str!("os_release/wolfi"), Distribution::Wolfi);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_arch_linux() {
|
||||
test_template(include_str!("os_release/arch"), Distribution::Arch);
|
||||
|
||||
5
src/steps/os/os_release/wolfi
Normal file
5
src/steps/os/os_release/wolfi
Normal file
@@ -0,0 +1,5 @@
|
||||
ID=wolfi
|
||||
NAME="Wolfi"
|
||||
PRETTY_NAME="Wolfi"
|
||||
VERSION_ID="20230201"
|
||||
HOME_URL="https://wolfi.dev"
|
||||
Reference in New Issue
Block a user