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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
use serde::{Serialize, Deserialize}; #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub enum PackageType { app, lib, driver, daemon, kernel, plugin, runtime, emulator, compiler, bootloader, firmware, media, } pub const DEFAULT_PACKAGE_TYPE: PackageType = PackageType::app; #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub enum ReleaseType { dev, release, } pub const DEFAULT_RELEASE_TYPE: ReleaseType = ReleaseType::dev; #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub enum Architecture { amd64, i386, armhf, spark, any, } pub const DEFAULT_ARCH: Architecture = Architecture::any; #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] /// Software license used for a package. /// See https://spdx.org/licenses/ For the complete list of commonly found /// free and open source licenses. pub enum License { gpl2, gpl3, mit, bsd2, bsd3, proprietary, unknown, } pub const DEFAULT_LICENSE: License = License::gpl2; #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] /// Generic representation of a build manifest. pub struct AbstractManifest { pub package_name: String, pub package_id: String, pub package_version: String, pub short_description: String, pub description: String, pub keywords: Vec<String>, pub package_type: PackageType, pub release_type: ReleaseType, pub architecture: Architecture, pub license: License, // The main module that this manifest is installing. pub main_module: AbstractModule, // The modules that the module being built requires. pub depends_on: Vec<AbstractModule>, pub permissions: Vec<AbstractPermission>, pub executables: Vec<AbstractExecutable>, } impl Default for AbstractManifest { fn default() -> Self { AbstractManifest { package_name: String::from(""), package_id: "".to_string(), package_version: "".to_string(), short_description: "".to_string(), description: "".to_string(), keywords: vec![], package_type: DEFAULT_PACKAGE_TYPE, release_type: DEFAULT_RELEASE_TYPE, architecture: DEFAULT_ARCH, license: DEFAULT_LICENSE, main_module: AbstractModule::default(), depends_on: vec![], permissions: vec![], executables: vec![], } } } // We implement the Iterator Trait to offer a convenient // way to travers the package tree recursively. impl Iterator for AbstractManifest { type Item = AbstractModule; fn next(&mut self) -> Option<AbstractModule> { return None; //Some(self.curr); } } impl AbstractManifest { fn dump(&self) -> String { return serde_json::to_string(&self).unwrap_or(String::from("")); } fn parse(content: &str) -> AbstractManifest { return AbstractManifest::default(); } } pub enum NetTool { // https://github.com/curl/curl curl, // http://git.savannah.gnu.org/cgit/wget.git wget, } pub enum OS { bsd, mac, ios, linux, android, symbian, // Add RT Oses?? // Add misc Oses like calculators and PAs??? } // See https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md // and https://doc.rust-lang.org/cargo/reference/manifest.html#the-version-field pub struct SemanticVersion { pub major: i32, pub minor: i32, pub patch: i32, } // Also called distribution. pub struct OSVersion { pub os: OS, pub is_distribution: bool, // pub name: String, // pub codename: String, } const jessie: OSVersion = OSVersion { os: OS::linux, is_distribution: true, // name: String::from("jessie"), // codename: String::from("stretch"), }; // TODO Should we allow those systems to be available // when the generated manifest will be used? We could // consider optionally downloading those dependencies // to ensure the version of the build system... #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub enum BuildSystem { make, cmake, autotools, meson, cargo, maven, xcode, npm, // if ever http://git.savannah.gnu.org/cgit/bash.git // git@github.com:bminor/bash.git bash, pip, pip3, // if ever git@github.com:PowerShell/PowerShell.git // powershell, manual, // if ever git@github.com:apple/swift.git. swift, native, // perl ?? // ruby ?? // simple? // haskell?? // LaTeX?? // mono?? unknown, } pub const DEFAULT_BUILD_SYSTEM: BuildSystem = BuildSystem::unknown; impl Default for BuildSystem { fn default() -> Self { DEFAULT_BUILD_SYSTEM } } #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub enum SourceType { bzr, deb, git, hg, local, mercurial, rpm, subversion, svn, tar, zip, // 7z sevenzip, unknown, } pub const DEFAULT_SOURCE_TYPE: SourceType = SourceType::unknown; impl Default for SourceType { fn default() -> Self { DEFAULT_SOURCE_TYPE } } #[derive(Default)] #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] /// Generic representation of a software module. pub struct AbstractModule { pub name: String, pub version: String, pub url: String, pub url_type: SourceType, pub build_system: BuildSystem, pub install_instructions: String, pub install_path: String, // The tag associated with the module, if any. pub tag: String, // The hash of the commit associated with the module, if any. pub commit: String, // The sha256 checksum of the modules. pub sha256: String, pub config_options: String, // Array of files and directories to cleanup after installing. pub cleanup_files: Vec<String>, pub depends_on: Vec<AbstractModule>, } #[derive(Default)] #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub struct AbstractExecutable { pub name: String, pub path: String, pub is_desktop: bool, pub is_daemon: bool, // Whether or not this is the primary executable of the bundle. pub is_primary: bool, pub icon_path: String, } #[derive(Default)] #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub struct AbstractPermission { pub name: String, pub description: String, pub api_type: APIType, } #[derive(Debug)] #[derive(Serialize)] #[derive(Deserialize)] pub enum APIType { dbus, files, socket, camera, mic, gps, unknown, } impl Default for APIType { fn default() -> Self { APIType::unknown } } // Currently the documentation comes from the Debian control file documentation. pub enum Priority { // Packages which are necessary for the proper functioning of the system (usually, this means that dpkg functionality depends on these packages). // Removing a required package may cause your system to become totally broken and you may not even be able to use dpkg to put things back, // so only do so if you know what you are doing. // // Systems with only the required packages installed have at least enough functionality for the sysadmin to boot the system and install more software. required, // Important programs, including those which one would expect to find on any Unix-like system. // If the expectation is that an experienced Unix person who found it missing would say “What on earth is going on, where is foo?”, // it must be an important package. 6 Other packages without which the system will not run well or be usable must also have priority important. // This does not include Emacs, the X Window System, TeX or any other large applications. // The important packages are just a bare minimum of commonly-expected and necessary tools. important, // These packages provide a reasonably small but not too limited character-mode system. // This is what will be installed by default if the user doesn’t select anything else. // It doesn’t include many large applications. // // No two packages that both have a priority of standard or higher may conflict with each other. standard, // This is the default priority for the majority of the archive. // Unless a package should be installed by default on standard Debian systems, // it should have a priority of optional. Packages with a priority of optional may conflict with each other. optional, // This priority is deprecated. Use the optional priority instead. // This priority should be treated as equivalent to optional. // // The extra priority was previously used for packages that conflicted with other packages and packages // that were only likely to be useful to people with specialized requirements. However, this distinction // was somewhat arbitrary, not consistently followed, and not useful enough to warrant the maintenance effort. extra, }