-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·50 lines (46 loc) · 1.16 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
#/usr/bin/bash
basedir="$PWD"
reponame="${1:-aur}"
find_deps() {
(
set -e
cd "$basedir/$reponame/$1"
cmd < "$(cd "$basedir/$reponame/$1" makepkg --printsrcinfo)" | sed -nr 's/^\W*depends = ([-a-zA-Z0-9]+).*$/\1/p' | while read -r dep; do
for pkg in ${pkgs[@]}; do
cmd < "$(cd "$packagedir" && makepkg --printsrcinfo)" | sed -nr 's/^\W*pkgname = ([-a-zA-Z0-9]+).*$/\1/p' | while read -r package_name; do
if [ "$dep" == "$package_name" ]; then
echo "$pkg"
fi
done
done
done
)
}
build() {
(
set -e
packagename="$1"
packagedir="$basedir/$reponame/$packagename"
if [ ! -f "$packagedir/PKGBUILD" ]; then
echo "Cannot find PKGBUILD in $packagedir"
return 1
fi
find_deps "$packagename" | while read -r dep; do
build "$dep"
done
cd "$packagedir"
makepkg -si --noconfirm --noprogressbar
)
}
if [ "$#" -lt 2 ]; then
# Build all packages from a repository (defaulting to aur)
pkgs=( $(cd "$basedir/$reponame" && find -- * -prune -type d | tr '\n' ' ') )
for pkg in ${pkgs[@]}; do
build "$pkg"
done
else
# Build only requested packages
for pkg in "${@:2}"; do
build "$pkg"
done
fi