#!/bin/bash

me="$(readlink -f $0)"
cd $(dirname "${me}")

for pkgbuild in perl-*/PKGBUILD demeter/PKGBUILD; do

  pkgrel="$(
    sed -n "/^pkgrel='\?[0-9]\+'\?\$/{s@^pkgrel='\?\([0-9]\+\)'\?\$@\1@;p}" "${pkgbuild}"
  )"
  sed -i "s@^\(pkgrel=\)'\?[0-9]\+'\?\$@\1'$[${pkgrel}+1]'@" "${pkgbuild}"
  git add "${pkgbuild}"

done

git commit -m 'recompile all perl packages'