#! /bin/sh

cd `dirname $0`

for RELEASE in stable unstable common
#for RELEASE in unstable
do
    if [ ! -s $RELEASE/apt-release.conf ]
    then
        echo "Not repo directory"
        exit 1
    fi


    echo $RELEASE Packages; apt-ftparchive packages $RELEASE > $RELEASE/Packages
    echo $RELEASE Sources; apt-ftparchive sources $RELEASE > $RELEASE/Sources
    echo $RELEASE Contents-amd64; apt-ftparchive contents $RELEASE > $RELEASE/Contents-amd64
    for COMP in Packages Sources Contents-amd64
    do
	echo "$RELEASE $COMP.xz"
	xz -kf $RELEASE/$COMP
    done

    apt-ftparchive -c $RELEASE/apt-release.conf release $RELEASE > $RELEASE/Release
    rm -f $RELEASE/InRelease $RELEASE/Release.gpg
    gpg --clearsign --digest-algo SHA512 -o $RELEASE/InRelease $RELEASE/Release && gpg -abs -o $RELEASE/Release.gpg $RELEASE/Release

done
