summaryrefslogtreecommitdiff
path: root/bumpPkgrel
blob: a8671668fbbc366947a71b00aff8eb87b32b0303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

if [ $# -eq 0 ]; then
  >&2 echo 'usage: bumpPkgrel [-n] $pkg1 $pkg2 $pkg3 ...'
  exit 1
fi

if [ "x$1" = 'x-n' ]; then
  commit=false
  shift
else
  commit=true
fi

if [ $# -eq 1 ]; then

  cd "$(dirname "$0")"

  pkg="${1%/}"
  cd "${pkg}"
  eval "$(
    grep '^pkgrel=' 'PKGBUILD'
  )"
  sed -i '
    s@^\(pkgrel=\)\('"'"'\?\)[0-9]\+\2$@\1'"$((pkgrel+1))"'@
  ' 'PKGBUILD'
  if ${commit}; then
    if [ -d '.git' ] || [ -f '.git' ]; then
      makepkg --printsrcinfo > .SRCINFO
      git commit 'PKGBUILD' '.SRCINFO' -m "${pkg}: rebuild"
      git push || exit 1
      cd ..
      git commit "${pkg}" -m "${pkg}: rebuild"
    else
      git commit 'PKGBUILD' -m "${pkg}: rebuild"
    fi
  fi

else

  printf '%s\n' "$@" \
    | xargs -rn1 "$0"

fi