aboutsummaryrefslogtreecommitdiffstats
path: root/build-updated-packages.bash
blob: 197c536d869668d52961cb0be8c6e918b2018b72 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash

source $(dirname $0)/config.bash

cd "$PKGBUILD_DIR"

##
# Get commit sha from PKGVER of PKGBUILD
#
# Arguments:
#    $1    Path to the directory containing the PKGBUILD
#          to get the sha from
get_pkgver_sha() {
	(source "$1"/PKGBUILD
	printf "%s" "$(sed -r 's/.*\.r[0-9]*\.g?//' <<<$pkgver)")
}

main() {
	for package in "${packages[@]}"; do
		old_version[$package]=$(get_pkgver_sha "$package")
		(cd "$package"
		makepkg --nobuild &>/dev/null) &
	done
	wait

	local needs_rebuild=()
	for package in "${packages[@]}"; do
		new_head=$(get_pkgver_sha "$package")

		if [[ "${old_version[$package]}" != "$new_head" ]]; then
			needs_rebuild+=("$package")
		fi
	done

	if [[ ${#needs_rebuild[@]} -eq 0 ]]; then
		printf "%s\n" "No VCS packages found that needs to be rebuilt."
	else
		printf "Packages that needs to be rebuilt:"
		printf "%s\n" "${needs_rebuild[@]}"

		for package in "${needs_rebuild[@]}"; do
			(cd "$package"
			makepkg -src --noconfirm 2>/dev/null) &
		done
		wait
	fi

	$(dirname $0)/db-build
}

main "$@"