summaryrefslogtreecommitdiff
path: root/bumpVersion
blob: ea9db2677cbd48e81849487403a6d91346a8e7e2 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash

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

verwendung() {
  >&2 echo ''
  >&2 echo "$(basename "$0")"': aktualisiere Version von Paketen in archlinuxewe'
  >&2 echo ''
  >&2 echo 'mögliche Optionen:'
  >&2 echo '  -h|--help:             zeige diese Hilfe'
  >&2 echo '  -n|--nicht $paket:     ignoriere Paket $paket'
  [ -z "$1" ] && exit 1 || exit $1
}

eval set -- "$(
  getopt -o hn: \
    --long help \
    --long nicht: \
    -n "$(basename "$0")" -- "$@" || \
    echo verwendung
)"

unset nichtPakete

while true
do
  case "$1" in
    -h|--help)
      verwendung 0
    ;;
    -n|--nicht)
      shift
      nichtPakete="$(printf '%s\n%s' "${nichtPakete}" "$1" | grep -v '^$')"
    ;;
    --)
      shift
      break
    ;;
    *)
      >&2 echo 'Hups, das sollte nicht passieren können, Option '"$1"' kenne ich doch nicht ...'
      exit -1
  esac
  shift
done

if [ $# -eq 0 ]
then
  >&2 echo 'bumping versions of all packages ...'
  pkgs="$(
    (
      "${myDir}/checkVersions" --noUpdate | \
        cut -d: -f1
      echo "${nichtPakete}"
      echo "${nichtPakete}"
    ) | \
      sort | \
      uniq -u
  )"
  [ -z "${pkgs}" ] && exit 0
  "${me}" ${pkgs}
  exit $?
elif [ $# -gt 1 ]
then
  [ -n "${nichtPakete}" ] && verwendung
  err=0
  for pkg in "$@"
  do
    "${me}" "${pkg}"
    cErr=$?
    [ ${cErr} -gt ${err} ] && err=${cErr}
  done
  exit ${err}
fi
[ -n "${nichtPakete}" ] && verwendung

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

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

if [ -z "${remVer}" ]
then
  >&2 echo '... remote Version not determined.'
  exit 0
fi

cd "${paket}"

sed 's|^\(\s*\)pkgver=.*$|\1pkgver='"${remVer}"'|;
  s|^\(\s*\)pkgrel=.*$|\1pkgrel=1|;
  s@^\s*\(sha[[:digit:]]\+sums\|md5sums\)=@sha512sums=@;
  /^\(sha[[:digit:]]\+\|md5\)sums_/d;
'"${sedExtra}" -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}-${pkgrel} -> ${remVer}-1"

>&2 echo '... done'