summaryrefslogtreecommitdiff
path: root/bumpPython
blob: c7eb39166d05265eec75ef56d0f545e46a92c86f (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
#!/bin/bash

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

usage() {
  >&2 echo 'usage:'
  >&2 echo '  bumpPython 2'
  >&2 echo 'or:'
  >&2 echo '  bumpPython 3'
  exit 1
}

if [ $# -ne 1 ]; then
  usage
fi

case "$1" in

  '2')
    pkgbuilds=(
      $(grep -l 'python>=2' */PKGBUILD)
    )
    pyver=$(
      python2 --version 2>&1
    )
  ;;
  '3')
    pkgbuilds=(
      $(grep -l 'python>=3' */PKGBUILD)
    )
    pyver=$(
      python --version 2>&1
    )
  ;;
  *)
    usage
  ;;
esac

pyver=$(
  printf '%s\n' "${pyver}" | \
    cut -d' ' -f2 | \
    cut -d. -f1,2
)
pymajor="${pyver%%.*}"
pyverupper="${pymajor}.$((${pyver#*.}+1))"

for pkgbuild in "${pkgbuilds[@]}"; do

  ./bumpPkgrel -n "${pkgbuild%/PKGBUILD}"
  sed -i '
    s@'"'python>=${pymajor}\.[0-9]\+'@'python>=${pyver}'"'@
    s@'"'python<${pymajor}\.[0-9]\+'@'python<${pyverupper}'"'@
  ' "${pkgbuild}"
  if [ -d "${pkgbuild%/*}"'/.git' ] || [ -f "${pkgbuild%/*}"'/.git' ]; then
    cd "${pkgbuild%/*}"
    makepkg --printsrcinfo > .SRCINFO
    git commit 'PKGBUILD' '.SRCINFO' -m "${pkgbuild%/*}: rebuild against new python ${pyver}"
    git push || exit 1
    cd ..
    git add "${pkgbuild%/*}"
  else
    git add "${pkgbuild}"
  fi

done

git commit -m 'recompile all python packages'