summaryrefslogtreecommitdiff
path: root/update.sh
blob: 8ce44e066e3577fb0a899ef5bbe128eb6ee1892c (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
#!/bin/bash

set -e

pkg="${1%:}"
version="$2"

cd /usr/src/ports/*/${pkg}
oldVer=$(
  sed '
    s/^version=//
    t
    d
  ' Pkgfile
)
if [ -z "${version}" ]; then
  version="${oldVer}"
fi
if [ "${oldVer}" = "${version}" ]; then
  release=$((
    1+$(
      sed '
        s/^release=//
        t
        d
      ' Pkgfile
    )
  ))
  sed -i '
    /^release=/ s/=.*$/='"${release}"'/
  ' Pkgfile
else
  sed -i '
    /^version=/ s/=.*$/='"${version}"'/
    /^release=/ s/=.*$/=1/
  ' Pkgfile
fi
sudo -u pkgmk fakeroot pkgmk -if -im -is -d
pkgmk -uf
pkgmk -um
pkgmk -us -sk /etc/ports/deepthought.sec
if [ "${oldVer}" = "${version}" ]; then
  git commit . -m "${pkg}: rebuild"
else
  git commit . -m "${pkg}: ${oldVer} -> ${version}"
fi

echo 'Erfolg!'