From a07166375a22e5c76f610887b5c731036ed3b491 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Thu, 6 Apr 2023 18:47:53 -0400 Subject: [PATCH] Add `Arch` to `Update` struct --- Cargo.lock | 10 +++++----- src/db/mod.rs | 13 +++++++++---- src/lib.rs | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea4cbec..c2c2e7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -392,7 +392,7 @@ dependencies = [ [[package]] name = "hpk-package" version = "0.1.0" -source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk-package.git#9cf9d469f644c43ee2c2d9ca3b16e669c2def944" +source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk-package.git#723d697e9085a575c1f6d59baf1e79819452d747" dependencies = [ "chrono", "deku", @@ -1263,9 +1263,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.4+zstd.1.5.4" +version = "6.0.5+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7afb4b54b8910cf5447638cb54bf4e8a65cbedd783af98b98c62ffe91f185543" +checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" dependencies = [ "libc", "zstd-sys", @@ -1273,9 +1273,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.7+zstd.1.5.4" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", diff --git a/src/db/mod.rs b/src/db/mod.rs index fc33e1b..000e080 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -1,5 +1,5 @@ use { - crate::{Package, Repository, Version}, + crate::{Arch, Package, Repository, Version}, hpk_package::ron::{self, ser::PrettyConfig}, rayon::prelude::*, serde::{Deserialize, Serialize}, @@ -19,13 +19,14 @@ use { pub struct Update { pub name: String, pub version: Version, + pub arch: Arch, pub release: u8, pub url: Url, } impl fmt::Display for Update { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}-{}_{}", self.name, self.version, self.release) + write!(f, "{}-{}_{}_{}", self.name, self.version, self.arch, self.release) } } @@ -77,6 +78,7 @@ impl Database { let update = Update { name: key.to_string(), version: remote_package.version.clone(), + arch: remote_package.arch, release: remote_package.release, url: repo.base_url.clone(), }; @@ -87,6 +89,7 @@ impl Database { // into our hashmap let update = Update { name: key.to_string(), + arch: remote_package.arch, version: remote_package.version.clone(), release: remote_package.release, url: repo.base_url.clone(), @@ -144,11 +147,12 @@ mod test { let up = Update { name: "hpk".to_string(), version: Version::Number(42), + arch: Arch::aarch64, release: 1, url: Url::parse("https://hitchhiker-linux.org/pub/packages/").unwrap(), } .to_string(); - assert_eq!("hpk-42_1".to_string(), up); + assert_eq!("hpk-42_aarch64_1".to_string(), up); } #[test] @@ -156,12 +160,13 @@ mod test { let up = Update { name: "hpk".to_string(), version: Version::Number(42), + arch: Arch::aarch64, release: 1, url: Url::parse("https://hitchhiker-linux.org/pub/packages/").unwrap(), }; let full_url = up.full_url().unwrap().to_string(); assert_eq!( - "https://hitchhiker-linux.org/pub/packages/hpk-42_1.tar.zstd".to_string(), + "https://hitchhiker-linux.org/pub/packages/hpk-42_aarch64_1.tar.zstd".to_string(), full_url ); } diff --git a/src/lib.rs b/src/lib.rs index 9fae73f..b08bd4b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ pub use { creator::{Creator, Message}, db::Database, hooks::Hooks, - hpk_package::{tar, Dependency, GitRev, Package, Plist, Rapid, SemVer, Specs, Version}, + hpk_package::{tar, Arch, Dependency, GitRev, Package, Plist, Rapid, SemVer, Specs, Version}, item::Item, repository::Repository, };