summaryrefslogtreecommitdiff
path: root/build
blob: bee133b0318c695c3b5a97c2cca620f9db72039a (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
#!/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
			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 "$@"