#!/bin/sh
#
#

ISSUE="$1"

if [ "${ISSUE}x" = x ];then
    echo "$0 <PTF number>"
    exit 1
fi

LISTFILE="/etc/apt/sources.list.d/benno-${ISSUE}.list"

if [ -e ${LISTFILE} ];then
    echo "File exists: ${LISTFILE}. Exit."
    exit 2
fi

echo "deb http://build.lw-systems.net/snapshot/${ISSUE} /" > ${LISTFILE}

apt-get update

PKGLIST="$(curl -s http://build.lw-systems.net/snapshot/fs984/Packages | grep ^Package: | cut -d ' ' -f 2)"

for PKGNAME in $(echo -n ${PKGLIST}); do
    PACKAGES="${PACKAGES} ${PKGNAME}"
done

apt-get -y install ${PACKAGES}

/bin/rm ${LISTFILE}
apt-get update

