-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·69 lines (54 loc) · 1.27 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
#!/usr/bin/env bash
rm -rf packages 2>/dev/null
DIR="$(pwd)"
PKGS=(`ls -d */ | cut -f1 -d'/'`)
PKGDIR="$DIR/packages"
## Script Termination
exit_on_signal_SIGINT () {
{ printf "\n\n%s\n" "Script interrupted." 2>&1; echo; }
exit 0
}
exit_on_signal_SIGTERM () {
{ printf "\n\n%s\n" "Script terminated." 2>&1; echo; }
exit 0
}
trap exit_on_signal_SIGINT SIGINT
trap exit_on_signal_SIGTERM SIGTERM
# Build packages
build_pkgs () {
local pkg
RDIR=$1
if [[ ! -d "$PKGDIR" ]]; then
mkdir -p "$PKGDIR"
fi
echo -e "\nBuilding Packages - \n"
for pkg in "${PKGS[@]}"; do
echo -e "Building ${pkg}..."
cd ${pkg} && updpkgsums && makechrootpkg -c -r $CHROOT && mv *.pkg.tar.zst "$PKGDIR"
# Verify
while true; do
set -- "$PKGDIR"/${pkg}-*
if [[ -e "$1" ]]; then
echo -e "\nPackage '${pkg}' generated successfully.\n"
break
else
echo -e "\nFailed to build '${pkg}', Exiting...\n"
exit 1;
fi
done
cd "$DIR"
done
if [[ -d "$RDIR" ]]; then
mv -f "$PKGDIR"/*.pkg.tar.zst "$RDIR" && rm -r "$PKGDIR"
echo -e "Packages moved to Repository.\n[!] Don't forget to update the database.\n"
else
echo $RDIR
exit 1
fi
}
if (( $# < 1 ))
then
echo "Usage: $0 Repository Path"
exit 1
fi
build_pkgs $1