From 9cf9d469f644c43ee2c2d9ca3b16e669c2def944 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Tue, 4 Apr 2023 22:02:58 -0400 Subject: [PATCH] Add `any` arch; Add `archive_name` method for `Package`; Ensure architecture matches when checking if a package is an upgrade; --- src/package/arch.rs | 3 +++ src/package/mod.rs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/package/arch.rs b/src/package/arch.rs index e453f27..5f10d1f 100644 --- a/src/package/arch.rs +++ b/src/package/arch.rs @@ -22,6 +22,7 @@ pub enum Arch { i686, riscv64, x86_64, + any, } impl Default for Arch { @@ -40,6 +41,7 @@ impl fmt::Display for Arch { Self::i686 => "i686", Self::riscv64 => "riscv64", Self::x86_64 => "x86_64", + Self::any => "any", }) } } @@ -66,6 +68,7 @@ impl FromStr for Arch { "armv7l" | "arm" => Ok(Self::armv7l), "arm64" | "aarch64" | "armv8" => Ok(Self::aarch64), "riscv" | "riscv64" => Ok(Self::riscv64), + "any" => Ok(Self::any), _ => Err(ParseArchError) } } diff --git a/src/package/mod.rs b/src/package/mod.rs index 06e5ae3..ffe2a7d 100644 --- a/src/package/mod.rs +++ b/src/package/mod.rs @@ -113,12 +113,18 @@ impl Package { /// Returns the formatted full package name including version and release strings pub fn fullname(&self) -> String { - format!("{}-{}_{}{}", self.name, self.version, self.arch, self.release) + format!("{}-{}_{}_{}", self.name, self.version, self.release, self.arch) + } + + /// Returns the name of the package archive + pub fn archive_name(&self) -> String { + format!("{}-{}_{}_{}.tar.zstd", self.name, self.version, self.release, self.arch) } /// Tests whether this package is an update for another pub fn is_upgrade(&self, other: &Self) -> bool { - self.name == other.name + self.arch == other.arch + && self.name == other.name && (self.version > other.version || (self.version == other.version && self.release > other.release)) }