anodizer_core/config/aur_source.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use super::publishers::CommitAuthorConfig;
5use super::{StringOrBool, deserialize_string_or_bool_opt};
6
7// ---------------------------------------------------------------------------
8// AurSourceConfig
9// ---------------------------------------------------------------------------
10
11#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
12#[serde(default, deny_unknown_fields)]
13pub struct AurSourceConfig {
14 /// Override the package name (default: crate name, no -bin suffix).
15 pub name: Option<String>,
16 /// Build IDs filter.
17 pub ids: Option<Vec<String>>,
18 /// Commit author with optional signing.
19 pub commit_author: Option<CommitAuthorConfig>,
20 /// Custom commit message template.
21 pub commit_msg_template: Option<String>,
22 /// Short description of the package.
23 pub description: Option<String>,
24 /// Project homepage URL.
25 pub homepage: Option<String>,
26 /// SPDX license identifier.
27 pub license: Option<String>,
28 /// Skip publishing. `"true"` always skips; `"auto"` skips for prereleases.
29 #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
30 pub skip_upload: Option<StringOrBool>,
31 /// Custom URL template for download URLs.
32 pub url_template: Option<String>,
33 /// PKGBUILD maintainer entries.
34 pub maintainers: Option<Vec<String>>,
35 /// Contributors listed in PKGBUILD comments.
36 pub contributors: Option<Vec<String>>,
37 /// Packages this PKGBUILD provides.
38 pub provides: Option<Vec<String>>,
39 /// Packages this PKGBUILD conflicts with.
40 pub conflicts: Option<Vec<String>>,
41 /// Runtime dependencies.
42 pub depends: Option<Vec<String>>,
43 /// Optional dependencies.
44 pub optdepends: Option<Vec<String>>,
45 /// Build-time dependencies (source packages need these).
46 pub makedepends: Option<Vec<String>>,
47 /// Backup files to preserve on upgrade.
48 pub backup: Option<Vec<String>>,
49 /// Package release number (default: "1").
50 pub rel: Option<String>,
51 /// Custom `prepare()` function body for PKGBUILD.
52 pub prepare: Option<String>,
53 /// Custom `build()` function body for PKGBUILD.
54 pub build: Option<String>,
55 /// Custom `package()` function body for PKGBUILD.
56 pub package: Option<String>,
57 /// AUR SSH git URL override. Defaults to
58 /// `ssh://aur@aur.archlinux.org/<package>.git`, derived from the resolved
59 /// package name; set this only for a non-standard endpoint.
60 pub git_url: Option<String>,
61 /// Custom SSH command for git operations.
62 pub git_ssh_command: Option<String>,
63 /// Path to SSH private key file.
64 pub private_key: Option<String>,
65 /// Subdirectory in the git repo for committed files.
66 pub directory: Option<String>,
67 /// Skip this config.
68 /// Accepts the legacy `disable:` spelling via serde alias for back-compat.
69 #[serde(
70 alias = "disable",
71 deserialize_with = "deserialize_string_or_bool_opt",
72 default
73 )]
74 pub skip: Option<StringOrBool>,
75 /// Content for a .install file (post-install/pre-remove scripts).
76 pub install: Option<String>,
77 /// Explicit architecture list (default: auto-detect from artifacts).
78 pub arches: Option<Vec<String>>,
79 /// `x86_64` micro-architecture variant — `v1` (baseline), `v2`, `v3`
80 /// (AVX2), or `v4`. Constrained
81 /// to a typed enum because AUR source pkgs build from the upstream
82 /// tarball (no binary artifacts to filter), so the value's only role
83 /// is as the `Amd64` template var consumed by `prepare:` / `build:` /
84 /// `package:` script bodies — typos must fail at parse time, not
85 /// silently render an invalid string into the PKGBUILD.
86 /// When unset, defaults to `v1` at template-render time.
87 pub amd64_variant: Option<Amd64Variant>,
88 /// Override whether this publisher failing should fail the overall release.
89 ///
90 /// Default: `false` — a failure here is logged but does not abort the release.
91 /// Set to `true` to fail the release on any error.
92 #[serde(default, skip_serializing_if = "Option::is_none")]
93 pub required: Option<bool>,
94 /// Template-conditional gate: when the rendered result is falsy
95 /// (`"false"` / `"0"` / `"no"` / empty), the AUR source config is
96 /// skipped. Render failure hard-errors. The
97 /// `aur_sources[].if:`.
98 #[serde(rename = "if")]
99 pub if_condition: Option<String>,
100 /// When `true`, a triggered rollback leaves this publisher's work in
101 /// place rather than attempting to undo it. Default `false`.
102 pub retain_on_rollback: Option<bool>,
103}
104
105/// `x86_64` micro-architecture variant. A typed
106/// values. Used by [`AurSourceConfig::amd64_variant`] to constrain the
107/// `prepare:` / `build:` / `package:` template var surface to a known set —
108/// AUR source pkgs build from the upstream tarball so the value is
109/// template-only (no artifact filter) and a typo would render an invalid
110/// PKGBUILD silently.
111#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
112#[serde(rename_all = "snake_case")]
113pub enum Amd64Variant {
114 V1,
115 V2,
116 V3,
117 V4,
118}
119
120impl Amd64Variant {
121 /// Canonical lowercase string form (`"v1"`..`"v4"`). Matches the
122 /// `Goamd64` external surface and the value rendered into the PKGBUILD
123 /// `Amd64` template var.
124 pub fn as_str(&self) -> &'static str {
125 match self {
126 Amd64Variant::V1 => "v1",
127 Amd64Variant::V2 => "v2",
128 Amd64Variant::V3 => "v3",
129 Amd64Variant::V4 => "v4",
130 }
131 }
132}