[Debian-l10n-commits] r1174 - in /ddtp-dinstall/trunk: Changelog checks/ddtp_i18n_check.sh

faw at users.alioth.debian.org faw at users.alioth.debian.org
Mon Aug 11 19:20:06 UTC 2008


Author: faw
Date: Mon Aug 11 19:20:06 2008
New Revision: 1174

URL: http://svn.debian.org/wsvn/?sc=1&rev=1174
Log:
 * checks/ddtp_i18n_check.sh: Added a temporary working directory, we
   now put all the generated files there and remove it with a trap.
 * checks/ddtp_i18n_check.sh: Sort SHA256SUMS before compare them.
   Using 'find' do not guarantee that we always have the same sequence
   of files.
 * checks/ddtp_i18n_check.sh: Renamed the generated lists of packages
   to follow the name of the Translation file used to generate it.

Modified:
    ddtp-dinstall/trunk/Changelog
    ddtp-dinstall/trunk/checks/ddtp_i18n_check.sh

Modified: ddtp-dinstall/trunk/Changelog
URL: http://svn.debian.org/wsvn/ddtp-dinstall/trunk/Changelog?rev=1174&op=diff
==============================================================================
--- ddtp-dinstall/trunk/Changelog (original)
+++ ddtp-dinstall/trunk/Changelog Mon Aug 11 19:20:06 2008
@@ -1,3 +1,13 @@
+2008-08-11  Felipe Augusto van de Wiel  <faw at funlabs.org>
+
+	* checks/ddtp_i18n_check.sh: Added a temporary working directory, we
+	now put all the generated files there and remove it with a trap.
+	* checks/ddtp_i18n_check.sh: Sort SHA256SUMS before compare them.
+	Using 'find' do not guarantee that we always have the same sequence
+	of files.
+	* checks/ddtp_i18n_check.sh: Renamed the generated lists of packages
+	to follow the name of the Translation file used to generate it.
+
 2008-08-11  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* tests/testsuite/bad/SHA256SUMS_not_in_parent_dir,

Modified: ddtp-dinstall/trunk/checks/ddtp_i18n_check.sh
URL: http://svn.debian.org/wsvn/ddtp-dinstall/trunk/checks/ddtp_i18n_check.sh?rev=1174&op=diff
==============================================================================
--- ddtp-dinstall/trunk/checks/ddtp_i18n_check.sh (original)
+++ ddtp-dinstall/trunk/checks/ddtp_i18n_check.sh Mon Aug 11 19:20:06 2008
@@ -28,11 +28,6 @@
 # Original SHA256SUMS, generated by i18n.debian.net
 SHA256SUMS="SHA256SUMS"
 
