From 0ab84def2e5e7ac6253c6b5f1ac20ecbf0fe70f8 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Fri, 7 Apr 2023 19:08:23 -0400 Subject: [PATCH] Make `package::User` and `package::Group` public --- src/lib.rs | 7 +++---- src/package/arch.rs | 30 +++++++++++++++++------------- src/package/mod.rs | 17 ++++++++++------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a8b28de..3381f56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,12 @@ -pub mod tar; mod package; mod plist; +pub mod tar; mod version; pub use { deku, - package::{Arch, Dependency, Package, Specs}, + package::{Arch, Dependency, Package, Specs, User, Group}, plist::*, - ron, - sha2, + ron, sha2, version::*, }; diff --git a/src/package/arch.rs b/src/package/arch.rs index 5f10d1f..59f1c01 100644 --- a/src/package/arch.rs +++ b/src/package/arch.rs @@ -1,10 +1,10 @@ use serde::{Deserialize, Serialize}; -use std::{fmt, str::FromStr, error::Error}; +use std::{error::Error, fmt, str::FromStr}; #[cfg(target_arch = "arm")] pub const HOST_ARCH: Arch = Arch::armv7l; #[cfg(target_arch = "aarch64")] -pub const HOST_ARCH: Arch = Arch::aarch64; +pub const HOST_ARCH: Arch = Arch::aarch64; #[cfg(target_arch = "x86")] pub const HOST_ARCH: Arch = Arch::i486; #[cfg(target_arch = "riscv64")] @@ -33,16 +33,20 @@ impl Default for Arch { impl fmt::Display for Arch { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", match self { - Self::armv7l => "armv7l", - Self::aarch64 => "aarch64", - Self::i486 => "i486", - Self::i586 => "i586", - Self::i686 => "i686", - Self::riscv64 => "riscv64", - Self::x86_64 => "x86_64", - Self::any => "any", - }) + write!( + f, + "{}", + match self { + Self::armv7l => "armv7l", + Self::aarch64 => "aarch64", + Self::i486 => "i486", + Self::i586 => "i586", + Self::i686 => "i686", + Self::riscv64 => "riscv64", + Self::x86_64 => "x86_64", + Self::any => "any", + } + ) } } @@ -69,7 +73,7 @@ impl FromStr for Arch { "arm64" | "aarch64" | "armv8" => Ok(Self::aarch64), "riscv" | "riscv64" => Ok(Self::riscv64), "any" => Ok(Self::any), - _ => Err(ParseArchError) + _ => Err(ParseArchError), } } } diff --git a/src/package/mod.rs b/src/package/mod.rs index ffe2a7d..0020cd9 100644 --- a/src/package/mod.rs +++ b/src/package/mod.rs @@ -3,6 +3,7 @@ mod dependency; mod specs; use { + crate::tar::{Node, Owner}, crate::{Plist, Version}, ron::ser::{to_string_pretty, PrettyConfig}, serde::{Deserialize, Serialize}, @@ -13,7 +14,6 @@ use { io::{BufWriter, Write}, path::Path, }, - crate::tar::{Node, Owner}, }; pub use {arch::Arch, dependency::Dependency, specs::Specs}; @@ -88,10 +88,7 @@ impl Package { to_string_pretty(self, cfg) } - pub fn save_ron_and_create_tar_node( - &self, - outdir: &Path, - ) -> Result> { + pub fn save_ron_and_create_tar_node(&self, outdir: &Path) -> Result> { if !outdir.exists() { fs::create_dir_all(outdir)?; } @@ -113,12 +110,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.release, self.arch) + 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) + format!( + "{}-{}_{}_{}.tar.zstd", + self.name, self.version, self.release, self.arch + ) } /// Tests whether this package is an update for another