summaryrefslogtreecommitdiff
path: root/build
blob: 1b3c5d22aac65ac2950f4eec290588db9853e59d (plain)
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
#!/usr/bin/env bash

pkgfilename() (
	BUILDFILE="$(realpath -ms -- "$1")"
	. "$BUILDFILE"
	echo $pkgname-$pkgver-$pkgrel-any.pkg.tar.xz
)

main() {
	local src pkg
	local pkgs=()
	for src in *.PKGBUILD; do
		pkg="$(pkgfilename "$src")"
		while ! { test "$src" -ot "$pkg" && test config.sh -ot "$pkg"; } 2>/dev/null; do
			printf '%s: Building %q\n' "$0" "$src"
			makepkg -d -p "$src" || exit $?
			pkg="$(pkgfilename "$src")"
		done
		pkgs+=("$pkg")
	done

	for pkg in "${pkgs[@]}"; do
		if test "$pkg" -nt config.db.tar.gz; then
			rm -f config.{db,files}{,.tar.gz}
			repo-add config.db.tar.gz "${pkgs[@]}"
			return
		fi
	done
}

main "$@"