summaryrefslogtreecommitdiff
path: root/bumpVersion
blob: 772dbcb5d020bdab4d6ea6dd826fba9542d797cf (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash

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

if [ $# -eq 0 ]
then
  >&2 echo 'bumping versions of all packages ...'
  "${me}" $(ls "${myDir}"/*/PKGBUILD | sed 's|^.*/\([^/]\+\)/PKGBUILD$|\1|')
  exit $?
elif [ $# -gt 1 ]
then
  err=0
  for pkg in "$@"
  do
    "${me}" "${pkg}"
    cErr=$?
    [ ${cErr} -gt ${err} ] && err=${cErr}
  done
  exit ${err}
fi

paket="${1%/}"
>&2 echo "bumping '${paket}' ..."

cd "${myDir}"
[ -r "${paket}/PKGBUILD" ] || exit 1
eval $(./checkVersions -m "${paket}")
if [ "${remVer}" == "${pkgver}" ]
then
  >&2 echo '... nothing to do here.'
  exit 0
fi

cd "${paket}"

sed 's|pkgver=.*$|pkgver='"${remVer}"'|;
  s|pkgrel=.*$|pkgrel=1|;
  s@^\s*\(sha[[:digit:]]\+sums\|md5sums\)=@sha512sums=@;
  /^\(sha[[:digit:]]\+\|md5\)sums_/d
' -i PKGBUILD

sed '
  :begin;
    $!N;
    s@^sha512sums=\([^)]*\)\n\(.*\)$@sha512sums=\1 \2@;
  tbegin;
  P;
  D
' -i PKGBUILD

summen="$( \
  makepkg -g | \
    sed ':begin;
        $!N;
        s@^\(.*\)\n\(.*\)$@\1\\n\2@;
      tbegin;
      P;
      D
    ' \
)"
sed 's|sha512sums=.*$|'"${summen}"'|' -i PKGBUILD

(
  if ! "${myDir}/testeAbhaengigkeiten" "${paket}"
  then
    was=''
    ec[0]='jJyY'
    ec[1]='nN'
    while [[ "${ec[0]}" != *"${was}"* ]] && [[ "${ec[1]}" != *"${was}"* ]] || [ -z "${was}" ]
    do
      read -p 'Trotzdem weiter machen (j/y/n)? ' was
    done
    [[ "${ec[0]}" == *"${was}"* ]]
  fi
) || exit $?

rm -rf pkg src
sudo pacman -Sy
makepkg -fcsr --noconfirm --asdeps || exit 1
namcap ${paket}-${remVer}-1-*.pkg.tar.xz || exit 1
git commit PKGBUILD -m "${paket} ${pkgver} -> ${remVer}"

>&2 echo '... done'