Skip to content

Commit fc52049

Browse files
committed
fix: make Arch packaging checksum release-time generated
1 parent ec2f9ed commit fc52049

5 files changed

Lines changed: 59 additions & 5 deletions

File tree

packaging/.SRCINFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ pkgbase = wayscriber
1717
depends = grim
1818
depends = slurp
1919
source = wayscriber-0.9.19.tar.gz::https://github.com/devmobasa/wayscriber/archive/refs/tags/v0.9.19.tar.gz
20-
sha256sums = e0f569b4b6c7d4f1d0735f32cfc71ae4a8304255a51dffb35198ce4f3d86597d
20+
sha256sums = SKIP
2121

2222
pkgname = wayscriber

packaging/PKGBUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ makedepends=(
2121
'cargo'
2222
)
2323
source=("$pkgname-$pkgver.tar.gz::https://github.com/devmobasa/wayscriber/archive/refs/tags/v$pkgver.tar.gz")
24-
sha256sums=('e0f569b4b6c7d4f1d0735f32cfc71ae4a8304255a51dffb35198ce4f3d86597d')
24+
# Template only: release/AUR automation replaces this after the tag exists.
25+
sha256sums=('SKIP')
2526

2627
prepare() {
2728
cd "$pkgname-$pkgver"

tools/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Helper scripts for development, installation, packaging, and release workflows.
5353
Packaging-only hotfix policy:
5454
- Normal releases use one version everywhere: Cargo, package metadata, Git tags, and artifacts all use `X.Y.Z`.
5555
- Hotfix releases may use `X.Y.Z.N` only when the Cargo version is still `X.Y.Z`. In that case, `packaging/PKGBUILD`, `packaging/.SRCINFO`, release artifacts, and AUR metadata use `X.Y.Z.N`; Cargo manifests and `flake.nix` stay on `X.Y.Z`.
56+
- Repo `packaging/PKGBUILD` and `packaging/.SRCINFO` are templates and keep `sha256sums=('SKIP')` because the final GitHub tag archive checksum can only be computed after the tag exists. AUR automation writes the real checksum into external AUR metadata.
5657
- Release builds set `WAYSCRIBER_RELEASE_VERSION`, so packaged binaries report the release artifact version. Nix builds follow Cargo and report `X.Y.Z` unless the Cargo version itself is bumped.
5758

5859
- **create-release-tag.sh** - Create git tag (local only)

tools/bump-version.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ Usage: tools/bump-version.sh [--dry-run] [new_version]
1515
* Cargo.lock (via cargo generate-lockfile)
1616
* configurator/Cargo.lock local package versions
1717
* flake.nix package version follows Cargo.toml automatically
18-
* packaging/PKGBUILD pkgver
18+
* packaging/PKGBUILD pkgver and template sha256sums=('SKIP')
1919
* packaging/.SRCINFO (via makepkg --printsrcinfo)
2020
21+
The repo PKGBUILD is a template: release/AUR automation computes the real
22+
source archive checksum after the tag exists.
23+
2124
Requires: cargo, jq, makepkg, sed, perl, python3 or python pointing to Python 3.
2225
EOF
2326
}
@@ -163,9 +166,10 @@ fi
163166

164167
if [[ -f packaging/PKGBUILD ]]; then
165168
if $DRY_RUN; then
166-
echo "dry-run: would set pkgver=${package_version} in packaging/PKGBUILD and regenerate .SRCINFO"
169+
echo "dry-run: would set pkgver=${package_version}, reset sha256sums=SKIP, and regenerate .SRCINFO"
167170
else
168171
sed -i "s/^pkgver=.*/pkgver=${package_version}/" packaging/PKGBUILD
172+
sed -i "s/^sha256sums=.*/sha256sums=('SKIP')/" packaging/PKGBUILD
169173
(cd packaging && makepkg --printsrcinfo > .SRCINFO)
170174
fi
171175
else

