cargo_dist/backend/installer/
mod.rs1use std::collections::BTreeMap;
6
7use camino::Utf8PathBuf;
8use cargo_dist_schema::{ArtifactId, EnvironmentVariables, Hosting, TripleName};
9use homebrew::HomebrewFragments;
10use macpkg::PkgInstallerInfo;
11use serde::Serialize;
12
13use crate::{
14 config::{JinjaInstallPathStrategy, LibraryStyle, ZipStyle},
15 platform::{PlatformSupport, RuntimeConditions},
16 InstallReceipt, ReleaseIdx,
17};
18
19use self::homebrew::HomebrewInstallerInfo;
20use self::msi::MsiInstallerInfo;
21use self::npm::NpmInstallerInfo;
22
23pub mod homebrew;
24pub mod macpkg;
25pub mod msi;
26pub mod npm;
27pub mod powershell;
28pub mod shell;
29
30#[derive(Debug, Clone)]
32#[allow(clippy::large_enum_variant)]
33pub enum InstallerImpl {
34 Shell(InstallerInfo),
36 Powershell(InstallerInfo),
38 Npm(NpmInstallerInfo),
40 Homebrew(HomebrewImpl),
42 Msi(MsiInstallerInfo),
44 Pkg(PkgInstallerInfo),
46}
47
48#[derive(Debug, Clone)]
50pub struct HomebrewImpl {
51 pub info: HomebrewInstallerInfo,
53
54 pub fragments: HomebrewFragments<ExecutableZipFragment>,
56}
57
58#[derive(Debug, Clone, Serialize)]
60pub struct InstallerInfo {
61 #[serde(skip)]
63 pub release: ReleaseIdx,
64 pub dest_path: Utf8PathBuf,
66 pub app_name: String,
68 pub app_version: String,
70 pub base_urls: Vec<String>,
72 pub hosting: Hosting,
74 pub artifacts: Vec<ExecutableZipFragment>,
76 pub desc: String,
78 pub hint: String,
80 pub install_paths: Vec<JinjaInstallPathStrategy>,
82 pub install_success_msg: String,
84 pub receipt: Option<InstallReceipt>,
86 pub bin_aliases: BTreeMap<TripleName, BTreeMap<String, Vec<String>>>,
88 pub install_libraries: Vec<LibraryStyle>,
90 pub runtime_conditions: RuntimeConditions,
92 pub platform_support: Option<PlatformSupport>,
94 pub env_vars: Option<EnvironmentVariables>,
96}
97
98#[derive(Debug, Clone, Serialize)]
100pub struct ExecutableZipFragment {
101 pub id: ArtifactId,
103 pub target_triple: TripleName,
105 pub executables: Vec<String>,
107 pub cdylibs: Vec<String>,
109 pub cstaticlibs: Vec<String>,
111 pub zip_style: ZipStyle,
113 pub updater: Option<UpdaterFragment>,
115 pub runtime_conditions: RuntimeConditions,
117}
118
119#[derive(Debug, Clone, Serialize)]
121pub struct UpdaterFragment {
122 pub id: ArtifactId,
124 pub binary: ArtifactId,
126}