-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·86 lines (68 loc) · 1.95 KB
/
run.sh
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
#!/usr/local/bin/dumb-init /bin/bash
set -euo pipefail
: ${TIMEOUT:=0} # allow to restrict runtime of the makepkg build
MAKEPKG_OPTS=(-cCs --noconfirm --needed)
REPOADD_OPTS=()
SKIP_VERIFY="${SKIP_VERIFY:-}"
while getopts ":hRs" opt; do
case "${opt}" in
R) # Remove older version of package from repo
REPOADD_OPTS+=(-R)
;;
s) # Skip PGP check for source signatures
SKIP_VERIFY="true"
;;
h | *) # Display help
echo "Usage:"
grep '\s.)\ #' $0
exit 1
;;
esac
done
SRC=${1:-}
# Override WORKDIR
cd /src
if [ ! -e PKGBUILD ]; then
if [ -z "${SRC}" ]; then
echo "No /src/PKGBUILD was found and no repo to clone was given as parameter"
exit 1
fi
# Ensure permissions on src
chown -R builder /src
gosu builder git clone "${SRC}" /src/git
cd /src/git
fi
[[ ${SKIP_VERIFY:-} == true ]] && {
MAKEPKG_OPTS+=(--skippgpcheck)
}
[ -e /config/signing.asc ] && {
gosu builder gpg --import </config/signing.asc
MAKEPKG_OPTS+=(--sign)
REPOADD_OPTS+=(--sign)
}
if [ -e /config/pacman.conf ]; then
# Allow full overwrite of pacman.conf
cp /config/pacman.conf /etc/pacman.conf
elif [ -e /config/pacman.conf.partial ]; then
# Allow to provide a partial pacman.conf to append
cat /config/pacman.conf.partial >>/etc/pacman.conf
fi
# Update pacman index and any updated package
pacman -Syyu --noconfirm
# Retrieve GPG keys if required
gosu builder getkeys.sh
# Execute the build itself
gosu builder timeout ${TIMEOUT} makepkg ${MAKEPKG_OPTS[@]}
PACKAGE=($(find . -regextype egrep -regex '^.*\.pkg(|\.tar|\.tar\.xz|\.tar\.zst)$'))
REPODB=$(find /repo -regextype egrep -regex '^.*\.db(\.tar|\.tar\.xz|\.tar.zst)$')
if [ -z "${REPODB}" ]; then
echo "No database found in /repo, not adding package."
echo "The built package is available in ${PACKAGE}"
exit 0
fi
for pkg_file in "${PACKAGE[@]}"; do
gosu builder mv ${pkg_file}* /repo
pushd /repo
gosu builder repo-add ${REPOADD_OPTS[@]} ${REPODB} "${pkg_file}"
popd
done