#!/usr/bin/env bash if [ ! -f ~/.avr ]; then echo "configuration file not found:" echo "$ cat ~/.avr [build] repositoryName=avr repositoryLocation=/foo/avr/x86_64 " exit 1 fi function getconfig { git config -f ~/.avr --get "$1" } location="$(pwd)" function released_version { name=$1 pacman -Ss $name | grep -e "^$(getconfig build.repositoryName)/$name " | cut -d" " -f2 } current_arch=$(uname -m) packages=() echo "initializing build queue" for name in $(find . -mindepth 1 -maxdepth 1 -type d -not -name "\.*"); do source $(basename $name)/PKGBUILD package=$pkgname local_version="${pkgver}-${pkgrel}" remote_version="$(released_version $package)" if [ -f $package/.norelease ] || [ -f $package/.norelease.$current_arch ]; then echo " disabled: $package (explicit)" elif [ -f $package/.forcerelease ]; then echo " enabled: $package ($local_version) (explicit)" packages+=($package) elif [ "$local_version" == "$(echo -e "$local_version\n$remote_version" | sort -V | head -n1)" ]; then echo " disabled: $package (local version $local_version <= remote version $remote_version)" elif [[ ! " ${arch[*]} " =~ " any " ]] && [[ ! " ${arch[*]} " =~ " $current_arch " ]]; then echo " disabled: $package (arch not targeted in PKGBUILD: $current_arch)" else echo " enabled: $package ($local_version)" packages+=($package) fi done repository_location=$(getconfig build.repositoryLocation) failures=() for package in ${packages[@]} ; do cd "$location/$package" makepkg $* if [ $? -eq 0 ]; then rsync -avhP *.tar.zst $repository_location rsync -avhP *.tar.zst.sig $repository_location else failures+=($package) fi done cd "$location" if [ ${#failures[@]} -gt 0 ]; then echo "failed to build ${#failures[@]} package(s):" for package in ${failures[@]} ; do echo " $package" done exit 1 fi