summaryrefslogtreecommitdiff
path: root/cpan2cruxPorts/lastVersion.sh
blob: 4b91ca6083a61e045d04536271e23302ce8d0f70 (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
#!/bin/bash

if [ $# -eq 0 ]; then
  ls -1 /usr/src/ports/cpan2cruxPorts | \
    parallel -j0 "$0" {} \;
  exit
elif [ $# -gt 1 ]; then
  parallel -j0 -n1 "$0" {} \; ::: "$@"
  exit
fi

pkgdir="/usr/src/ports/cpan2cruxPorts/$1"

if [ ! -d "${pkgdir}" ]; then
  exit
fi

. ${pkgdir}/Pkgfile

unset remVer

for src in "${source[@]}"; do
  if [[ "${src}" != "http"*"cpan"* ]]; then
    continue
  fi
  dir="${src%/*}"
  fName="${src##*/}"
  fName="${fName%-*}"
  remVer="$(
    wget -O - "${dir}" 2> /dev/null | \
      tr '"' '\n' | \
      grep "^${fName}-[0-9.]\+\.tar\.gz$" | \
      sed "s|^${fName}-\([0-9.]\+\)\.tar\.gz$|\1|" | \
      sort -V | \
      tail -n1
  )"
  break
done

if [ "${remVer}" != "${version}" ]; then
  echo "${name}: ${remVer} vs. ${version}"
fi