Merge branch 'fix/aur-makepkg-builddir-perms'
@@ -137,8 +137,10 @@ publish:aur:
137
137
needs:
138
138
- release:gitlab
139
139
before_script:
140
# Only tools needed to update the AUR git repo (no Rust GUI build deps).
141
# Do not install package name "cargo" — it prompts for a provider (rust vs rustup).
140
142
- pacman -Syu --noconfirm
141
- pacman -S --noconfirm --needed rust cargo pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync curl openssh coreutils
143
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
142
144
- chmod +x scripts/aur-ssh-setup.sh
143
145
- ./scripts/aur-ssh-setup.sh
144
146
script:
@@ -137,8 +137,10 @@ publish:aur:137
needs:
137
needs:
138
- release:gitlab
138
- release:gitlab
139
before_script:
139
before_script:
140
# Only tools needed to update the AUR git repo (no Rust GUI build deps).
141
# Do not install package name "cargo" — it prompts for a provider (rust vs rustup).
140
- pacman -Syu --noconfirm
142
- pacman -Syu --noconfirm
141
- pacman -S --noconfirm --needed rust cargo pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync curl openssh coreutils
143
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
142
- chmod +x scripts/aur-ssh-setup.sh
144
- chmod +x scripts/aur-ssh-setup.sh
143
- ./scripts/aur-ssh-setup.sh
145
- ./scripts/aur-ssh-setup.sh
144
script:
146
script:
@@ -40,7 +40,9 @@ When a Git tag is pushed:
40
40
- computes its SHA-256
41
41
- clones the AUR repo
42
42
- updates `pkgver`, `pkgrel`, and `sha256sums`
43
- regenerates `.SRCINFO` via `makepkg --printsrcinfo` (as a non-root user when CI runs as root)
43
- regenerates `.SRCINFO` via `makepkg --printsrcinfo` (as non-root `aurbuild` when CI runs as root; parent tempdir is made traversable and `BUILDDIR` is forced under that user)
44
- strips a leading `v` from the tag when resolving the GitLab source archive URL
45
44
46
- commits and pushes to AUR `master`
45
47
46
48
## GitLab CI secrets
@@ -40,7 +40,9 @@ When a Git tag is pushed:40
- computes its SHA-25640
- computes its SHA-25641
- clones the AUR repo41
- clones the AUR repo42
- updates `pkgver`, `pkgrel`, and `sha256sums`42
- updates `pkgver`, `pkgrel`, and `sha256sums`43
- regenerates `.SRCINFO` via `makepkg --printsrcinfo` (as a non-root user when CI runs as root)43
- regenerates `.SRCINFO` via `makepkg --printsrcinfo` (as non-root `aurbuild` when CI runs as root; parent tempdir is made traversable and `BUILDDIR` is forced under that user)44
- strips a leading `v` from the tag when resolving the GitLab source archive URL45
44
- commits and pushes to AUR `master`46
- commits and pushes to AUR `master`45
47
46
## GitLab CI secrets48
## GitLab CI secrets@@ -15,10 +15,16 @@ cd "$ROOT"
15
15
if [[ -z "$VERSION" ]]; then
16
16
VERSION="$(grep '^version = ' Cargo.toml | sed -E 's/.*"([^"]+)"/\1/')"
17
17
fi
18
# Tags may be "0.5.1" or "v0.5.1"; GitLab archive URLs and pkgver use the bare version.
19
VERSION="${VERSION#v}"
18
20
19
21
for cmd in git makepkg sed sha256sum curl; do
20
22
command -v "$cmd" >/dev/null || { echo "Missing command: $cmd" >&2; exit 1; }
21
23
done
24
if [[ "$(id -u)" -eq 0 ]]; then
25
command -v runuser >/dev/null || { echo "Missing command: runuser" >&2; exit 1; }
26
command -v useradd >/dev/null || { echo "Missing command: useradd" >&2; exit 1; }
27
fi
22
28
23
29
if [[ ! -f packaging/aur/PKGBUILD ]]; then
24
30
echo "Missing packaging/aur/PKGBUILD template" >&2
@@ -44,18 +50,28 @@ sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD
44
50
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
45
51
sed -i "s|^sha256sums=.*|sha256sums=('${ARCHIVE_SHA}')|" PKGBUILD
46
52
47
# makepkg refuses to run as root (CI images are often root).
48
if [[ "$(id -u)" -eq 0 ]]; then
49
MAKEPKG_USER="${AUR_MAKEPKG_USER:-aurbuild}"
50
if ! id "$MAKEPKG_USER" >/dev/null 2>&1; then
51
useradd --system --create-home --shell /bin/bash "$MAKEPKG_USER"
53
generate_srcinfo() {
54
# makepkg refuses root. mktemp parents are 0700 — aurbuild must be able to traverse
55
# $WORKDIR or [[ -d $BUILDDIR ]] fails and mkdir then errors.
56
if [[ "$(id -u)" -eq 0 ]]; then
57
local makepkg_user="${AUR_MAKEPKG_USER:-aurbuild}"
58
local build_tmp
59
if ! id "$makepkg_user" >/dev/null 2>&1; then
60
useradd --system --create-home --shell /bin/bash "$makepkg_user"
61
fi
62
chmod 755 "$WORKDIR"
63
chown -R "$makepkg_user:$makepkg_user" "$WORKDIR/repo"
64
build_tmp="$(runuser -u "$makepkg_user" -- mktemp -d)"
65
# Belt-and-suspenders: force BUILDDIR into a dir aurbuild definitely owns.
66
runuser -u "$makepkg_user" -- env BUILDDIR="$build_tmp" makepkg --printsrcinfo > .SRCINFO
67
rm -rf "$build_tmp"
68
chown -R root:root "$WORKDIR/repo"
69
else
70
makepkg --printsrcinfo > .SRCINFO
52
71
fi
53
chown -R "$MAKEPKG_USER:$MAKEPKG_USER" "$WORKDIR/repo"
54
runuser -u "$MAKEPKG_USER" -- makepkg --printsrcinfo > .SRCINFO
55
chown -R root:root "$WORKDIR/repo"
56
else
57
makepkg --printsrcinfo > .SRCINFO
58
fi
72
}
73
74
generate_srcinfo
59
75
60
76
if git diff --quiet -- PKGBUILD .SRCINFO; then
61
77
echo "AUR repo already up to date for ${VERSION}"
@@ -15,10 +15,16 @@ cd "$ROOT"15
if [[ -z "$VERSION" ]]; then15
if [[ -z "$VERSION" ]]; then16
VERSION="$(grep '^version = ' Cargo.toml | sed -E 's/.*"([^"]+)"/\1/')"16
VERSION="$(grep '^version = ' Cargo.toml | sed -E 's/.*"([^"]+)"/\1/')"17
fi17
fi18
# Tags may be "0.5.1" or "v0.5.1"; GitLab archive URLs and pkgver use the bare version.19
VERSION="${VERSION#v}"18
20
19
for cmd in git makepkg sed sha256sum curl; do21
for cmd in git makepkg sed sha256sum curl; do20
command -v "$cmd" >/dev/null || { echo "Missing command: $cmd" >&2; exit 1; }22
command -v "$cmd" >/dev/null || { echo "Missing command: $cmd" >&2; exit 1; }21
done23
done24
if [[ "$(id -u)" -eq 0 ]]; then25
command -v runuser >/dev/null || { echo "Missing command: runuser" >&2; exit 1; }26
command -v useradd >/dev/null || { echo "Missing command: useradd" >&2; exit 1; }27
fi22
28
23
if [[ ! -f packaging/aur/PKGBUILD ]]; then29
if [[ ! -f packaging/aur/PKGBUILD ]]; then24
echo "Missing packaging/aur/PKGBUILD template" >&230
echo "Missing packaging/aur/PKGBUILD template" >&2@@ -44,18 +50,28 @@ sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD44
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD50
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD45
sed -i "s|^sha256sums=.*|sha256sums=('${ARCHIVE_SHA}')|" PKGBUILD51
sed -i "s|^sha256sums=.*|sha256sums=('${ARCHIVE_SHA}')|" PKGBUILD46
52
47
# makepkg refuses to run as root (CI images are often root).53
generate_srcinfo() {48
if [[ "$(id -u)" -eq 0 ]]; then54
# makepkg refuses root. mktemp parents are 0700 — aurbuild must be able to traverse49
MAKEPKG_USER="${AUR_MAKEPKG_USER:-aurbuild}"55
# $WORKDIR or [[ -d $BUILDDIR ]] fails and mkdir then errors.50
if ! id "$MAKEPKG_USER" >/dev/null 2>&1; then56
if [[ "$(id -u)" -eq 0 ]]; then51
useradd --system --create-home --shell /bin/bash "$MAKEPKG_USER"57
local makepkg_user="${AUR_MAKEPKG_USER:-aurbuild}"58
local build_tmp59
if ! id "$makepkg_user" >/dev/null 2>&1; then60
useradd --system --create-home --shell /bin/bash "$makepkg_user"61
fi62
chmod 755 "$WORKDIR"63
chown -R "$makepkg_user:$makepkg_user" "$WORKDIR/repo"64
build_tmp="$(runuser -u "$makepkg_user" -- mktemp -d)"65
# Belt-and-suspenders: force BUILDDIR into a dir aurbuild definitely owns.66
runuser -u "$makepkg_user" -- env BUILDDIR="$build_tmp" makepkg --printsrcinfo > .SRCINFO67
rm -rf "$build_tmp"68
chown -R root:root "$WORKDIR/repo"69
else70
makepkg --printsrcinfo > .SRCINFO52
fi71
fi53
chown -R "$MAKEPKG_USER:$MAKEPKG_USER" "$WORKDIR/repo"72
}54
runuser -u "$MAKEPKG_USER" -- makepkg --printsrcinfo > .SRCINFO73
55
chown -R root:root "$WORKDIR/repo"74
generate_srcinfo56
else57
makepkg --printsrcinfo > .SRCINFO58
fi59
75
60
if git diff --quiet -- PKGBUILD .SRCINFO; then76
if git diff --quiet -- PKGBUILD .SRCINFO; then61
echo "AUR repo already up to date for ${VERSION}"77
echo "AUR repo already up to date for ${VERSION}"