-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·129 lines (106 loc) · 3.13 KB
/
build
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
#!/bin/bash
: '
usage:
sudo -E bash ./build [pkg/xyz]
result in rollarch.log and pkg/xyz/rollarch.log
'
set -uo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
#needed https://github.com/graysky2/clean-chroot-manager/pull/77
if ! command -v ccm64 >/dev/null 2>&1; then
echo -e "ccm64 required. https://github.com/graysky2/clean-chroot-manager"
exit 1
fi
LOCAL_PATH=/var/cache/pacman/pkg
REPO_NAME=custom
PACKAGES=${@:-pkg/*}
for package in $PACKAGES; do
if [[ ! -f "$package/PKGBUILD" ]]; then
echo -e "$package/PKGBUILD missing.
Make sure submodules are there. Do::
make update
" >&2
exit 1
fi
done
get_pkg_arch() {
while (( $# )); do
if [[ "$1" == "x86_64" ]] || [[ "$1" == "any" ]]; then
echo "$1"
return
fi
shift
done
}
ROLLARCH="$PWD"
#additional build tools
if [[ -z "$SUDO_USER" ]]; then
if logname &>/dev/null; then
USER=$(logname)
fi
elif [[ "$SUDO_USER" = "root" ]]; then
echo -e "Cannot determine your username. Exiting."
exit 1
else
USER="$SUDO_USER"
fi
HOMEDIR="$(getent passwd "$USER" | cut -d: -f6)"
# CHROOTPATH64="/scratch/.buildroot"
# comes from clean-chroot-manager.conf
source ${XDG_CONFIG_HOME:-$HOMEDIR/.config}/clean-chroot-manager.conf
# in /etc/fstab add setting 10G
# tmpfs /scratch/.buildroot tmpfs nodev,user,noauto,size=10G 0 0
if cat /etc/fstab | grep $CHROOTPATH64 &> /dev/null; then
if ! mount | grep $CHROOTPATH64 &> /dev/null; then
mount $CHROOTPATH64
fi
fi
if [[ ! -f "$CHROOTPATH64"/root/.arch-chroot ]]; then
rm -rf "$CHROOTPATH64"/root
if ! ccm64 c &> rollarch.log; then
rm -rf "$CHROOTPATH64"/root
fi
if [[ ! -f "$CHROOTPATH64"/root/.arch-chroot ]]; then
rm -rf "$CHROOTPATH64"/root
echo "mkarchroot failed"
exit 1
fi
fi
if [[ -d "$CHROOTPATH64/root" ]]; then
for tool in git unzip meson cmake clojure; do
echo "tool $tool"
if [[ ! -x "$CHROOTPATH64/root/usr/bin/$tool" ]]; then
pacstrap "$CHROOTPATH64/root" $tool
fi
done
fi
for package in $PACKAGES; do
cd "$package"
pkgdr="$(pwd)"
dps="$(ARCH=x86_64 CARCH=x86_64 source PKGBUILD && echo "${makedepends[@]} ${depends[@]}")"
for adep in $dps; do
if [[ -d "$ROLLARCH/pkg/$adep" ]]; then
echo "first doing dependency $adep"
cd $ROLLARCH
./build "pkg/$adep"
cd $pkgdr
fi
done
echo "doing $pkgdr"
psuffix="$(ARCH=x86_64 CARCH=x86_64 source PKGBUILD && echo "-$pkgver-$pkgrel-$(get_pkg_arch ${arch[@]}).pkg.tar.*")"
pkgs=*$psuffix
if ! ls *$psuffix 1> /dev/null 2>&1; then
echo "$package..." && ccm64 s &> rollarch.log && echo "OK" || echo "FAIL"
else
echo *$psuffix
fi
for pkgfile in *$psuffix; do
if [[ -f "$pkgfile" ]]; then
cp $pkgfile $LOCAL_PATH
repo-add "$LOCAL_PATH/$REPO_NAME.db.tar.zst" $LOCAL_PATH/$pkgfile
fi
done
cd $ROLLARCH
done
ln -sf "$REPO_NAME.db.tar.zst" "$LOCAL_PATH/$REPO_NAME.db"
ln -sf "$REPO_NAME.files.tar.zst" "$LOCAL_PATH/$REPO_NAME.files"