-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·136 lines (124 loc) · 4.65 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
·136 lines (124 loc) · 4.65 KB
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
#!/usr/bin/env bash
# scripts/aur/update.sh — bump BOTH AUR packages to a release version.
#
# mcpp-bin/ prebuilt release binaries (per-arch tarball checksums)
# mcpp-m/ built from source via mcpp-bin (source-archive checksum)
#
# Pulls checksums straight from the GitHub release / archive, rewrites each
# PKGBUILD's pkgver + sums, resets pkgrel to 1, regenerates both .SRCINFO
# files, and keeps the shared mcpp.sh wrapper in sync across both dirs.
# Run after a release is published, then publish each package (see README.md).
#
# Usage:
# scripts/aur/update.sh [VERSION] # default: [package].version from mcpp.toml
set -euo pipefail
cd "$(dirname "$0")"
REPO="mcpp-community/mcpp"
ARCHES=(linux-x86_64 linux-aarch64)
# Resolve version: explicit arg, else mcpp.toml at repo root.
if [[ $# -ge 1 ]]; then
VER="$1"
else
VER=$(grep -m1 -E '^\s*version\s*=' ../../mcpp.toml | sed -E 's/.*"([^"]+)".*/\1/')
fi
[[ -n "$VER" ]] || { echo "error: could not determine version" >&2; exit 1; }
echo ":: targeting mcpp v${VER}"
reldl="https://github.com/${REPO}/releases/download/v${VER}"
archive_url="https://github.com/${REPO}/archive/v${VER}.tar.gz"
# --- prebuilt binary checksums (mcpp-bin) ----------------------------------
declare -A SUMS
for plat in "${ARCHES[@]}"; do
url="${reldl}/mcpp-${VER}-${plat}.tar.gz.sha256"
echo ":: fetching ${url}"
line=$(curl -fsSL --connect-timeout 15 "$url") \
|| { echo "error: cannot fetch sha256 for ${plat} (is v${VER} released?)" >&2; exit 1; }
SUMS[$plat]=$(awk '{print $1}' <<<"$line")
[[ -n "${SUMS[$plat]}" ]] || { echo "error: empty sha256 for ${plat}" >&2; exit 1; }
done
x86=${SUMS[linux-x86_64]}
arm=${SUMS[linux-aarch64]}
# --- source-archive checksum (mcpp-m) ----------------------------------------
echo ":: hashing source archive ${archive_url}"
src=$(curl -fsSL --connect-timeout 30 "$archive_url" | sha256sum | awk '{print $1}')
[[ -n "$src" ]] || { echo "error: cannot hash source archive" >&2; exit 1; }
# --- keep the wrapper in sync ----------------------------------------------
cp -f mcpp-bin/mcpp.sh mcpp-m/mcpp.sh 2>/dev/null || true
# --- rewrite mcpp-bin/PKGBUILD ---------------------------------------------
sed -i -E \
-e "s/^pkgver=.*/pkgver=${VER}/" \
-e "s/^pkgrel=.*/pkgrel=1/" \
-e "s/^sha256sums_x86_64=\('[^']*'\)/sha256sums_x86_64=('${x86}')/" \
-e "s/^sha256sums_aarch64=\('[^']*'\)/sha256sums_aarch64=('${arm}')/" \
mcpp-bin/PKGBUILD
# --- rewrite mcpp-m/PKGBUILD ---------------------------------------------
sed -i -E \
-e "s/^pkgver=.*/pkgver=${VER}/" \
-e "s/^pkgrel=.*/pkgrel=1/" \
-e "s/^sha256sums=\('[^']*'\)/sha256sums=('${src}')/" \
mcpp-m/PKGBUILD
# --- regenerate .SRCINFO files ---------------------------------------------
# Prefer makepkg's own generator on an Arch host; fall back to templates so
# this also works when bumping from a non-Arch machine (e.g. CI / dev box).
_srcinfo() { # $1 = package dir
# CI runs as root where makepkg refuses to run; MCPP_AUR_NO_MAKEPKG=1
# forces the template path (byte-identical output, no makepkg needed).
if [[ -z "${MCPP_AUR_NO_MAKEPKG:-}" ]] && command -v makepkg >/dev/null 2>&1; then
( cd "$1" && makepkg --printsrcinfo > .SRCINFO )
return
fi
case "$1" in
mcpp-bin)
cat > mcpp-bin/.SRCINFO <<EOF
pkgbase = mcpp-bin
pkgdesc = Modern C++ build & package management tool (prebuilt binary)
pkgver = ${VER}
pkgrel = 1
url = https://github.com/${REPO}
arch = x86_64
arch = aarch64
license = Apache-2.0
depends = git
conflicts = mcpp-m
conflicts = mcpp
options = !strip
source = mcpp.sh
sha256sums = SKIP
source_x86_64 = mcpp-${VER}-linux-x86_64.tar.gz::${reldl}/mcpp-${VER}-linux-x86_64.tar.gz
sha256sums_x86_64 = ${x86}
source_aarch64 = mcpp-${VER}-linux-aarch64.tar.gz::${reldl}/mcpp-${VER}-linux-aarch64.tar.gz
sha256sums_aarch64 = ${arm}
pkgname = mcpp-bin
EOF
;;
mcpp-m)
cat > mcpp-m/.SRCINFO <<EOF
pkgbase = mcpp-m
pkgdesc = Modern C++ build & package management tool (built from source)
pkgver = ${VER}
pkgrel = 1
url = https://github.com/${REPO}
arch = x86_64
arch = aarch64
license = Apache-2.0
makedepends = mcpp-bin
makedepends = git
depends = git
conflicts = mcpp-bin
conflicts = mcpp
options = !strip
source = mcpp-${VER}.tar.gz::${archive_url}
source = mcpp.sh
sha256sums = ${src}
sha256sums = SKIP
pkgname = mcpp-m
EOF
;;
esac
}
_srcinfo mcpp-bin
_srcinfo mcpp-m
echo ":: updated to v${VER}"
echo " mcpp-bin x86_64 ${x86}"
echo " mcpp-bin aarch64 ${arm}"
echo " mcpp-m source ${src}"
echo ":: review, then publish each package (see scripts/aur/README.md)"