#!/usr/bin/env bash source "${BASH_SOURCE%/*}"/config.bash db_build_script="$(pwd)"/"${BASH_SOURCE%/*}"/db-build 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)") } get_repo_sha() { shopt -s nullglob local packages for f in "$REPO_ROOT"/"$1"*.tar.xz; do package="${f##*/}" package="${package//-git-/-git }" package="${package//-hg-/-hg }" package="${package//-?-*.pkg.tar.xz}" IFS=' ' read -ra p <<< "$package" if [[ -z "${package//* debug-*}" ]]; then continue else name="${p[0]}" ver="${p[1]}" printf "%s" "$(sed -r 's/.*\.r[0-9]*\.g?//' <<<$ver)" return fi done } main() { for package in "${packages[@]}"; do old_version[$package]=$(get_repo_sha "$package") (cd "$PKGBUILD_DIR"/"$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 printf "%-30s %-25s %s\n" "$package" "${old_version[$package]}" "$new_head" 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 "%s\n" "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 "$db_build_script" } main "$@"