summaryrefslogtreecommitdiff
path: root/bumpVersion
blob: 5cf3e20fe09db2983084f4c9b84563b0f0f98477 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/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

auto_summen=true

cd "${paket}"

if [ "${paket}" = 'local-certificates' ]; then
  sums=$(
    curl -Ss 'https://eckner.net/certs/sha512sums'
  )
  sed_extra='
    /^source=/ i source=(\
'"$(
      printf '%s\n' "${sums}" \
      | sed '
        s@^\S\+  @  '"'"'https://eckner.net/certs/@
        s/$/'"'"'\\/
      '
    )"'
)\
sha512sums=(\
'"$(
      printf '%s\n' "${sums}" \
      | sed '
        s/  .*$/'"'"'\\/
        s/^/  '"'"'/
      '
    )"'
)
    /^source=/,/)$/ d
    /^sha512sums=/,/)$/ d
  '
  auto_summen=false
fi

sed -i 's|^\(\s*\)pkgver=.*$|\1pkgver='"${remVer}"'|;
  s|^\(\s*\)pkgrel=.*$|\1pkgrel=1|;
  '"${sed_extra}"'
' PKGBUILD

if ${auto_summen}; then
  sed -i '
    s@^\s*\(sha[[:digit:]]\+sums\|md5sums\)=@sha512sums=@;
    /^\(sha[[:digit:]]\+\|md5\)sums_/d;
  ' 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
fi

(
  if ! yes '' | "${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 $?

if [ "${paket}" != 'qgis-git' ]; then
  rm -rf "src" "pkg"
  sudo pacman -Sy
  makepkg -fcsr --noconfirm --asdeps || exit 1
  namcap ${paket}-${remVer}-1-*.pkg.tar.xz || exit 1
fi
git commit PKGBUILD -m "${paket} ${pkgver}-${pkgrel} -> ${remVer}-1"

>&2 echo '... done'