From esselfe, 5 Years ago, written in Plain Text.
Embed
  1. SRCNAME="$1"
  2. SRCURL="ftp://mirror.vexxhost.com/gnu"
  3. PKGDIR=/pkg
  4. [ -f $SRCNAME-index.html ] || wget $SRCURL/$SRCNAME/ -O $SRCNAME-index.html
  5. cat $SRCNAME-index.html |tail -n+10  |grep .xz |sed -e '/^$/d' -e 's/^.*grep/grep/' -e 's/<.*//' \
  6.                 -e '/.*sig/d' -e 's/grep-//' > $SRCNAME-files.txt
  7.         MAJOR=$(cat $SRCNAME-files.txt |awk -F'.' '{ print $1 }' |tail -n1)
  8.         grep -e "^$MAJOR." $SRCNAME-files.txt > $SRCNAME-major.txt
  9.         MINOR=$(cat $SRCNAME-major.txt |awk -F'.' '{ print $2 }' |sort -n |tail -n1)
  10.         grep -e "^$MAJOR.$MINOR." $SRCNAME-major.txt > $SRCNAME-minor.txt
  11.         REVISION=$(cat $SRCNAME-minor.txt |awk -F'.' '{ print $3 }' |sort -n |tail -n1)
  12.         if [ $REVISION = [[:digit:]] ]; then
  13.                 FILENAME=$SRCNAME-$(grep "$MAJOR.$MINOR.$REVISION" $SRCNAME-minor.txt)
  14.         else
  15.                 FILENAME=$SRCNAME-$(grep "$MAJOR.$MINOR" $SRCNAME-minor.txt)
  16.         fi
  17.         [ -f $PKGDIR/$FILENAME ] ||
  18.                 wget $SRCURL/$SRCNAME/$FILENAME -O $PKGDIR/$FILENAME
  19.         rm $SRCNAME-{index,files,major,minor}*