summaryrefslogtreecommitdiff
path: root/build
blob: 0c70c8ecb41e453d12d905f6b89e791960d2e2de (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"
			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 "$@"