Author: adsb
Date: 2008-11-17 18:32:52 +0000 (Mon, 17 Nov 2008)
New Revision: 1727
Modified:
trunk/debian/changelog
trunk/scripts/dcmd.1
trunk/scripts/dcmd.sh
Log:
dcmd: Allow only a subset of the files listed in the .changes / .dsc
file to be selected. (Closes: #481415)
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-11-16 19:43:18 UTC (rev 1726)
+++ trunk/debian/changelog 2008-11-17 18:32:52 UTC (rev 1727)
@@ -22,6 +22,8 @@
+ Add an updated check for $'' which is much less prone to false
positives. Thanks Filippo Giunchedi. (Closes: #504292)
+ Add an updated check for $"" based on Filippo's $'' patch.
+ * dcmd: Allow only a subset of the files listed in the .changes / .dsc
+ file to be selected. (Closes: #481415)
* Debbugs.pm:
+ Really fix the special-casing of the "archive" key in select() to
get rid of an uninitialized value warning.
Modified: trunk/scripts/dcmd.1
===================================================================
--- trunk/scripts/dcmd.1 2008-11-16 19:43:18 UTC (rev 1726)
+++ trunk/scripts/dcmd.1 2008-11-17 18:32:52 UTC (rev 1727)
@@ -2,7 +2,8 @@
.SH NAME
dcmd \- expand file lists of .dsc/.changes files in the command line
.SH SYNOPSIS
-\fBdcmd\fR [\fIcommand\fR] [\fIchanges-file\fR|\fIdsc-file\fR] [\fI...\fR]
+\fBdcmd\fR [\fIoptions\fR] [\fIcommand\fR] [\fIchanges-file\fR|\fIdsc-file\fR]
+[\fI...\fR]
.SH DESCRIPTION
\fBdcmd\fR replaces any reference to a .dsc or .changes file in the
command line with the list of files in its 'Files' section, plus the
@@ -12,6 +13,47 @@
If \fIcommand\fR is omitted (that is the first argument is an existing .dsc
or .changes file), the expanded list of files is printed to stdout, one file
by line. Useful for usage in backticks.
+.SH OPTIONS
+There are a number of options which may be used in order to select only a
+subset of the files listed in the .dsc or .changes file. If a requested file
+is not found, an error message will be printed.
+.TP 14
+.B \-\-dsc
+Select the .dsc file.
+.TP
+.B \-\-schanges
+Select .changes files for the 'source' architecture.
+.TP
+.B \-\-bchanges
+Select .changes files for binary architectures.
+.TP
+.B \-\-changes
+Select .changes files. Implies \-\-schanges and \-\-bchanges.
+.TP
+.B \-\-archdeb
+Select architecture-dependent binary packages (.deb files).
+.TP
+.B \-\-indepdeb
+Select architecture-independent binary packages (.deb files).
+.TP
+.B \-\-deb
+Select binary packages (.deb files). Implies \-\-archdeb and \-\-indepdeb.
+.TP
+.B \-\-tar, \-\-orig
+Select the tar file.
+.TP
+.B \-\-diff
+Select the Debian diff file.
+.PP
+Each option may be prefixed by \fB\-\-no\fR to indicate that all files
+\fInot\fR matching the specification should be selected.
+.PP
+It is not possible to combine positive filtering options (e.g. \-\-dsc)
+and negative filtering options (e.g. \-\-no\-changes) in the same
+\fBdcmd\fR invocation.
+.TP
+.B \-\-no\-fail\-on\-missing, \-r
+If any of the requested files were not found, do not output an error.
.SH "EXAMPLES"
Copy the result of a build to another machine:
@@ -22,6 +64,11 @@
rcs_5.7-23_amd64.deb 100% 363KB 362.7KB/s 00:00
rcs_5.7-23_amd64.changes 100% 1095 1.1KB/s 00:00
$
+
+$ dcmd --diff --deb scp rcs_5.7-23_amd64.changes elegiac:/tmp
+rcs_5.7-23.diff.gz 100% 12KB 11.7KB/s 00:00
+rcs_5.7-23_amd64.deb 100% 363KB 362.7KB/s 00:00
+$
.fi
Check the contents of a source package:
@@ -32,6 +79,11 @@
f0ceeae96603e823eacba6721a30b5c7 rcs_5.7-23.diff.gz
5241db1e231b1f43ae5514b63d2523f8 rcs_5.7-23.dsc
$
+
+$ dcmd --no-diff md5sum rcs_5.7-23.dsc
+8fd09ea9654cda128f8d5c337d3b8de7 rcs_5.7.orig.tar.gz
+5241db1e231b1f43ae5514b63d2523f8 rcs_5.7-23.dsc
+$
.fi
.SH "SEE ALSO"
Modified: trunk/scripts/dcmd.sh
===================================================================
--- trunk/scripts/dcmd.sh 2008-11-16 19:43:18 UTC (rev 1726)
+++ trunk/scripts/dcmd.sh 2008-11-17 18:32:52 UTC (rev 1727)
@@ -4,6 +4,7 @@
#
# Copyright (C) 2008 Romain Francoise <[EMAIL PROTECTED]>
# Copyright (C) 2008 Christoph Berg <[EMAIL PROTECTED]>
+# Copyright (C) 2008 Adam D. Barratt <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -45,7 +46,7 @@
usage()
{
- printf "Usage: %s [command] [dsc or changes file] [...]\n" $PROGNAME
+ printf "Usage: %s [options] [command] [dsc or changes file] [...]\n"
$PROGNAME
}
endswith()
@@ -71,17 +72,156 @@
fi
}
-if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then
- version
- exit 0
-elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
- usage
- exit 0
-fi
+DSC=1; BCHANGES=1; SCHANGES=1; ARCHDEB=1; INDEPDEB=1; TARBALL=1; DIFF=1
+CHANGES=1; DEB=1
+FILTERED=0; FAIL_MISSING=1
+while [ $# -gt 0 ]; do
+ TYPE=""
+ case "$1" in
+ --version|-v) version; exit 0;;
+ --help|-h) usage; exit 0;;
+ --no-fail-on-missing|-r) FAIL_MISSING=0;;
+ --fail-on-missing) FAIL_MISSING=1;;
+ --) shift; break;;
+ --no-*)
+ TYPE=${1#--no-}
+ case "$FILTERED" in
+ 1) echo "$PROGNAME: Can't combine --foo and --no-foo options"
>&2;
+ exit 1;;
+ 0) FILTERED=-1;;
+ esac;;
+ --**)
+ TYPE=${1#--}
+ case "$FILTERED" in
+ -1) echo "$PROGNAME: Can't combine --foo and --no-foo options"
>&2;
+ exit 1;;
+ 0) FILTERED=1; DSC=0; BCHANGES=0; SCHANGES=0; CHANGES=0
+ ARCHDEB=0; INDEPDEB=0; DEB=0; TARBALL=0; DIFF=0;;
+ esac;;
+ *) break;;
+ esac
+
+ case "$TYPE" in
+ "") ;;
+ dsc) [ "$FILTERED" = "1" ] && DSC=1 || DSC=0;;
+ changes) [ "$FILTERED" = "1" ] &&
+ { BCHANGES=1; SCHANGES=1; CHANGES=1; } ||
+ { BCHANGES=0; SCHANGES=0; CHANGES=0; } ;;
+ bchanges) [ "$FILTERED" = "1" ] && BCHANGES=1 || BCHANGES=0;;
+ schanges) [ "$FILTERED" = "1" ] && SCHANGES=1 || SCHANGES=1;;
+ deb) [ "$FILTERED" = "1" ] &&
+ { ARCHDEB=1; INDEPDEB=1; DEB=1; } ||
+ { ARCHDEB=0; INDEPDEB=0; DEB=0; };;
+ archdeb) [ "$FILTERED" = "1" ] && ARCHDEB=1 || ARCHDEB=0;;
+ indepdeb) [ "$FILTERED" = "1" ] && INDEPDEB=1 || INDEPDEB=0;;
+ tar|orig) [ "$FILTERED" = "1" ] && TARBALL=1 || TARBALL=0;;
+ diff) [ "$FILTERED" = "1" ] && DIFF=1 || DIFF=0;;
+ *) echo "$PROGNAME: Unknown option '$1'" >&2; exit 1;;
+ esac
+ shift
+done
+
args=""
for arg in "$@"; do
- args="$args $(maybe_expand "$arg") $arg"
+ temparg="$(maybe_expand "$arg")"
+ if [ -z "$temparg" ]; then
+ # Not expanded, so simply add to argument list
+ args="$args $arg"
+ else
+ SEEN_INDEPDEB=0; SEEN_ARCHDEB=0; SEEN_SCHANGES=0; SEEN_BCHANGES=0
+ SEEN_TARBALL=0; SEEN_DIFF=0; SEEN_DSC=0
+ MISSING=0
+ newarg=""
+ # Output those items from the expanded list which were
+ # requested, and record which files are contained in the list
+ eval $(echo "$temparg" | while read THISARG; do
+ if [ -z "$THISARG" ]; then
+ # Skip
+ :
+ elif endswith "$THISARG" _all.deb; then
+ [ "$INDEPDEB" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
+ echo "SEEN_INDEPDEB=1;"
+ elif endswith "$THISARG" .deb; then
+ [ "$ARCHDEB" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
+ echo "SEEN_ARCHDEB=1;"
+ elif endswith "$THISARG" .tar.gz || \
+ endswith "$THISARG" .tar.bz2; then
+ [ "$TARBALL" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
+ echo "SEEN_TARBALL=1;"
+ elif endswith "$THISARG" _source.changes; then
+ [ "$SCHANGES" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
+ echo "SEEN_SCHANGES=1;"
+ elif endswith "$THISARG" .changes; then
+ [ "$BCHANGES" = "0" ] || echo "newarg\"\$newarg $THISARG\";"
+ echo "SEEN_BCHANGES=1;"
+ elif endswith "$THISARG" .dsc; then
+ [ "$DSC" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
+ echo "SEEN_DSC=1;"
+ elif endswith "$THISARG" .diff.gz; then
+ [ "$DIFF" = "0" ] || echo "newarg=\"\$newarg $THISARG\";"
+ echo "SEEN_DIFF=1;"
+ elif [ "$FILTERED" != "1" ]; then
+ # What is it? Output anyway
+ echo "newarg=\"\$newarg $THISARG\";"
+ fi
+ done)
+
+ INCLUDEARG=1
+ if endswith "$arg" _source.changes; then
+ [ "$SCHANGES" = "1" ] || INCLUDEARG=0
+ SEEN_SCHANGES=1
+ elif endswith "$arg" .changes; then
+ [ "$BCHANGES" = "1" ] || INCLUDEARG=0
+ SEEN_BCHANGES=1
+ elif endswith "$arg" .dsc; then
+ [ "$DSC" = "1" ] || INCLUDEARG=0
+ SEEN_DSC=1
+ fi
+
+ if [ "$FAIL_MISSING" = "1" ] && [ "$FILTERED" = "1" ]; then
+ if [ "$CHANGES" = "1" ]; then
+ if [ "$SEEN_SCHANGES" = "0" ] && [ "$SEEN_BCHANGES" = "0" ];
then
+ MISSING=1; echo "$arg: .changes fiie not found" >&2
+ fi
+ else
+ if [ "$SCHANGES" = "1" ] && [ "$SEEN_SCHANGES" = "0" ]; then
+ MISSING=1; echo "$arg: source .changes file not found" >&2
+ fi
+ if [ "$BCHANGES" = "1" ] && [ "$SEEN_BCHANGES" = "0" ]; then
+ MISSING=1; echo "$arg: binary .changes file not found" >&2
+ fi
+ fi
+
+ if [ "$DEB" = "1" ]; then
+ if [ "$SEEN_INDEPDEB" = "0" ] && [ "$SEEN_ARCHDEB" = "0" ];
then
+ MISSING=1; echo "$arg: binary packages not found" >&2
+ fi
+ else
+ if [ "$INDEPDEB" = "1" ] && [ "$SEEN_INDEPDEB" = "0" ]; then
+ MISSING=1; echo "$arg: arch-indep packages not found" >&2
+ fi
+ if [ "$ARCHDEB" = "1" ] && [ "$SEEN_ARCHDEB" = "0" ]; then
+ MISSING=1; echo "$arg: arch-dep packages not found" >&2
+ fi
+ fi
+
+ if [ "$DSC" = "1" ] && [ "$SEEN_DSC" = "0" ]; then
+ MISSING=1; echo "$arg: .dsc file not found" >&2
+ fi
+ if [ "$TARBALL" = "1" ] && [ "$SEEN_TARBALL" = "0" ]; then
+ 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
+ fi
+
+ [ "$MISSING" = "0" ] || exit 1
+ fi
+
+ args="$args $newarg"
+ [ "$INCLUDEARG" = "0" ] || args="$args $arg"
+ fi
done
if [ -e "$1" ] && (endswith "$1" .changes || endswith "$1" .dsc); then
--
To unsubscribe, send mail to [EMAIL PROTECTED]