summarylogtreecommitdiffstats
path: root/update.sh
blob: 72783f1444bd9ef7338a50c0431e7e0decdc2b2c (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
#!/usr/bin/env bash

if ! [ -f pkgsum.sh ]; then
  wget https://gist.github.com/nandub/04f1f049a5e55476b642/raw/02c13a02fb7e9121d1390b3a4f5f6fca5d11e07b/pkgsum.sh
  chmod +x pkgsum.sh
fi

get_latest() {
  wget -q -O- 'http://primesieve.org/downloads/' | \
  sed -n 's,.*primesieve-\([0-9][^>]*\)\.tar.*,\1,p' | \
  grep -v '\(linux\|mac\|win\)' | \
  sort -r | \
  head -1
}
latest_version=pkgver=$(get_latest)
current_version=$(cat PKGBUILD | grep pkgver=[^d.].[^d.].[^d.])

if ! [ "$latest_version" = "$current_version" ]; then
  echo Updating the package with the latest version
  echo latest: $latest_version
  echo current: $current_version
  sed -i.bak "s/$current_version/$latest_version/g" PKGBUILD
  sed -i.bak "s/pkgrel=[^d.]/pkgrel=1/g" PKGBUILD
  ./pkgsum.sh
  mksrcinfo
else
  echo Nothing to update.
fi