[devscripts] 01/01: mergechanges: Add -S argument to include only source packages

James McCoy jamessan at debian.org
Sun Aug 23 03:55:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit c196d1ba6a31a0a77f518fd360db7359d289f21a
Author: James McCoy <jamessan at debian.org>
Date:   Sat Aug 22 23:49:05 2015 -0400

    mergechanges: Add -S argument to include only source packages
    
    Closes: #795573
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog        |  3 +++
 scripts/mergechanges.1  |  5 +++-
 scripts/mergechanges.sh | 67 +++++++++++++++++++++++++++++++------------------
 3 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index c319845..3a51976 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,9 @@ devscripts (2.15.9) UNRELEASED; urgency=medium
     + Fix warning when there are no fixed bugs in the changelog.  (Closes:
       #795470)
     + Avoid querying the BTS when there are no bugs closed in the changelog.
+  * mergechanges:
+    + Add -S/--source argument to skip all binary packages.  Thanks to Ansgar
+      Burchardt for the patch.  (Closes: #795573)
 
   [ Dominique Dumont ]
   * licensecheck:
diff --git a/scripts/mergechanges.1 b/scripts/mergechanges.1
index f6253fa..f815862 100644
--- a/scripts/mergechanges.1
+++ b/scripts/mergechanges.1
@@ -2,7 +2,7 @@
 .SH NAME
 mergechanges \- merge multiple changes files
 .SH SYNOPSIS
-\fBmergechanges\fR [\fB\-d\fR] [\fB\-f\fR] [\fB\-i\fR] \fIfile1 file2\fR [\fIfile\fR...]
+\fBmergechanges\fR [\fB\-d\fR] [\fB\-f\fR] [\fB\-S\fR] [\fB\-i\fR] \fIfile1 file2\fR [\fIfile\fR...]
 .SH DESCRIPTION
 \fBmergechanges\fR merges two or more \fI.changes\fR files, merging
 the Architecture, Description and Files (and Checksums-*, if present)
@@ -22,6 +22,9 @@ input files will be deleted.
 If the \fB\-i\fR or \fB\-\-indep\fR option is given, source packages
 and architecture-independent (Architecture: all) packages are included
 in the output, but architecture-dependent packages are not.
+.PP
+If the \fB\-S\fR or \fB\-\-source\fR option is given, only source packages
+are included in the output.
 .SH AUTHOR
 Gergely Nagy <algernon at debian.org>,
 modifications by Julian Gilbey <jdg at debian.org>,
diff --git a/scripts/mergechanges.sh b/scripts/mergechanges.sh
index 86a1747..1e07622 100755
--- a/scripts/mergechanges.sh
+++ b/scripts/mergechanges.sh
@@ -24,17 +24,18 @@ set -e
 PROGNAME=`basename $0`
 
 synopsis () {
-    echo "Usage: $PROGNAME [-h|--help|--version] [-d] [-i|--indep] [-f] <file1> <file2> [<file> ...]"
+    echo "Usage: $PROGNAME [-h|--help|--version] [-d] [-S|--source] [-i|--indep] [-f] <file1> <file2> [<file> ...]"
 }
 
 usage () {
     synopsis
-    echo <<EOT
+    cat <<EOT
   Merge the changes files <file1>, <file2>, ....  Output on stdout
   unless -f option given, in which case, output to
   <package>_<version>_multi.changes in the same directory as <file1>.
   If -i is given, only source and architecture-independent packages
-  are included in the output."
+  are included in the output.
+  If -S is given, only the source package is included in the output.
 EOT
 }
 
@@ -51,7 +52,8 @@ GNU General Public License, version 2 or later."
 # Commandline parsing
 FILE=0
 DELETE=0
-INDEP_ONLY=0
+REMOVE_ARCHDEP=0
+REMOVE_INDEP=0
 
 while [ $# -gt 0 ]; do
     case "$1" in
@@ -72,7 +74,12 @@ while [ $# -gt 0 ]; do
 	    shift
 	    ;;
 	-i|--indep)
-	    INDEP_ONLY=1
+	    REMOVE_ARCHDEP=1
+	    shift
+	    ;;
+	-S|--source)
+	    REMOVE_ARCHDEP=1
+	    REMOVE_INDEP=1
 	    shift
 	    ;;
 	-*)
@@ -104,33 +111,45 @@ done
 # and merge them, sorting out duplicates. Skip architectures
 # other than all and source if desired.
 ARCHS=$(grep -h "^Architecture: " "$@" | sed -e "s,^Architecture: ,," | tr ' ' '\n' | sort -u)
-if test ${INDEP_ONLY} = 1; then
+if test ${REMOVE_ARCHDEP} = 1; then
     ARCHS=$(echo "$ARCHS" | grep -E '^(all|source)$')
 fi
+if test ${REMOVE_INDEP} = 1; then
+    ARCHS=$(echo "$ARCHS" | grep -vxF all)
+fi
 ARCHS=$(echo "$ARCHS" | tr '\n' ' ' | sed 's/ $//')
 
 checksum_uniq() {
     local line
     local IFS=
-    if test ${INDEP_ONLY} = 1; then
-        while read line; do
-            case "$line" in
-                (*.dsc|*.diff.gz|*.tar.*|*_all.deb|*_all.udeb)
-                    # source or architecture-independent
-                    echo "$line"
-                    ;;
-                (*.deb|*.udeb)
-                    # architecture-specific, ignore
-                    ;;
-                (*)
-                    echo "Unrecognised file, is it architecture-dependent?" >&2
-                    echo "$line" >&2
-                    exit 1
-                    ;;
-            esac
-        done | awk '{if(arr[$NF] != 1){arr[$NF] = 1; print;}}'
+    if test ${REMOVE_ARCHDEP} = 1 -o ${REMOVE_INDEP} = 1; then
+	while read line; do
+	    case "$line" in
+		(*.dsc|*.diff.gz|*.tar.*)
+		    # source
+		    echo "$line"
+		    ;;
+		(*_all.deb|*_all.udeb)
+		    # architecture-indep
+		    if test ${REMOVE_INDEP} = 0; then
+			echo "$line"
+		    fi
+		    ;;
+		(*.deb|*.udeb)
+		    # architecture-specific
+		    if test ${REMOVE_ARCHDEP} = 0; then
+			echo "$line"
+		    fi
+		    ;;
+		(*)
+		    echo "Unrecognised file, is it architecture-dependent?" >&2
+		    echo "$line" >&2
+		    exit 1
+		    ;;
+	    esac
+	done | awk '{if(arr[$NF] != 1){arr[$NF] = 1; print;}}'
     else
-        awk '{if(arr[$NF] != 1){arr[$NF] = 1; print;}}'
+	awk '{if(arr[$NF] != 1){arr[$NF] = 1; print;}}'
     fi
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list