#!/bin/bash cd "$(dirname "$(readlink -e "$0")")" if [ "x$1" = 'x--pull' ]; then shift if ! git pull --ff-only; then if ! git pull --rebase \ && git push; then >&2 echo 'cannot push/pull' exit 1 fi fi fi if [ -n "$(git status --porcelain)" ]; then >&2 echo 'git is not clean' exit 1 fi ids=$( for pkg in */PKGBUILD; do cd "${pkg%/PKGBUILD}" ../addPkgbuildPatch add { printf '%s-build:latest\n' arch artix printf 'arch32-%s-build\n' i486 i686 pentium4 } \ | shuf \ | xargs -rn1 docker run --rm -d -v .:/build cd .. done \ | tee /dev/stderr ) check_and_commit_package_updates() { [ -z "$(git status --porcelain)" ] && return for pkg in $( git status --porcelain \ | sed ' s@^.. @@ s@/[^/]\+$@@ ' \ | grep -vxFf <( docker ps --format '{{.Mounts}}' --no-trunc \ | sed 's@^.*/@@' ) ); do if ! [ -d "$pkg" ]; then >&2 echo "$pkg is not a directory" continue fi cd "$pkg" ../addPkgbuildPatch del [ -n "$(git status --porcelain -- .)" ] \ && ../commit-package -a \ && git push cd .. done } while docker ps --no-trunc | grep -wF "${ids}"; do sleep 10 check_and_commit_package_updates date done check_and_commit_package_updates