#! /bin/sh # The name is a deliberate echo of the "real" Debian dinstall; it moves # packages into http://riva.ucam.org/~cjwatson/debian/, removes any old # versions of those packages there, and re-runs dpkg-myscan {packages,sources}. if [ $# -lt 2 ]; then echo "Usage: $0 package-name version-number" >&2 exit 1 fi PACKAGE=$1 VERSION=$2 UPSTREAM=`echo $VERSION | sed -e 's/-[^-]*$//'` NATIVE= if [ "$VERSION" = "$UPSTREAM" ]; then NATIVE=y fi echo -n "Dinstalling package $PACKAGE, " echo -n "version $VERSION, " echo "upstream version $UPSTREAM" [ "$NATIVE" ] && echo "Native Debian package" ARCH=i386 BINARCH=i386 DEB=$PWD/${PACKAGE}_${VERSION}_${BINARCH}.deb if [ ! -f $DEB ]; then BINARCH=all ALLDEB=$PWD/${PACKAGE}_${VERSION}_${BINARCH}.deb else ALLDEB=$DEB fi if [ "$NATIVE" ]; then ORIG=$PWD/${PACKAGE}_${VERSION}.tar.gz DIFF= else ORIG=$PWD/${PACKAGE}_${UPSTREAM}.orig.tar.gz DIFF=$PWD/${PACKAGE}_${VERSION}.diff.gz fi DSC=$PWD/${PACKAGE}_${VERSION}.dsc CHANGES=$PWD/${PACKAGE}_${VERSION}_${ARCH}.changes # Sanity checks ERROR= if [ ! -f $DEB -a ! -f $ALLDEB ]; then echo $DEB 'not found' >&2 [ $BINARCH = all ] && echo $ALLDEB 'not found' >&2 ERROR=1 fi DEB=$ALLDEB if [ ! -f $ORIG ]; then echo $ORIG 'not found' >&2; ERROR=1; fi if [ "$DIFF" -a ! -f "$DIFF" ]; then echo $DIFF 'not found' >&2 ERROR=1 fi if [ ! -f $DSC ]; then echo $DSC 'not found' >&2; ERROR=1; fi if [ ! -f $CHANGES ]; then echo $CHANGES 'not found' >&2; ERROR=1; fi [ "$ERROR" ] && exit 1 SECTION=`dpkg -f $DEB Section` if [ "$SECTION" ]; then echo "Section: $SECTION" else echo "Section not found." >&2 exit 1 fi if echo $SECTION | egrep -q '^(contrib|non-free)/'; then BINARYDIR=`echo $SECTION | sed -e "s|/|/binary-$BINARCH/|"` SOURCEDIR=`echo $SECTION | sed -e "s|/|/source/|"` elif echo $SECTION | egrep -q '^non-US/'; then BINARYDIR=$SECTION/binary-$BINARCH SOURCEDIR=$SECTION/source else BINARYDIR=main/binary-$BINARCH/$SECTION SOURCEDIR=main/source/$SECTION fi echo "Binaries in $BINARYDIR, sources in $SOURCEDIR" cd "$HOME/public_html/debian" ERROR= if [ ! -d $BINARYDIR ]; then echo 'Binary dir not found.' >&2; ERROR=1; fi if [ ! -d $SOURCEDIR ]; then echo 'Source dir not found.' >&2; ERROR=1; fi [ "$ERROR" ] && exit 1 shopt -s nullglob BINARIES=`echo $BINARYDIR/${PACKAGE}_*` if [ "$BINARIES" ]; then echo 'Binaries found in binary dir:' echo $BINARIES | xargs -n1 read -n1 -esp 'Remove: (y/N) ' REMOVE if [ "$REMOVE" = y ]; then echo -n 'Removing ... ' echo $BINARIES | xargs rm echo 'done.' else echo 'Aborting.' exit fi fi SOURCES=`echo $SOURCEDIR/${PACKAGE}_*` if [ "$SOURCES" ]; then echo 'Sources found in source dir:' echo $SOURCES | xargs -n1 read -n1 -esp 'Remove: (y/N) ' REMOVE if [ "$REMOVE" = y ]; then echo -n 'Removing ... ' echo $SOURCES | xargs rm echo 'done.' else echo 'Aborting.' exit fi fi echo "Moving $DEB to $BINARYDIR ..." mv -f $DEB $BINARYDIR echo "Copying $ORIG to $SOURCEDIR ..." cp -f $ORIG $SOURCEDIR if [ "$DIFF" ]; then echo "Copying $DIFF to $SOURCEDIR ..." cp -f $DIFF $SOURCEDIR fi echo "Moving $DSC to $SOURCEDIR ..." mv -f $DSC $SOURCEDIR echo "Moving $CHANGES to $SOURCEDIR ..." mv -f $CHANGES $SOURCEDIR echo dpkg-myscan packages echo dpkg-myscan sources echo echo -n 'Updating index.html ...' if [ "$NATIVE" ]; then perl -pi -l \ -e 's/('$PACKAGE'_).*?(_|\.dsc)/${1}'$VERSION'$2/;' \ -e 's/('$PACKAGE'_).*?(\.tar\.gz)/${1}'$VERSION'$2/;' index.html else perl -pi -l \ -e 's/('$PACKAGE'_).*?(_|\.diff\.gz|\.dsc)/${1}'$VERSION'$2/;' \ -e 's/('$PACKAGE'_).*?(\.orig\.tar\.gz)/${1}'$UPSTREAM'$2/;' index.html fi echo ' done.' echo "Dinstallation of $PACKAGE-$VERSION complete."