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.
58 pub git_url: Option<String>,
59 /// Custom SSH command for git operations.
60 pub git_ssh_command: Option<String>,
61 /// Path to SSH private key file.
62 pub private_key: Option<String>,
63 /// Subdirectory in the git repo for committed files.
64 pub directory: Option<String>,
65 /// Skip this config.
66 #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
67 pub skip: Option<StringOrBool>,
68 /// Explicit architecture list (default: auto-detect from artifacts).
69 pub arches: Option<Vec<String>>,
70 /// `x86_64` micro-architecture variant — `v1` (baseline), `v2`, `v3`
71 /// (AVX2), or `v4`. Equivalent to GR `AurSource.Goamd64`. Constrained
72 /// to a typed enum because AUR source pkgs build from the upstream
73 /// tarball (no binary artifacts to filter), so the value's only role
74 /// is as the `Amd64` template var consumed by `prepare:` / `build:` /
75 /// `package:` script bodies — typos must fail at parse time, not
76 /// silently render an invalid string into the PKGBUILD.
77 /// When unset, defaults to `v1` at template-render time.
78 pub amd64_variant: Option<Amd64Variant>,
79}
80
81/// `x86_64` micro-architecture variant. Mirrors GoReleaser's `Goamd64` typed
82/// values. Used by [`AurSourceConfig::amd64_variant`] to constrain the
83/// `prepare:` / `build:` / `package:` template var surface to a known set —
84/// AUR source pkgs build from the upstream tarball so the value is
85/// template-only (no artifact filter) and a typo would render an invalid
86/// PKGBUILD silently.
87#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
88#[serde(rename_all = "snake_case")]
89pub enum Amd64Variant {
90 V1,
91 V2,
92 V3,
93 V4,
94}
95
96impl Amd64Variant {
97 /// Canonical lowercase string form (`"v1"`..`"v4"`). Matches the GR
98 /// `Goamd64` external surface and the value rendered into the PKGBUILD
99 /// `Amd64` template var.
100 pub fn as_str(&self) -> &'static str {
101 match self {
102 Amd64Variant::V1 => "v1",
103 Amd64Variant::V2 => "v2",
104 Amd64Variant::V3 => "v3",
105 Amd64Variant::V4 => "v4",
106 }
107 }
108}