#!/usr/bin/env bash
#
# Update all AUR packages in $HOME/pkg

set -euo pipefail

find "$HOME/pkg" -mindepth 1 -maxdepth 1 -type d -print0 | while read -rd $'\0' pkgdir
do
  cd "$pkgdir"
  pullres=$(git pull --rebase)
  if [ "$pullres" = "Already up to date." ]; then
    continue
  fi

  makepkg -si --noconfirm --needed
done