Author: adam-guest
Date: 2008-04-11 20:42:52 +0000 (Fri, 11 Apr 2008)
New Revision: 1330
Modified:
trunk/debian/changelog
trunk/scripts/mergechanges.1
trunk/scripts/mergechanges.sh
Log:
mergechanges:
+ Update for the new .changes format introduced with dpkg 1.14.17:
- Handle Checksums-Sha(1|256)
- Only allow .changes files with the same Format to be merged
- Reject .changes files with unsupported Formats or Checksums fields
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-04-11 19:32:31 UTC (rev 1329)
+++ trunk/debian/changelog 2008-04-11 20:42:52 UTC (rev 1330)
@@ -13,6 +13,11 @@
the first
* debian/control: Suggest instead of Recommending gnuplot and
cvs-buildpackage
+ * mergechanges:
+ + Update for the new .changes format introduced with dpkg 1.14.17:
+ - Handle Checksums-Sha(1|256)
+ - Only allow .changes files with the same Format to be merged
+ - Reject .changes files with unsupported Formats or Checksums fields
-- Adam D. Barratt <[EMAIL PROTECTED]> Wed, 09 Apr 2008 18:39:33 +0100
Modified: trunk/scripts/mergechanges.1
===================================================================
--- trunk/scripts/mergechanges.1 2008-04-11 19:32:31 UTC (rev 1329)
+++ trunk/scripts/mergechanges.1 2008-04-11 20:42:52 UTC (rev 1330)
@@ -5,10 +5,11 @@
\fBmergechanges\fR [\fB\-f\fR] \fIfile1 file2\fR [\fIfile\fR...]
.SH DESCRIPTION
\fBmergechanges\fR merges two or more \fI.changes\fR files, merging
-the Architecture, Description and Files fields of the two. There are
-basic checks made to ensure that the changes files are from the same
-source package and version. The first changes file is used as the basis
-and the information from the later ones is merged into it.
+the Architecture, Description and Files (and Checksums-*, if present)
+fields of the two. There are checks made to ensure that the changes
+files are from the same source package and version and use the same
+changes file Format. The first changes file is used as the basis and
+the information from the later ones is merged into it.
.PP
The output is normally written to \fIstdout\fR. If the \fB\-f\fR
option is given, the output is written to
@@ -16,4 +17,5 @@
directory as the first changes file listed.
.SH AUTHOR
Gergely Nagy <[EMAIL PROTECTED]>,
-modifications by Julian Gilbey <[EMAIL PROTECTED]>.
+modifications by Julian Gilbey <[EMAIL PROTECTED]> and
+Adam D. Barratt <[EMAIL PROTECTED]>.
Modified: trunk/scripts/mergechanges.sh
===================================================================
--- trunk/scripts/mergechanges.sh 2008-04-11 19:32:31 UTC (rev 1329)
+++ trunk/scripts/mergechanges.sh 2008-04-11 20:42:52 UTC (rev 1330)
@@ -96,8 +96,17 @@
SOURCE=$(grep -h "^Source: " "$@" | sed -e "s,^Source: ,," | sort -u)
# Extract & merge the files from all files
FILES=$(egrep -h "^ [0-9a-f]{32} [0-9]+" "$@" | sort -u)
+# Extract & merge the sha1 checksums from all files
+SHA1S=$(egrep -h "^ [0-9a-f]{40} [0-9]+" "$@" | sort -u)
+# Extract & merge the sha256 checksums from all files
+SHA256S=$(egrep -h "^ [0-9a-f]{64} [0-9]+" "$@" | sort -u)
# Extract & merge the description from all files
DESCRIPTIONS=$(sed '/^Description:/,/^[^ ]/{/^ /p;d};d' "$@" | sort -u)
+# Extract & merge the Formats from all files
+FORMATS=$(grep -h "^Format: " "$@" | sed -e "s,^Format: ,," | sort -u)
+# Extract & merge the Checksums-* field names from all files
+CHECKSUMS=$(grep -h "^Checksums-.*:" "$@" | sort -u)
+UNSUPCHECKSUMS="$(echo "${CHECKSUMS}" | grep -v "^Checksums-Sha\(1\|256\):" ||
true)"
# Sanity check #2: Versions must match
if test $(echo "${VERSION}" | wc -l) -ne 1; then
@@ -120,6 +129,31 @@
exit 1
fi
+# Sanity check #5: Formats must match
+if test $(echo "${FORMATS}" | wc -l) -ne 1; then
+ echo "Error: Changes files have different Format fields:"
+ grep "^Format: " "$@"
+ exit 1
+fi
+
+# Sanity check #6: The Format must be one we understand
+case "$FORMATS" in
+ 1.7|1.8) # Supported
+ ;;
+ *)
+ echo "Error: Changes files use unknown Format:"
+ echo "${FORMATS}"
+ exit 1
+ ;;
+esac
+
+# Sanity check #7: Unknown checksum fields
+if test -n "${UNSUPCHECKSUMS}"; then
+ echo "Error: Unsupported checksum fields:"
+ echo "${UNSUPCHECKSUMS}"
+ exit 1
+fi
+
if test ${FILE} = 1; then
DIR=`dirname "$1"`
REDIR1="> '${DIR}/${SOURCE}_${SVERSION}_multi.changes'"
@@ -145,12 +179,22 @@
# Replace the Architecture: field, nuke the value of Files:, and insert
# the Description: field before the Changes: field
-eval "sed -e 's,^Architecture: .*,Architecture: ${ARCHS},; /^Files: /q' \
+eval "sed -e 's,^Architecture: .*,Architecture: ${ARCHS},' \
+ -e '/^Files: /,$ d; /^Checksums-.*: /,$ d' \
-e '/^Description:/,/^[^ ]/{/^Description:/d;/^[ ]/d}' \
-e '/^Changes:/{r '${DESCFILE} -e ';aChanges:' -e ';d}' \
${OUTPUT} ${REDIR1}"
-# Voodoo magic to get the merged filelist into the output
+# Voodoo magic to get the merged file and checksum lists into the output
+if test -n "${SHA1S}"; then
+ eval "echo 'Checksums-Sha1: ' ${REDIR2}"
+ eval "echo '${SHA1S}' ${REDIR2}"
+fi
+if test -n "${SHA256S}"; then
+ eval "echo 'Checksums-Sha256: ' ${REDIR2}"
+ eval "echo '${SHA256S}' ${REDIR2}"
+fi
+eval "echo 'Files: ' ${REDIR2}"
eval "echo '${FILES}' ${REDIR2}"
exit 0
--
To unsubscribe, send mail to [EMAIL PROTECTED]