-trap_exit () {
-	rm -f "$PACKAGES_LISTS_DIR"/*.pkgs
-}
-trap trap_exit EXIT
-
 usage () {
 	echo "Usage: $0 <dists_parent_dir> [<packages_lists_directory>]" >&2
 	exit 1
@@ -42,6 +37,21 @@
 then
 	usage
 fi
+
+# Temporary working directory. We need a full path to reduce the
+# complexity of checking SHA256SUMS and cleaning/removing TMPDIR
+TEMP_WORK_DIR=$(mktemp -d -t ddtp_dinstall_tmpdir.XXXXXX)
+cd "$TEMP_WORK_DIR"
+TMP_WORK_DIR=$(pwd)
+cd "$OLDPWD"
+unset TEMP_WORK_DIR
+
+# If it's traped, something bad happened.
+trap_exit () {
+	rm -rf "$TMP_WORK_DIR"
+	exit 1
+}
+trap trap_exit EXIT
 
 # If no argument indicates the PACKAGES_LISTS_DIR then use '.'
 PACKAGES_LISTS_DIR=${2:-.}
@@ -252,14 +262,26 @@
 	return 0
 }
 
+# SHA256SUMS must exist
+if [ -f "$SHA256SUMS" ]; then
+	echo "SHA256SUMS ($SHA256SUMS) doesn't exist"
+	exit 1;
+fi
+
+# Comparing SHA256SUMS
+# We don use -c because a file could exist in the directory tree and not in
+# the SHA256SUMS, so we sort the existing SHA256SUMS and we create a new one
+# already sorted, if cmp fails then files are different and we don't want to
+# continue.
 cd "$dists_parent_dir"
-find dists -type f |xargs sha256sum > "$SHA256SUMS.new"
-if ! cmp --quiet "$SHA256SUMS" "$SHA256SUMS.new"; then
-	echo "sha256sum mismatch!" >&2
-	diff -au "$SHA256SUMS" "$SHA256SUMS.new" >&2
+find dists -type f -print0 |xargs --null sha256sum > "$TMP_WORK_DIR/$SHA256SUMS.new"
+sort "$SHA256SUMS" > "$TMP_WORK_DIR/$SHA256SUMS.sorted"
+sort "$TMP_WORK_DIR/$SHA256SUMS.new" > "$TMP_WORK_DIR/$SHA256SUMS.new.sorted"
+if ! cmp --quiet "$TMP_WORK_DIR/$SHA256SUMS.sorted" "$TMP_WORK_DIR/$SHA256SUMS.new.sorted"; then
+	echo "Failed to compare the SHA256SUMS, they are not identical!" >&2
+	diff -au "$TMP_WORK_DIR/$SHA256SUMS.sorted" "$TMP_WORK_DIR/$SHA256SUMS.new.sorted" >&2
 	exit 1
 fi
-rm -f "$SHA256SUMS.new"
 cd "$OLDPWD"
 
 # Get the list of valid packages (sorted, uniq)
@@ -268,7 +290,7 @@
 		echo "Missing $PACKAGES_LISTS_DIR/$t" >&2
 		exit 1
 	fi
-	cut -d' ' -f 1 "$PACKAGES_LISTS_DIR/$t" | sort -u > "$PACKAGES_LISTS_DIR/$t.pkgs"
+	cut -d' ' -f 1 "$PACKAGES_LISTS_DIR/$t" | sort -u > "$TMP_WORK_DIR/$t.pkgs"
 done
 
 /usr/bin/find "$dists_parent_dir" |
@@ -298,17 +320,16 @@
 		fi
 
 		# Check that every packages in Translation-$lang exists
-		grep "^Package: " "$f" | cut -d' ' -f 2 | sort -u > "$PACKAGES_LISTS_DIR/tmp.pkgs"
+		TPKGS=$(basename "$f").pkgs
+		grep "^Package: " "$f" | cut -d' ' -f 2 | sort -u > "$TMP_WORK_DIR/$TPKGS"
 		case "$f" in
 			*/$TESTING/*)  t="$TESTING";;
 			*/$UNSTABLE/*) t="$UNSTABLE";;
 		esac
-		if diff "$PACKAGES_LISTS_DIR/$t.pkgs" "$PACKAGES_LISTS_DIR/tmp.pkgs" | grep -q "^>"; then
-			rm -f "$PACKAGES_LISTS_DIR/tmp.pkgs"
+		if diff "$TMP_WORK_DIR/$t.pkgs" "$TMP_WORK_DIR/$TPKGS" | grep -q "^>"; then
 			echo "$f contains packages which are not in $t" >&2
 			exit 1
 		fi
-		rm -f "$PACKAGES_LISTS_DIR/tmp.pkgs"
 
 		# Check encoding
 		iconv -f utf-8 -t utf-8 < "$f" > /dev/null 2>&1 || {
@@ -333,3 +354,7 @@
 
 echo "$dists_parent_dir structure validated successfully ($(date +%c))"
 
+# If we reach this point, everything went fine.
+trap - EXIT
+rm -rf "$TMP_WORK_DIR"
+




More information about the Debian-l10n-commits mailing list