tools/check-version-consistency.sh

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Checks that release/version metadata agrees across:
1414
* packaging/.SRCINFO
1515
* flake.nix
1616
17+
Repo packaging metadata is a release template and must use sha256sums=('SKIP').
18+
Release/AUR automation writes the real source archive checksum after the tag
19+
exists.
20+
1721
When --release-version is provided, it must either match Cargo.toml exactly
1822
or be a packaging hotfix version of the Cargo version (for example, Cargo
1923
0.9.19 with release 0.9.19.1). Hotfix releases require packaging/PKGBUILD
@@ -77,6 +81,7 @@ release_version = sys.argv[2] or None
7781
errors = []
7882
7983
version_re = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
84+
checksum_re = re.compile(r"^[0-9a-fA-F]{64}$")
8085
8186
def read_text(path):
8287
return (root / path).read_text(encoding="utf-8")
@@ -112,13 +117,47 @@ def srcinfo_version(path):
112117
match = re.search(r"^\s*pkgver = (.+)$", read_text(path), re.MULTILINE)
113118
return match.group(1).strip() if match else None
114119
120+
def pkgbuild_sha256sums(path):
121+
match = re.search(r"(?ms)^sha256sums=\((.*?)\)", read_text(path))
122+
if not match:
123+
return []
124+
125+
values = []
126+
for value_match in re.finditer(r"'([^']*)'|\"([^\"]*)\"|(\S+)", match.group(1)):
127+
value = next(group for group in value_match.groups() if group is not None)
128+
values.append(value.strip())
129+
return values
130+
131+
def srcinfo_sha256sums(path):
132+
return [
133+
match.group(1).strip()
134+
for match in re.finditer(r"^\s*sha256sums = (.+)$", read_text(path), re.MULTILINE)
135+
]
136+
115137
def is_hotfix_of(version, base):
116138
return re.fullmatch(re.escape(base) + r"\.\d+", version) is not None
117139
118140
def require_equal(label, actual, expected):
119141
if actual != expected:
120142
errors.append(f"{label}: expected {expected}, got {actual or 'missing'}")
121143
144+
def require_template_sha256sums(label, values):
145+
if values == ["SKIP"]:
146+
return
147+
148+
if not values:
149+
errors.append(f"{label}: expected SKIP template checksum, got missing")
150+
return
151+
152+
actual = ", ".join(values)
153+
if any(checksum_re.fullmatch(value) for value in values):
154+
errors.append(
155+
f"{label}: expected SKIP template checksum, got fixed SHA {actual}; "
156+
"release/AUR automation writes the real checksum after the tag exists"
157+
)
158+
else:
159+
errors.append(f"{label}: expected SKIP template checksum, got {actual}")
160+
122161
root_version = cargo_version("Cargo.toml")
123162
config_version = cargo_version("configurator/Cargo.toml")
124163
require_equal("configurator/Cargo.toml", config_version, root_version)
@@ -153,6 +192,12 @@ else:
153192
154193
require_equal("packaging/PKGBUILD pkgver", packaging_version, expected_packaging_version)
155194
require_equal("packaging/.SRCINFO pkgver", srcinfo_pkgver, expected_packaging_version)
195+
require_template_sha256sums(
196+
"packaging/PKGBUILD sha256sums", pkgbuild_sha256sums("packaging/PKGBUILD")
197+
)
198+
require_template_sha256sums(
199+
"packaging/.SRCINFO sha256sums", srcinfo_sha256sums("packaging/.SRCINFO")
200+
)
156201
157202
flake_text = read_text("flake.nix")
158203
if "builtins.fromTOML (builtins.readFile ./Cargo.toml)" not in flake_text:
@@ -164,5 +209,8 @@ if errors:
164209
print(f"- {error}", file=sys.stderr)
165210
sys.exit(1)
166211
167-
print(f"Version consistency OK: Cargo={root_version}, packaging={expected_packaging_version}")
212+
print(
213+
f"Version consistency OK: Cargo={root_version}, "
214+
f"packaging={expected_packaging_version}, checksum=SKIP"
215+
)
168216
PY

0 commit comments

Comments
 (0)