control: tag 622561 patch

This bug has been around ...

I think we should be able to 
 * select upstream tarballs by --tar  or --orig
   This should not include debian.tar.*
   For multiple upstream tar, it should include all of them.
 * select Debian changes    by --diff or --debtar

(Basically --orig and --debtar are alias for 3.0 format)

This is more natural to me.

Also, it would be nice to be able to filter filename into package name
part only.  So we can do things like "dcmd --deb --package dpkg -P".

Oh, it is even nicer to be able to sort output alphabetically etc.

Here is a patch to do this all and its updated manpage.

(I skipped debian.tar.lzma since I never saw it.)

Osamu


diff -Nru devscripts-2.14.5.orig/scripts/dcmd.1 devscripts-2.14.5/scripts/dcmd.1
--- devscripts-2.14.5.orig/scripts/dcmd.1	2014-07-12 22:00:39.773397709 +0900
+++ devscripts-2.14.5/scripts/dcmd.1	2014-07-12 22:07:59.738848882 +0900
@@ -48,10 +48,10 @@
 Select \fI.udeb\fR binary packages. Implies \fB\-\-archudeb\fR and \fB\-\-indepudeb\fR.
 .TP
 .BR \-\-tar ,\  \-\-orig
-Select the \fI.tar\fR file.
+Select the upstream \fI.tar\fR file.
 .TP
-.B \-\-diff
-Select the Debian \fI.diff\fR file.
+.BR \-\-diff ,\  \-\-debtar
+Select the Debian \fI.debian.tar\fR or \fI.diff\fR file.
 .PP
 Each option may be prefixed by \fB\-\-no\fR to indicate that all files
 \fInot\fR matching the specification should be selected.
@@ -62,6 +62,16 @@
 .TP
 .B \-\-no\-fail\-on\-missing\fR, \fB\-r
 If any of the requested files were not found, do not output an error.
+.TP
+.B \-\-package\fR, \fB\-p
+Output package name part only.
+.TP
+.B \-\-sort\fR, \fB\-s
+Sort output alphabetically.
+.TP
+.B \-\-tac\fR, \fB\-t
+Reverse output order.
+
 .SH "EXAMPLES"
 Copy the result of a build to another machine:
 
diff -Nru devscripts-2.14.5.orig/scripts/dcmd.sh devscripts-2.14.5/scripts/dcmd.sh
--- devscripts-2.14.5.orig/scripts/dcmd.sh	2014-07-12 10:37:37.159986956 +0900
+++ devscripts-2.14.5/scripts/dcmd.sh	2014-07-12 22:27:27.879656191 +0900
@@ -80,6 +80,9 @@
 DSC=1; BCHANGES=1; SCHANGES=1; ARCHDEB=1; INDEPDEB=1; TARBALL=1; DIFF=1
 CHANGES=1; DEB=1; ARCHUDEB=1; INDEPUDEB=1; UDEB=1;
 FILTERED=0; FAIL_MISSING=1
+EXTRACT_PACKAGE_NAME=0
+SORT=0
+TAC=0
 
 while [ $# -gt 0 ]; do
     TYPE=""
@@ -88,6 +91,9 @@
 	--help|-h) usage; exit 0;;
 	--no-fail-on-missing|-r) FAIL_MISSING=0;;
 	--fail-on-missing) FAIL_MISSING=1;;
+	--package|-p) EXTRACT_PACKAGE_NAME=1;;
+	--sort|-s) SORT=1;;
+	--tac|-t) TAC=1;;
 	--) shift; break;;
 	--no-*)
 	    TYPE=${1#--no-}
@@ -127,7 +133,7 @@
 	archudeb) [ "$FILTERED" = "1" ] && ARCHUDEB=1 || ARCHUDEB=0;;
 	indepudeb) [ "$FILTERED" = "1" ] && INDEPUDEB=1 || INDEPUDEB=0;;
 	tar|orig) [ "$FILTERED" = "1" ] && TARBALL=1 || TARBALL=0;;
-	diff) [ "$FILTERED" = "1" ] && DIFF=1 || DIFF=0;;
+	diff|debtar) [ "$FILTERED" = "1" ] && DIFF=1 || DIFF=0;;
 	*) echo "$PROGNAME: Unknown option '$1'" >&2; exit 1;;
     esac
     shift
@@ -175,6 +181,12 @@
 		[ "$ARCHUDEB" = "0" ] || echo "newarg=\"\$newarg
 $THISARG\";"
 		echo "SEEN_ARCHUDEB=1;"
+	    elif endswith "$THISARG" .debian.tar.gz || \
+		 endswith "$THISARG" .debian.tar.xz || \
+		 endswith "$THISARG" .debian.tar.bz2; then
+		[ "$DIFF" = "0" ] || echo "newarg=\"\$newarg
+$THISARG\";"
+		echo "SEEN_DIFF=1;"
 	    elif endswith "$THISARG" .tar.gz || \
 		 endswith "$THISARG" .tar.xz || \
 		 endswith "$THISARG" .tar.lzma || \
@@ -265,7 +277,7 @@
 		MISSING=1; echo "$arg: upstream tar not found" >&2
 	    fi
 	    if [ "$DIFF" = "1" ] && [ "$SEEN_DIFF" = "0" ]; then
-		MISSING=1; echo "$arg: Debian diff not found" >&2
+		MISSING=1; echo "$arg: Debian debian.tar/diff not found" >&2
 	    fi
 
 	    [ "$MISSING" = "0" ] || exit 1
@@ -280,6 +292,20 @@
 
 IFS='
 '
+if [ "$EXTRACT_PACKAGE_NAME" = "1" ]; then
+    packages=""
+    for arg in $args; do
+        packages="$packages
+$(echo "$arg" |sed s/_.*//)"
+    done
+    args="$packages"
+fi
+if [ "$SORT" = "1" ]; then
+    args="$(echo "$args"| sort -)"
+fi
+if [ "$TAC" = "1" ]; then
+    args="$(echo "$args"| tac -)"
+fi
 if [ -z "$cmd" ]; then
     for arg in $args; do
 	echo $arg

Reply via email to