#! /bin/sh # The name is a deliberate echo of the "real" Debian dinstall; it moves # packages into /usr/src/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/-[^-]*$//'` echo -n "Dinstalling package $PACKAGE, " echo -n "version $VERSION, " echo "upstream version $UPSTREAM" ARCH=i386 DEB=$PWD/${PACKAGE}_${VERSION}_${ARCH}.deb ORIG=$PWD/${PACKAGE}_$UPSTREAM.orig.tar.gz DIFF=$PWD/${PACKAGE}_${VERSION}.diff.gz DSC=$PWD/${PACKAGE}_${VERSION}.dsc CHANGES=$PWD/${PACKAGE}_${VERSION}_${ARCH}.changes # Sanity checks ERROR= if [ ! -f $DEB ]; then echo $DEB 'not found' >&2; ERROR=1; fi if [ ! -f $ORIG ]; then echo $ORIG 'not found' >&2; ERROR=1; fi if [ ! -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-$ARCH/|"` SOURCEDIR=`echo $SECTION | sed -e "s|/|/source/|"` elif echo $SECTION | egrep -q '^non-US/'; then BINARYDIR=$SECTION/binary-$ARCH SOURCEDIR=$SECTION/source else BINARYDIR=main/binary-$ARCH/$SECTION SOURCEDIR=main/source/$SECTION fi echo "Binaries in $BINARYDIR, sources in $SOURCEDIR" cd /usr/src/debian/dists/unstable 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 echo "Copying $DIFF to $SOURCEDIR ..." cp -f $DIFF $SOURCEDIR echo "Moving $DSC to $SOURCEDIR ..." mv -f $DSC $SOURCEDIR echo "Moving $CHANGES to $SOURCEDIR ..." mv -f $CHANGES $SOURCEDIR echo cd ../.. dpkg-myscan packages echo dpkg-myscan sources echo echo "Dinstallation of $PACKAGE-$VERSION complete."