-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·91 lines (83 loc) · 1.92 KB
/
build.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
87
88
89
90
91
#!/bin/bash -ex
export LANG=en_US.UTF-8
cd ~/src
gpg --keyserver hkps://keys.openpgp.org --refresh-keys
sudo pacman-key --keyserver hkps://keys.openpgp.org --refresh-keys [email protected]
# Mount the web server's filesystem
sshfs -o allow_root \
[email protected]:/home/project-web/archlinux-repo/htdocs/packages \
~/repo
sudo pacman -Syu --noconfirm
# Download PKGBUILDs from AUR
for i in $(cat aur-build-list); do
if [ ! -e ~/build/"$i" ]; then
curl -fsSL "https://aur.archlinux.org/cgit/aur.git/snapshot/$i.tar.gz" | tar xzC ~/build
fi
done
# Download public keys
curl -fsSL https://github.com/web-flow.gpg | gpg --import
for i in $(cat gpg-keyids); do
set +e
for j in $(seq 10); do
gpg --keyserver keyserver.ubuntu.com --recv-keys "$i" \
|| gpg --keyserver pool.sks-keyservers.net --recv-keys "$i" \
&& break
if [ "$j" == "10" ]; then exit 1; fi
sleep 1
done
set -e
done
# Resolve dependencies
tmp1="$(mktemp)"
tmp2="$(mktemp)"
tmp3="$(mktemp)"
source build-deps.sh
for i in ${!deps[@]}; do
for j in ${deps["$i"]}; do
echo "$j" "$i" >> "$tmp1"
done
done
cat "$tmp1" | tsort > "$tmp2"
cat aur-build-list | sort > "$tmp3"
pkglist="$(cat "$tmp2") $(cat "$tmp2" | sort | comm -3 - "$tmp3")"
# Build packages
build_err=0
tmp_res="$(mktemp)"
for i in $pkglist; do
pushd ~/build/"$i"
patch_path=~/src/patches/"$i".patch
if [ -f "$patch_path" ]; then
if ! patch -Np1 -i "$patch_path"; then
echo "$i patch failed" >> "$tmp_res"
build_err=1
popd
continue
fi
fi
set +e
CARCH=x86_64 makepkg -sr --sign --needed --noconfirm
makepkg_err=$?
set -e
sudo rm -rf src pkg
echo "$i $makepkg_err" >> "$tmp_res"
case $makepkg_err in
0)
for j in $(makepkg --packagelist); do
pushd ~/repo
repo-add -n -R -s archlinux-ddosolitary.db.tar.gz "$j"
popd
done
sudo pacman -Sy
;;
13)
;;
*)
build_err=1
;;
esac
popd
done
# Exit
fusermount3 -u ~/repo
cat "$tmp_res"
exit $build_err