1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
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<String>,
pub license: Option<String>,
pub url: String,
pub git_repo: Option<String>,
}
#[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<String>,
// Git repository URL for source code if needed
pub git_repo: Option<String>,
// pub files: Option<Vec<String>>,
}
#[allow(dead_code)]
#[derive(Deserialize, Debug, Clone)]
pub struct Install {
pub package: Package,
pub install: InstallMeta,
#[serde(default)]
pub files: Vec<String>,
}
#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Setts {
// Export environment variables if this needed
pub env: Option<String>,
// Test the package after installation
pub test: Option<String>,
}
#[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<String>,
}
#[allow(dead_code)]
#[derive(Deserialize)]
pub struct Build {
pub build_system: BuildSystems,
pub env: Option<String>,
pub script: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Index {
pub packages: Vec<Package>,
}
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())
}
}
|