#!/bin/sh # Usage: dasource [-r REPOS] [PACKAGENAME ...] # Creates or updates a checkout and source package for each listed # PACKAGENAME, or for all regular packages if no PACKAGENAME is # specified. # If REPOS is specified, it is used in preference to the canonical # Athena repository trunk. # Package subdirectories are created in the cwd. The source checkout # will reside in PACKAGENAME/PACKAGENAME-VERSION and the source # package will be created in PACKAGENAME. set -e : ${DEBATHENA_APT=/mit/debathena/apt} basedir=$(dirname "$0") pkgfile=$basedir/packages repo=svn+ssh://svn.mit.edu/athena/trunk while getopts r: opt; do case "$opt" in r) type="$OPTARG" ;; \?) echo "$usage" exit 1 ;; esac done die() { echo "$@" >&2 exit 1 } do_package() { pkgname=$1 pkgpath=$2 if [ ! -d $pkgname ]; then echo "Creating directory $pkgname" mkdir $pkgname fi # Check out or update the package source. if [ $(echo $pkgname/$pkgname-* | wc -w) -gt 2 ]; then die "More than one checkout under $pkgname!" elif [ -d $pkgname/$pkgname-* ]; then dir=$(echo $pkgname/$pkgname-*) echo "Updating and cleaning $dir" (cd $dir && svn update && svn revert -R . && svn st | awk '/^?/ {print $2}' | xargs rm -vrf) else dir=$pkgname/$pkgname echo "Checking out $repo/$pkgpath into $dir" svn co $repo/$pkgpath $dir fi # Extract the changelog version and strip off the epoch and Debian component. changever=$(cd $dir && dpkg-parsechangelog | sed -n 's/Version: //p') sver=$(echo $changever | sed -re 's/^[0-9]+://p') upver=$(echo $sver | sed -re 's/-[^-]*$//') # Rename the source checkout if necessary. correctdir=$pkgname/${pkgname}-$upver if [ $dir != $correctdir ]; then echo "Renaming $dir to $correctdir" mv $dir $correctdir dir=$correctdir fi # Add autoconf goo if it's an Athena source directory. case $pkgpath in athena/*) (cd $dir && $basedir/daconfiscate) ;; esac # If the version has a debian component then we need an orig archive. if [ $sver != $upver ]; then tarfile=${pkgname}_$upver.orig.tar.gz if [ ! -e $pkgname/$tarfile ]; then aptorig=$(find ${DEBATHENA_APT}*/pool -name $tarfile | head -1) if [ -n "$aptorig" ]; then echo "Copying existing $aptorig to original source" cp $aptorig $pkgname/$tarfile else echo "Creating original source archive" (cd $pkgname && tar --exclude=.svn --exclude=debian $correctname -czf \ $tarfile ${pkgname}-$upver) fi fi fi # Build an unsigned package, ignoring version control subdirs in the source. echo "Creating source package" (cd $dir && debuild -S -i -I -sa -us -uc) } if [ $# -gt 0 ]; then # Build specific source packages. for pkgname; do pkgpath=$(sed -nre "s/^$pkgname[[:space:]]+//p" $pkgfile) [ -n "$pkgpath" ] || die "Can't find package $pkgname" do_package $pkgname $pkgpath done else # Build all source packages. exec <$pkgfile while read pkgname pkgpath; do do_package $pkgname $pkgpath done fi