use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Serialize, Debug, Deserialize, Clone, PartialEq, Default)] pub enum Archs { #[default] X86_64, Aarch64, X86, ArmV7, ArmV8, } #[derive(Serialize, Debug, Deserialize, Clone, Default)] pub struct Package { pub name: String, pub version: String, pub arch: Archs, pub descr: Option, pub license: Option, pub url: String, pub git_repo: Option, } #[derive(Deserialize, Debug, Clone)] pub struct InstallMeta { pub path: String, pub user: String, pub group: String, pub mode: String, // Cancels the previous fields and installs them using the shell script pub custom_script: Option, // Git repository URL for source code if needed pub git_repo: Option, // pub files: Option>, } #[allow(dead_code)] #[derive(Deserialize, Debug, Clone)] pub struct Install { pub package: Package, pub install: InstallMeta, #[serde(default)] pub files: Vec, } #[allow(dead_code)] #[derive(Deserialize, Debug)] pub struct Setts { // Export environment variables if this needed pub env: Option, // Test the package after installation pub test: Option, } #[derive(Deserialize, Serialize, Debug)] pub enum BuildSystems { Make, CMake, Meson, Cargo, } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct PackageManifest { pub name: String, pub version: String, pub all_files: Vec, } #[allow(dead_code)] #[derive(Deserialize)] pub struct Build { pub build_system: BuildSystems, pub env: Option, pub script: Option, } #[derive(Serialize, Deserialize, Debug)] pub struct Index { pub packages: Vec, } impl Archs { pub fn as_str(&self) -> &'static str { match self { Archs::X86_64 => "x86_64", Archs::Aarch64 => "aarch64", Archs::X86 => "x86", Archs::ArmV7 => "armv7", Archs::ArmV8 => "armv8", } } } impl fmt::Display for Archs { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.as_str()) } }