[pkg-haskell-tools] 05/06: New script: debian2dsc
Joachim Breitner
nomeata at moszumanska.debian.org
Thu Aug 13 11:47:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
nomeata pushed a commit to branch master
in repository pkg-haskell-tools.
commit d27091ee69daf68b890278f624e205e10354a23b
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Thu Aug 13 13:44:14 2015 +0200
New script: debian2dsc
---
.gitignore | 1 +
debian/changelog | 1 +
debian/docs | 1 +
debian/rules | 5 +-
scripts/debian2dsc | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 165 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index a3661ee..81a32a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
debian/dht.1
dist/
+debian/dht.html
diff --git a/debian/changelog b/debian/changelog
index d2a5829..c07fd9c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ pkg-haskell-tools (0.2) UNRELEASED; urgency=medium
* Use pandoc instead of help2man
* New script: what-to-build
* New script: what-to-upgrade
+ * New script: debian2dsc
-- Joachim Breitner <nomeata at debian.org> Thu, 13 Aug 2015 13:20:44 +0200
diff --git a/debian/docs b/debian/docs
new file mode 100644
index 0000000..a096edc
--- /dev/null
+++ b/debian/docs
@@ -0,0 +1 @@
+debian/dht.html
diff --git a/debian/rules b/debian/rules
index dcd3930..287cb40 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,7 +5,10 @@ DEB_DEFAULT_COMPILER = ghc
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/hlibrary.mk
-build/pkg-haskell-tools:: build-ghc-stamp debian/dht.1
+build/pkg-haskell-tools:: build-ghc-stamp debian/dht.1 debian/dht.html
+
+debian/dht.html: dht scripts/*
+ ./dht --manpage | pandoc -f markdown -s -t html > $@
debian/dht.1: dht scripts/*
./dht --manpage | pandoc -f markdown -s -t man > $@
diff --git a/scripts/debian2dsc b/scripts/debian2dsc
new file mode 100755
index 0000000..24cdb1d
--- /dev/null
+++ b/scripts/debian2dsc
@@ -0,0 +1,158 @@
+#!/bin/sh
+
+set -e
+
+usage() {
+ cat <<'__END__'
+debian2dsc - generate a dsc file from a debian directory
+
+Usage: dht debian2dsc [-o output/] [dir ...]
+
+Expects directories containing the contents of the debian/ directory of a
+Debian source package (i.e. control, changelog, watch, ...). Uses the watch
+file to retrieve the upstream tarball (unless it already exists in the local
+directory), creates a debian.tar.xz tarball from the given directory (ignoring
+the ususal suspects like _darcs and *~) and creates a corresponding .dsc file;
+all without unpacking the upstream tarball.
+__END__
+}
+
+manpage() {
+ cat <<'__END__'
+Usage: dht debian2dsc [-o output/] [dir ...]
+
+Expects directories containing the contents of the `debian/` directory of a
+Debian source package (i.e. `control`, `changelog`, `watch`, ...). Uses the watch
+file to retrieve the upstream tarball (unless it already exists in the local
+directory), creates a `debian.tar.xz` tarball from the given directory (ignoring
+the ususal suspects like `_darcs` and `*~`) and creates a corresponding `.dsc` file;
+all without unpacking the upstream tarball.
+__END__
+}
+
+if [ "$1" = "--help" ]
+then
+ usage
+ exit 0
+fi
+
+if [ "$1" = "--manpage" ]
+then
+ manpage
+ exit 0
+fi
+
+
+if [ "$1" = "-o" ]
+then
+ shift
+ dest="$1"
+ shift
+else
+ dest="."
+fi
+
+until [ -z "$1" ]
+do
+ case "$1" in
+ *)
+ DIRS="$DIRS $1"
+ ;;
+ esac
+ shift
+done
+
+if [ -z "$DIRS" ]
+then
+ 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 -SVersion`
+ PACKAGE=`dpkg-parsechangelog -l$DIR/changelog -c1 -SSource`
+ UPSTREAM=`echo $VERSION | cut -d- -f1` # this could be improved
+ if echo $UPSTREAM | fgrep -q : ; then
+ UPSTREAM=`echo $UPSTREAM | cut -d: -f2-`
+ VERSION=`echo $VERSION | cut -d: -f2-`
+ fi
+ TARBALL_GZ=$dest/${PACKAGE}_$UPSTREAM.orig.tar.gz
+ TARBALL_BZ2=$dest/${PACKAGE}_$UPSTREAM.orig.tar.bz2
+ TARBALL_XZ=$dest/${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 \
+ --copyright-file $DIR/copyright \
+ --download-version "$UPSTREAM" \
+ --upstream-version "$UPSTREAM" \
+ --destdir "$dest" \
+ --rename ||
+ ( cd $dest ; 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=$dest/${PACKAGE}_${VERSION}.debian.tar.xz
+ # -I line taken from "man dpkg-source"
+ tar --create \
+ --xz \
+ --transform s,^.,debian, \
+ --force-local \
+ --file $DEBIAN_TARBALL \
+ --directory $DIR \
+ "--exclude=*.a" "--exclude=*.la" "--exclude=*.o" "--exclude=*.so" "--exclude=.*.sw?" "--exclude=*/*~" "--exclude=,,*" "--exclude=.[#~]*" "--exclude=.arch-ids" "--exclude=.arch-inventory" "--exclude=.be" "--exclude=.bzr" "--exclude=.bzr.backup" "--exclude=.bzr.tags" "--exclude=.bzrignore" "--exclude=.cvsignore" "--exclude=.deps" "--exclude=.git" "--exclude=.gitattributes" "--exclude=.gitignore" "--exclude=.gitmodules" "--exclude=.hg" "--exclude=.hgignore" "--exclude=.hgsigs" "--exclude=. [...]
+ .
+
+ # dpkg-source insists on cluttering the current directory
+ 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
+ mv $DSC "$dest/$DSC"
+ echo "Successfully created $DSC."
+ else
+ echo "Failed to create $DSC."
+ fi
+done
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/pkg-haskell-tools.git
More information about the Pkg-haskell-commits
mailing list