File update.sh of Package fakePackman

#!/bin/bash

BASENAME=$(basename ${PWD})
MODULE=${BASENAME%-*}
DIST=${BASENAME##*-}
if [[ ${MODULE} =~ [0-9]-devel$ ]]; then
  FILES="^${MODULE} ^${MODULE%-devel}-[0-9]\\+"
else
  FILES="^${MODULE} ^${MODULE%-devel}[0-9]\\+"
fi
SUBREPO=Essentials
#URL='ftp://packman.mirrors.skynet.be/pub/packman/suse/'
#URL='ftp://ftp.halifax.rwth-aachen.de/packman/suse/'
#URL='ftp://packman.unixheads.com/packman/suse/'
URL='ftp://packman.links2linux.org/pub/packman/suse/'
[ -f update-data ] && . update-data

#for DIST in $@; do
  NEW=0
  for ARCH in i586 x86_64; do
    URLS=
    echo Starting ${DIST}-${ARCH}
    CONTENTS=$(curl -l -s -S "${URL}${DIST}/${SUBREPO}/${ARCH}/")
    CANDIDATES=$(echo "${CONTENTS}" | grep "^${MODULE}-[0-9]")
    for CANDIDATE in ${CANDIDATES}; do
      URLS="${URLS} ${URL}${DIST}/${SUBREPO}/${ARCH}/$CANDIDATE"
    done
    VERSION=$(rpm -qp --qf '%{BUILDTIME} -> %{VERSION}-%{RELEASE}\n' ${URLS} | sort -nr | head -n1)
    BUILDTIME=${VERSION%% -> *}
    VERSION=${VERSION##* -> }
    if [ -f buildtime.${DIST}-${ARCH} ]; then
      if [ ${BUILDTIME} -le $(cat buildtime.${DIST}-${ARCH}) ]; then
        if [ ${BUILDTIME} -lt $(cat buildtime.${DIST}-${ARCH}) ]; then
          echo "Older version in FTP!!"
        fi
        continue;
      fi
    fi
    echo "New version: ${DIST}-${ARCH}"
    NEW=1

    URLS=
    for FILE in ${FILES}; do
      PARAM="${PARAM} -e ${FILE}-${VERSION}.${ARCH}.rpm$"
    done
    mkdir -p ${DIST}
    LIST=$(echo "${CONTENTS}" | grep ${PARAM})
    if [ -f postproc_list ]; then
      . postproc_list
      postproc_list "$LIST"
    fi    
    for FILE in ${LIST}; do
      URLS="${URLS} ${URL}${DIST}/${SUBREPO}/${ARCH}/${FILE}"
    done
    cd ${DIST}
    wget -q ${URLS}
    cd ..
    echo ${BUILDTIME} > buildtime.${DIST}-${ARCH}
    touch -d "20010101" buildtime.${DIST}-${ARCH}
  done
  if [ ${NEW} -eq 1 ]; then
    ../packman2obs.sh ${DIST}
  fi
  rm -rf ${DIST}
#done

echo Finished
openSUSE Build Service is sponsored by