[Pkg-haskell-commits] darcs: tools: Add debian2dsc

Joachim Breitner mail at joachim-breitner.de
Sat Oct 13 21:46:52 UTC 2012


Sat Oct 13 21:41:56 UTC 2012  Joachim Breitner <mail at joachim-breitner.de>
  * Add debian2dsc
  Ignore-this: cac810345a367f5df891e9a6b8a7baf8

    A ./debian2dsc.sh

Sat Oct 13 21:41:56 UTC 2012  Joachim Breitner <mail at joachim-breitner.de>
  * Add debian2dsc
  Ignore-this: cac810345a367f5df891e9a6b8a7baf8
diff -rN -u old-tools//debian2dsc.sh new-tools//debian2dsc.sh
--- old-tools//debian2dsc.sh	1970-01-01 00:00:00.000000000 +0000
+++ new-tools//debian2dsc.sh	2012-10-13 21:46:52.370723748 +0000
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+set -e
+
+until [ -z "$1" ]
+do
+    case "$1" in
+        *)
+            DIRS="$DIRS $1"
+            ;;
+    esac
+    shift
+done
+
+if [ -z "$DIRS" ]
+then 
+   echo "Usage: $0 [dir ...]"
+   exit 1
+fi
+
+for DIR in $DIRS
+do
+    if [ ! -e $DIR/control -o ! -e $DIR/changelog ]
+    then
+      echo "Did not find $DIR/control or $DIR/changelog."
+      echo "Is the repository in the debian/-only format?"
+      exit 1
+    fi
+
+    VERSION=`dpkg-parsechangelog -l$DIR/changelog -c1 | grep-dctrl -n -s Version .`
+    PACKAGE=`dpkg-parsechangelog -l$DIR/changelog -c1 | grep-dctrl -n -s Source .`
+    UPSTREAM=`echo $VERSION | cut -d- -f1` # this could be improved
+    if echo $UPSTREAM | fgrep -q : ; then
+    	UPSTREAM=`echo $UPSTREAM | cut -d: -f2-`
+    fi
+    TARBALL_GZ=${PACKAGE}_$UPSTREAM.orig.tar.gz
+    TARBALL_BZ2=${PACKAGE}_$UPSTREAM.orig.tar.bz2
+    TARBALL_XZ=${PACKAGE}_$UPSTREAM.orig.tar.xz
+    # see 375138 for why this doesn't work as well as it could. Fall back to apt-get source
+    # as a last resort.
+    [ ! -e $TARBALL_GZ -a ! -e $TARBALL_BZ2 -a ! -e $TARBALL_XZ ] && \
+       ( uscan \
+        --rename \
+        --force-download \
+        --package "$PACKAGE" \
+        --download \
+        --watchfile $DIR/watch \
+        --download-version "$UPSTREAM" \
+        --upstream-version "$UPSTREAM" \
+        --destdir . \
+	--rename ||
+        apt-get source "$PACKAGE" --tar-only )
+
+    if [ ! -e $TARBALL_GZ -a ! -e $TARBALL_BZ2 -a ! -e $TARBALL_XZ ]
+    then
+      echo "Couldn't download tarball with uscan or apt-get source. See above for errors"
+      exit 1
+    fi
+
+    TARBALL=""
+
+    if [ -e $TARBALL_GZ ]
+    then
+    	TARBALL="$TARBALL_GZ"
+    else
+    	if [ -e $TARBALL_XZ ]
+	then
+	    TARBALL="$TARBALL_XZ"
+	else
+	    if [ -e $TARBALL_BZ2 ]
+	    then
+		TARBALL="$TARBALL_BZ2"
+	    else
+		echo "Unreachable code"
+		exit 1
+	    fi
+	fi
+    fi
+    
+    DEBIAN_TARBALL=${PACKAGE}_${VERSION}.debian.tar.gz
+    tar --create --gzip --transform s,^.,debian, --file $DEBIAN_TARBALL --directory $DIR .
+    dpkg-source \
+	-c$DIR/control -l$DIR/changelog \
+	--format="3.0 (custom)" --target-format="3.0 (quilt)" \
+	-b / \
+	$DEBIAN_TARBALL \
+	$TARBALL
+
+    DSC=${PACKAGE}_${VERSION}.dsc
+    if [ -e $DSC ]
+    then
+	echo "Successfully created $DSC."
+    else
+	echo "Failed to create $DSC."
+    fi
+done





More information about the Pkg-haskell-commits mailing list