-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·60 lines (49 loc) · 1.17 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
#!/usr/bin/env bash
## Copyright (C) 2020-2024 Aditya Shakya <adi1090x@gmail.com>
## Dirs
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
if [[ ! -d "$PKGDIR" ]]; then
mkdir -p "$PKGDIR"
fi
echo -e "\nBuilding Packages - \n"
for pkg in "${PKGS[@]}"; do
echo -e "Building ${pkg}..."
cd ${pkg} && makepkg -sc
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
RDIR='../pkgs/x86_64'
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"
fi
}
## Execute
build_pkgs