Package: devscripts
Version: 2.10.71
Severity: wishlist

The attached patch adds a --return option to cowpoke, that causes any
.deb and .changes files resulting from a build to be returned to the
current directory on completion of the build.

Note that to handle the case where multiple .deb files result from the
build of one .dsc, I've chosen to use patterns that looks like:

    *package_version*deb
    *package_version*changes

It is theoretically possible that this could return more results than
desired if multiple packages have been built with identical version
strings, but the only alternative would seem to be parsing the control
file in the package source to obtain a definitive list of binary package
names to look for, and that seems unnecessarily complicated.

Bdale

Attachment: pgpXLXmLCDAfL.pgp
Description: PGP signature

>From ea818a01d2a0a9abd145ae2fed114db9955493ec Mon Sep 17 00:00:00 2001
From: Bdale Garbee <bd...@gag.com>
Date: Sun, 20 Feb 2011 11:33:07 -0700
Subject: [PATCH] add a new --return option that pulls build results to current directory

---
 cowpoke.conf       |    3 +++
 scripts/cowpoke.1  |    5 +++++
 scripts/cowpoke.sh |   22 ++++++++++++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/cowpoke.conf b/cowpoke.conf
index 7a80a7f..18e203d 100644
--- a/cowpoke.conf
+++ b/cowpoke.conf
@@ -56,6 +56,9 @@ BUILDD_HOST=
 # debootstrap or cdebootstrap.
 #DEBOOTSTRAP="cdebootstrap"
 
+# If set to "yes", the .deb and .changes files resulting from the build 
+# will be returned to the current directory after the build completes.
+#RETURNRESULTS="no"
 
 # =============================================================================
 #
diff --git a/scripts/cowpoke.1 b/scripts/cowpoke.1
index c149d4f..eb3449e 100644
--- a/scripts/cowpoke.1
+++ b/scripts/cowpoke.1
@@ -60,6 +60,11 @@ is not passed it is an error for the specified \fB\-\-dist\fP or \fB\-\-arch\fP
 to not have an existing cowbuilder root in the expected location.
 
 .TP
+.B \-\-return
+Return the .deb and .changes files resulting from the build to the current
+directory after the build completes.
+
+.TP
 .BI \-\-dpkg\-opts= "'opt1 opt2 ...'"
 Specify additional options to be passed to \fBdpkg-buildpackage\fP(1).  Multiple
 options are delimited with spaces.  This will override any options specified in
diff --git a/scripts/cowpoke.sh b/scripts/cowpoke.sh
index 60a81ac..00d5a02 100755
--- a/scripts/cowpoke.sh
+++ b/scripts/cowpoke.sh
@@ -80,6 +80,7 @@ cowpoke [options] package.dsc
    --buildd="host"       Specify the remote host to build on.
    --buildd-user="name"  Specify the remote user to build as.
    --create              Create the remote cowbuilder root if necessary.
+   --return              Return results of the build to current directory.
 
   The current default configuration is:
 
@@ -130,6 +131,10 @@ for arg; do
 	    CREATE_COW="yes"
 	    ;;
 
+	--return)
+	    RETURNRESULTS="yes"
+	    ;;
+
 	--dpkg-opts=*)
 	    DEBBUILDOPTS="--debbuildopts \"${arg#*=}\""
 	    ;;
@@ -311,6 +316,23 @@ ssh -t "$BUILDD_USER$BUILDD_HOST" "\"$INCOMING_DIR/$REMOTE_SCRIPT\" && rm -f \"$
 echo
 echo "Build completed."
 
+if [ "$RETURNRESULTS" = "yes" ]; then
+    for arch in $BUILDD_ARCH; do
+      for dist in $BUILDD_DIST; do
+
+	RESULT_DIR="$(eval echo "\$${arch}_${dist}_RESULT_DIR")"
+	[ -n "$RESULT_DIR" ] || RESULT_DIR="$PBUILDER_BASE/$arch/$dist/result"
+	RESULTVER="$(eval echo $DSC | cut -d '_' -f 2 | sed -e 's/.dsc//')"
+	RESULTS="$(eval ssh "$BUILDD_USER$BUILDD_HOST" "ls $RESULT_DIR/*$RESULTVER*deb $RESULT_DIR/*$RESULTVER*changes")"
+
+	for result in $RESULTS; do
+	  dcmd scp "$BUILDD_USER$BUILDD_HOST:$result" .
+        done
+
+      done
+    done
+fi
+
 if [ -n "$SIGN_KEYID" ]; then
     for arch in $BUILDD_ARCH; do
       CHANGES="$arch.changes"
-- 
1.7.4.1

Reply via email to