#!/usr/bin/env bash source $(dirname $0)/config.bash cd "$PKGBUILD_DIR" ## # Get commit sha from PKGVER of PKGBUILD # # Arguments: # $1 Whether the source is a PKGBUILD or string # $2 Path to the directory containing the PKGBUILD # to get the sha from get_pkgver_sha() { if [[ "$1" -eq "pkgbuild" ]]; then source "$1"/PKGBUILD elif [[ "$1" -eq "string" ]]; then pkgver="$2" else printf "%s\n" "get_pkgver_sha failed" 1>&2 fi printf "%s" "$(sed -r 's/.*\.r[0-9]*\.g?//' <<<$pkgver)" } main() { for package in "${packages[@]}"; do old_version[$package]=$(get_pkgver_sha "pkgbuild" "$package") (cd "$package" makepkg --nobuild &>/dev/null) & done wait local needs_rebuild=() for package in "${packages[@]}"; do new_head=$(get_pkgver_sha "pkgbuild" "$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 "$@"