#!/usr/bin/env bash . "$HOME"/.makepkg.conf cd "$HOME"/packaging/pkgbuilds source $(dirname $0)/package-list.bash need_rebuild=() #for package in "${!packages[@]}"; do # if [[ -d "$package" ]]; then # cd "$package" # (makepkg -src --noconfirm) & # cd - #done ## # Buils the given package # # Arguments: # $1: Directory that contains the PKGBUILD of the # package to build. build_package() { if [[ -d "$1" ]]; then (cd "$1" makepkg -src --noconfirm 2>/dev/null) fi } ## # Get newest commit of VCS repo. # # Arguments: # $1 Path to the directory of the VCS repo. # $2 Name of the ref to get the newest commit of get_new_commit() { if [[ -d "$1" ]]; then (cd "$1" if [[ -d .hg ]]; then hg update &>/dev/null printf "%s" "$(hg log -r "." --template "{node|short}")" elif [[ -n "$(git config --get core.bare)" ]]; then if [[ -n "$2" ]]; then local ref="$2" else local ref=HEAD fi printf "%s" "$(git rev-parse --short $ref)" fi) else printf "%s\n" "Repository to get commit from not found" 1>&2 fi } ## # Get commit of the laste built package from pkgver of PKGBUILD # # Arguments: # $1 Path to the directory of the PKGBUILD to get te old commit from. get_old_commit() { (source "$1"/PKGBUILD printf "%s" "$(sed -r 's/.*\.r[0-9]*\.g?//' <<<$pkgver)") } for package in "${!packages[@]}"; do new_head=$(get_new_commit "$SRCDEST"/"${packages[$package]}" "${branches[$package]}") old_commit=$(get_old_commit $package) # printf "%-30s\t\t%s\t\t%s\n" $package $old_commit $new_head if [[ "$old_commit" != "$new_head" ]]; then need_rebuild+=("$package") fi done if [ ${#need_rebuild[@]} -eq 0 ]; then printf "%s" "No VCS packages needing rebuilding." else printf "%s" "Packages needing rebuilding: " for package in "${need_rebuild[@]}"; do printf "%s" "$package" build_package "$package" &>/dev/null & done fi wait printf "\n" "$HOME"/packaging/vodik-repose/repose kyriasis -r "$HOME"/packaging/repo -p "$HOME"/packaging/built_packages -v