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

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

perlMinor=$(
  pacman -Q perl | \
    sed '
      s/^\S\+ //
    '
)
perlMajor="${perlMinor%%.*}"
perlMinor="${perlMinor#${perlMajor}.}"
perlMinor="${perlMinor%%.*}"

for pkgbuild in perl-*/PKGBUILD demeter/PKGBUILD; do

  pkgrel="$(
    sed -n "/^pkgrel='\?[0-9]\+'\?\$/{s@^pkgrel='\?\([0-9]\+\)'\?\$@\1@;p}" "${pkgbuild}"
  )"
  sed -i "s@^\(pkgrel=\)'\?[0-9]\+'\?\$@\1'$[${pkgrel}+1]'@" "${pkgbuild}"
  sed -i '
    /^depends=(/{
      :a
      /)/! {
        N
        ba
      }
      s/\n\(\s*\('"'"'\?\)perl[<>]\S\+\2\n\)\+/\n/
      s/^depends=([^\n]*\n/\0  '"'"'perl>='"${perlMajor}.${perlMinor}'"'\n  '"'"'perl<'"${perlMajor}.$((perlMinor+1))'"'\n/
    }
  ' "${pkgbuild}"
  if ! grep -q '^depends=(' "${pkgbuild}"; then
    sed -i '
      /^arch=(/ a depends=(\
  '"'"'perl>='"${perlMajor}.${perlMinor}'"'\
  '"'"'perl<'"${perlMajor}.$((perlMinor+1))'"'\
)
    ' "${pkgbuild}"
  fi
  git add "${pkgbuild}"

done

git commit -m 'recompile all perl packages'