[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] ddtp-i18n.sh



update the script with what Felipe sent me. This now generates the Index
file needed by the generate-release script.
advantage having it in here: it is only generated when needed and it
doesn't riddle gen-rel with entirely unrelated code

Signed-off-by: Joerg Jaspert <joerg@debian.org>
---
 scripts/debian/ddtp-i18n-check.sh |   58 +++++++++++++++++++++++++++---------
 1 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/scripts/debian/ddtp-i18n-check.sh b/scripts/debian/ddtp-i18n-check.sh
index cefb68e..f894f1c 100755
--- a/scripts/debian/ddtp-i18n-check.sh
+++ b/scripts/debian/ddtp-i18n-check.sh
@@ -1,8 +1,8 @@
 #!/bin/bash
 #
-# $Id: ddtp_i18n_check.sh 1670 2009-03-31 20:57:49Z nekral-guest $
+# $Id: ddtp_i18n_check.sh 2535 2011-02-19 14:20:52Z nekral-guest $
 # 
-# Copyright (C) 2008, Felipe Augusto van de Wiel <faw@funlabs.org>
+# Copyright (C) 2008, 2011 Felipe Augusto van de Wiel <faw@funlabs.org>
 # Copyright (C) 2008, 2009 Nicolas François <nicolas.francois@centraliens.net>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,10 @@ DEBUG=0
 # files.
 DRY_RUN=0
 
+# When GEN_IDX=1, we create the Index files.  There is a runtime option
+# to not create/generate the Index file.
+GEN_IDX=1
+
 dists_parent_dir=""
 # If no argument indicates the PACKAGES_LISTS_DIR then use '.'
 PACKAGES_LISTS_DIR=""
@@ -35,6 +39,7 @@ usage () {
 	echo "    --debug      Debug mode: do not stop after the first error" >&2
 	echo "    --dry-run    Do not generate the compressed version of the " >&2
 	echo "                 Translation files">&2
+	echo "    --no-index   Do not generate the Index files" >&2
 	exit 1
 }
 
@@ -47,6 +52,9 @@ for opt; do
 		"--dry-run")
 			DRY_RUN=1
 			;;
+		"--no-index")
+			GEN_IDX=0
+			;;
 		"-*")
 			usage
 			;;
@@ -80,21 +88,21 @@ elif [ ! -d "$PACKAGES_LISTS_DIR" ]; then
 	usage
 fi
 
-#STABLE="lenny"
+#STABLE="squeeze"
 TESTING="wheezy"
 UNSTABLE="sid"
 
 # Original SHA256SUMS, generated by i18n.debian.net
-SHA256SUMS="SHA256SUMS"
+CHECKSUMS="SHA256SUMS"
 
 # DAK Timestamp
 TIMESTAMP="timestamp"
 
 # These special files must exist on the top of dists_parent_dir
-SPECIAL_FILES="$SHA256SUMS $TIMESTAMP $TIMESTAMP.gpg"
+SPECIAL_FILES="$CHECKSUMS $TIMESTAMP $TIMESTAMP.gpg"
 
 # Temporary working directory. We need a full path to reduce the
-# complexity of checking SHA256SUMS and cleaning/removing TMPDIR
+# complexity of checking CHECKSUMS and cleaning/removing TMPDIR
 TEMP_WORK_DIR=$(mktemp -d -t ddtp_dinstall_tmpdir.XXXXXX)
 cd "$TEMP_WORK_DIR"
 TMP_WORK_DIR=$(pwd)
@@ -105,6 +113,7 @@ unset TEMP_WORK_DIR
 trap_exit () {
 	rm -rf "$TMP_WORK_DIR"
 	rm -f "$dists_parent_dir"/dists/*/main/i18n/Translation-*.bz2
+	rm -f "$dists_parent_dir"/dists/*/main/i18n/Index
 	exit 1
 }
 trap trap_exit EXIT HUP INT QUIT TERM
@@ -315,18 +324,18 @@ for sf in $SPECIAL_FILES; do
 	fi
 done
 
-# 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
+# Comparing CHECKSUMS
+# We don't use -c because a file could exist in the directory tree and not in
+# the CHECKSUMS, so we sort the existing CHECKSUMS 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 -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
+find dists -type f -print0 |xargs --null sha256sum > "$TMP_WORK_DIR/$CHECKSUMS.new"
+sort "$CHECKSUMS" > "$TMP_WORK_DIR/$CHECKSUMS.sorted"
+sort "$TMP_WORK_DIR/$CHECKSUMS.new" > "$TMP_WORK_DIR/$CHECKSUMS.new.sorted"
+if ! cmp --quiet "$TMP_WORK_DIR/$CHECKSUMS.sorted" "$TMP_WORK_DIR/$CHECKSUMS.new.sorted"; then
+	echo "Failed to compare the $CHECKSUMS, they are not identical!" >&2
+	diff -au "$TMP_WORK_DIR/$CHECKSUMS.sorted" "$TMP_WORK_DIR/$CHECKSUMS.new.sorted" >&2
 	exit 1
 fi
 cd "$OLDPWD"
@@ -346,6 +355,14 @@ while read f; do
 		if ! is_dirname_okay "$f"; then
 			echo "Wrong directory name: $f" >&2
 			exit 1
+		else
+			# If the directory name is OK, and if it's name is i18n
+			# and GEN_IDX is enabled, we generate the header of the
+			# Index file
+			if [ "$(basename $f)" = "i18n" -a "$GEN_IDX" = "1" ];
+			then
+				echo "SHA1:" > "$f/Index"
+			fi
 		fi
 	elif [ -f "$f" ]; then
 		# If $f is in $SPECIAL_FILES, we skip to the next loop because
@@ -393,6 +410,17 @@ while read f; do
 			# Now generate the compressed files
 			bzip2 "$f"
 		fi
+
+		# Create Index
+		if [ "$GEN_IDX" = "1" ]; then
+			fbz=${f}.bz2
+			IDX=$(dirname $f)
+			tf_name=$(basename $fbz)
+			tf_sha1=$(sha1sum $fbz)
+			tf_size=$(du $fbz)
+			printf ' %s % 7s %s\n' "${tf_sha1% *}" \
+				"${tf_size%	*}" "${tf_name}" >> "$IDX/Index"
+		fi
 	else
 		echo "Neither a file or directory: $f" >&2
 		exit 1
-- 
1.7.2.5


Reply to: