#!/bin/sh
+
+# The location of the sources
SOURCES=sources/equivs
-PACKAGES=public/packages
+# The codename of the archive to import into
+CODENAME=stderr
-mkdir -p $PACKAGES
+# Save the root of the repository
+cd `dirname $0`
+REPO_ROOT=`pwd`
-cd $PACKAGES
+# Create our output dir
+OUT_DIR=`mktemp -d` || exit 1
+cd $OUT_DIR
-for i in ../../$SOURCES/*; do
+for i in $REPO_ROOT/$SOURCES/*; do
BASE=`basename "$i"`
if [ -d "$i" ]; then
echo "Skipping directory '$BASE'"
echo "Skipping non-equivs file '$BASE'"
continue;
fi
- if [ -f "${PACKAGE}_${VERSION}_all.deb" ]; then
- echo "Skipping $PACKAGE, version $VERSION already built"
- continue;
+
+ # Find out what the current repostory version is. We simply take the
+ # first of the architectures in the output, since these are
+ # architecture all packages and should have the same version on all
+ # archs.
+ REPO_VERSION=`$REPO_ROOT/reprepro list "${CODENAME}" "${PACKAGE}" | head -1 | cut -d' ' -f 3`
+ if dpkg --compare-versions "${REPO_VERSION}" ge "${VERSION}"; then
+ echo "Not building version $VERSION of $PACKAGE, version $REPO_VERSION already in repository"
+ continue
fi
echo "Building version $VERSION of $PACKAGE"
- equivs-build $i
+ equivs-build $i || exit 1
+
+ # Import the produced deb
+ $REPO_ROOT/reprepro includedeb "${CODENAME}" "${PACKAGE}_${VERSION}_all.deb" || exit 1
done
-cd ../..
+# Conservatively delete our temporary directory (To prevent issues when
+# $OUT_DIR got set to / for some reason or something like that)
+cd /
+rm -f $OUT_DIR/*.deb
+rmdir $OUT_DIR