[Debian-l10n-commits] r1495 - in /dl10n/trunk: Changelog pootle/sync-projects.d/10debconf

nekral-guest at users.alioth.debian.org nekral-guest at users.alioth.debian.org
Sun Dec 7 20:32:06 UTC 2008


Author: nekral-guest
Date: Sun Dec  7 20:32:06 2008
New Revision: 1495

URL: http://svn.debian.org/wsvn/?sc=1&rev=1495
Log:
	* pootle/sync-projects.d/10debconf: Execute with "set -e".
	* pootle/sync-projects.d/10debconf: Quote variables.
	* pootle/sync-projects.d/10debconf: Create the temporary directory
	with mktemp instead of tempfile. This avoid having to remove the
	file and create the directory later.
	* pootle/sync-projects.d/10debconf: Better handling of packages
	without a debian/po directory in the root.
	* pootle/sync-projects.d/10debconf: Ignore the errors from msgcat.
	(A lot of empty PO files were created with no valid charset)
	* pootle/sync-projects.d/10debconf: Fix typo: lang -> $lang.
	* pootle/sync-projects.d/10debconf: Use
	/srv/pootle.debian.net/tmp/ for the temporary files and
	directories.

Modified:
    dl10n/trunk/Changelog
    dl10n/trunk/pootle/sync-projects.d/10debconf

Modified: dl10n/trunk/Changelog
URL: http://svn.debian.org/wsvn/dl10n/trunk/Changelog?rev=1495&op=diff
==============================================================================
--- dl10n/trunk/Changelog (original)
+++ dl10n/trunk/Changelog Sun Dec  7 20:32:06 2008
@@ -1,3 +1,19 @@
+2008-12-06  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* pootle/sync-projects.d/10debconf: Execute with "set -e".
+	* pootle/sync-projects.d/10debconf: Quote variables.
+	* pootle/sync-projects.d/10debconf: Create the temporary directory
+	with mktemp instead of tempfile. This avoid having to remove the
+	file and create the directory later.
+	* pootle/sync-projects.d/10debconf: Better handling of packages
+	without a debian/po directory in the root.
+	* pootle/sync-projects.d/10debconf: Ignore the errors from msgcat.
+	(A lot of empty PO files were created with no valid charset)
+	* pootle/sync-projects.d/10debconf: Fix typo: lang -> $lang.
+	* pootle/sync-projects.d/10debconf: Use
+	/srv/pootle.debian.net/tmp/ for the temporary files and
+	directories.
+
 2008-12-06  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* pootle/sync-projects.d/x20ddtp: Execute with "set -e".

Modified: dl10n/trunk/pootle/sync-projects.d/10debconf
URL: http://svn.debian.org/wsvn/dl10n/trunk/pootle/sync-projects.d/10debconf?rev=1495&op=diff
==============================================================================
--- dl10n/trunk/pootle/sync-projects.d/10debconf (original)
+++ dl10n/trunk/pootle/sync-projects.d/10debconf Sun Dec  7 20:32:06 2008
@@ -1,63 +1,68 @@
 #!/bin/sh
+
+set -e
 
 . `dirname $0`/cfg/common
 . `dirname $0`/cfg/`basename $0`
 
 echo "`basename $0`: Updating debconf translations..."
 
-TEMPDIR=`tempfile --directory=/tmp`
-rm $TEMPDIR
+TMPDIR=/srv/pootle.debian.net/tmp
+export TMPDIR
+TEMPDIR=`mktemp -d -p "$TMPDIR" sync.XXXXXX`
 
-cd $POOTLEDEBCONFDIR
+cd "$POOTLEDEBCONFDIR"
 svn -q up
 
-[ -f $TARBALL ] || exit 1
+[ -f "$TARBALL" ] || exit 1
 
 # First we extract the tarball in the temporary directory
 echo "  Extracting files from $TARBALL..."
-mkdir $TEMPDIR
-cd $TEMPDIR
+cd "$TEMPDIR"
 umask 002
-tar xfz $TARBALL
+tar xfz "$TARBALL"
 mv po/unstable/* .
 rm -rf po
 
 # Then we extract the PO Files
 echo "  Uncompress/update/check extracted files..."
 for pkg in `find . -mindepth 3 -maxdepth 3 -type d` ; do
-	# Files are originall in debian/po. Move them the the root
+	# Files are originally in debian/po. Move them in the root
 	# of the directory
-	mv $pkg/debian/po/*gz $pkg 2>/dev/null
+	if [ ! -d "$pkg/debian/po/" ]; then
+		continue
+	fi
+	mv "$pkg"/debian/po/*gz "$pkg" 2>/dev/null
 	# And clean out the remaining stuff
-	rm -rf $pkg/debian 2>/dev/null
+	rm -rf "$pkg/debian" 2>/dev/null
 	# Uncompress files
-	if [ `\ls -1 $pkg/*gz 2>/dev/null | wc -l` != "0" ] ; then
-	  gzip -d $pkg/*gz
+	if [ `\ls -1 "$pkg"/*gz 2>/dev/null | wc -l` != "0" ] ; then
+	  gzip -d "$pkg"/*gz
 	fi
 	# Now we should rename those files to $LANGUAGE.po
 	# We need to strip out the package name and version
 	# The name of the templates.pot file will give it to us
-	for pot in `\ls -1 $pkg/*templates.pot 2>/dev/null`; do
-		root=`basename $pot templates.pot`
-		for pots in `\ls -1 $pkg/*.pot 2>/dev/null`; do
+	for pot in `\ls -1 "$pkg"/*templates.pot 2>/dev/null`; do
+		root=`basename "$pot" templates.pot`
+		for pots in `\ls -1 "$pkg"/*.pot 2>/dev/null`; do
 		        # Rename the file to "templates.pot"
-			mv $pots $pkg/`basename $pots | sed "s/$root//g"`
+			mv "$pots" $pkg/`basename $pots | sed "s/$root//g"`
 		done
-		for po in `\ls -1 $pkg/*.po 2>/dev/null`; do
+		for po in `\ls -1 "$pkg"/*.po 2>/dev/null`; do
 		        # Convert the file to UTF-8 and rename it by
 		        # stripping out the package name and version
 		        # If something fails, report
-			if msgconv --to-code=utf-8 $po >$pkg/`basename $po | sed "s/$root//g"` 2>/dev/null; then
-				rm $po
+			if msgconv --to-code=utf-8 "$po" >$pkg/`basename "$po" | sed "s/$root//g"` 2>/dev/null; then
+				rm "$po"
 			else
-				rm $pkg/`basename $po | sed "s/$root//g"` >/dev/null 2>&1 || true
-				rm $po
+				rm $pkg/`basename "$po" | sed "s/$root//g"` >/dev/null 2>&1 || true
+				rm "$po"
 				echo "      Error while working on $po"
 			fi
 		done
 	done
-	# Now we have a directory withe only $LANGUAGE.po and templates.pot
-	TEMPFILE=`tempfile`
+	# Now we have a directory with only $LANGUAGE.po and templates.pot
+	TEMPFILE=`tempfile --directory "$TMPDIR"`
 	# Now we update the file in Pootle
 	# We need to merge the file from the tarball with
 	# the file in Pootle (that one could have been changed by a translator
@@ -65,31 +70,32 @@
 	# Of course, if the directory does not exist in Pootle (new
 	# package with debconf), we will just add it
 	# and copy files from the tarball
-	if [ -d $POOTLEDEBCONFDIR/$pkg ] ; then
+	if [ -d "$POOTLEDEBCONFDIR/$pkg" ] ; then
 	        # So, there's something in Pootle
 	        # Cycle over all PO files
-		for pofile in `\ls -1 $pkg/*.po 2>/dev/null` ; do
-			filename=`basename $pofile`
-			if [ -f $POOTLEDEBCONFDIR/$pkg/$filename ] ; then
+		for pofile in `\ls -1 "$pkg"/*.po 2>/dev/null` ; do
+			filename=`basename "$pofile"`
+			if [ -f "$POOTLEDEBCONFDIR/$pkg/$filename" ] ; then
 			        # Give priority to the file in Pootle
-				msgcat --use-first $POOTLEDEBCONFDIR/$pkg/$filename $pofile >$TEMPFILE 2>/dev/null
+				# Ignore errors (e.g. wrong CHARSET because the file is empty)
+				msgcat --use-first "$POOTLEDEBCONFDIR/$pkg/$filename" "$pofile" >"$TEMPFILE" 2>/dev/null || true
 				# And merge with the POT file from the tarball
-				msgmerge -U $TEMPFILE $POOTLEDEBCONFDIR/$pkg/templates.pot >/dev/null 2>&1
+				msgmerge -U "$TEMPFILE" "$POOTLEDEBCONFDIR/$pkg/templates.pot" >/dev/null 2>&1
 				# And overwrite the Pootle file
-				cp $TEMPFILE $POOTLEDEBCONFDIR/$pkg/$filename
+				cp "$TEMPFILE" "$POOTLEDEBCONFDIR/$pkg/$filename"
 			else
 			        # Maybe *that* file didn't exist in Pootle
 			        # In such case, just copy it
-				cp $pofile $POOTLEDEBCONFDIR/$pkg
-				msgmerge -U $POOTLEDEBCONFDIR/$pkg/$filename $POOTLEDEBCONFDIR/$pkg/templates.pot  >/dev/null 2>&1
+				cp "$pofile" "$POOTLEDEBCONFDIR/$pkg"
+				msgmerge -U "$POOTLEDEBCONFDIR/$pkg/$filename" "$POOTLEDEBCONFDIR/$pkg/templates.pot"  >/dev/null 2>&1
 			fi
 		done
 	else
 	        # There was no directory in Pootle yet, just copy
-		mkdir -p $POOTLEDEBCONFDIR/$pkg
-		cp -r $pkg/* $POOTLEDEBCONFDIR/$pkg
+		mkdir -p "$POOTLEDEBCONFDIR/$pkg"
+		cp -r "$pkg"/* "$POOTLEDEBCONFDIR/$pkg"
 	fi
-	rm $TEMPFILE 2>/dev/null || true
+	rm "$TEMPFILE" 2>/dev/null || true
 done
 
 # Now we have the Pootle directory updated with files from the tarball
@@ -99,25 +105,25 @@
 echo "  Cleaning out broken files..."
 for file in $BROKEN; do
 	echo "    $file"
-	rm $POOTLEDEBCONFDIR/$file
+	rm "$POOTLEDEBCONFDIR/$file"
 done
 
 # Some packages should be ignored for various reasons
 echo "  Cleaning out ignored packages..."
 for pkg in $IGNORE; do
 	echo "    $pkg"
-	rm -rf `find $POOTLEDEBCONFDIR -mindepth 3 -maxdepth 3 -name $pkg` #2>/dev/null
+	rm -rf `find "$POOTLEDEBCONFDIR" -mindepth 3 -maxdepth 3 -name "$pkg"` #2>/dev/null
 done
 
 # And some packages provide useless garbage 
 echo "  Cleaning out garbage..."
 for dir in $GARBAGE; do
 	echo "    $dir"
-	rm -rf $POOTLEDEBCONFDIR/$dir
+	rm -rf "$POOTLEDEBCONFDIR/$dir"
 done
 
 # What languages are present?
-LANGUAGES=`find $POOTLEDEBCONFDIR -name \*.po | cut -f9 -d\/ | sort | uniq | cut -f1 -d\.`
+LANGUAGES=`find "$POOTLEDEBCONFDIR" -name \*.po | cut -f9 -d\/ | sort | uniq | cut -f1 -d\.`
 # This will allow automatically adding a language as soon as *one* package
 # provides a file for it
 
@@ -125,12 +131,12 @@
 # That's slightly suboptimal but this is the only way to have correct
 # statistics in Pootle
 echo "  Updating Pootle files..."
-for pkg in `find $POOTLEDEBCONFDIR -maxdepth 3 -mindepth 3 -type d | grep -v \\.svn` ; do
+for pkg in `find "$POOTLEDEBCONFDIR" -maxdepth 3 -mindepth 3 -type d | grep -v \\.svn` ; do
 	for lang in $LANGUAGES; do
-		if [ ! -f $pkg/$lang.po ] ; then
-			cp $pkg/templates.pot $pkg/$lang.po
+		if [ ! -f "$pkg/$lang.po" ] ; then
+			cp "$pkg/templates.pot" "$pkg/$lang.po"
 		else
-			msgmerge -U $pkg/lang.po $pkg/templates.pot >/dev/null 2>&1
+			msgmerge -U "$pkg/$lang.po" "$pkg/templates.pot" >/dev/null 2>&1
 		fi
 	done
 done
@@ -138,7 +144,7 @@
 
 # Now commit the whole stuff to SVN
 echo "  Committing to SVN..."
-cd $POOTLEDEBCONFDIR
+cd "$POOTLEDEBCONFDIR"
 svn -q up
 # echo "   Committing updated files"
 svn -q commit -m"[SILENT_COMMIT] Update existing files for `date +%Y%m%d%H%M`"
@@ -154,16 +160,16 @@
 # aren't anymore in the tarball. Most of the time, this will be
 # packages that dropped po-debconf support
 echo "  Finding added/removed files/directories..."
-cd $POOTLEDEBCONFDIR
-find . -mindepth 3 -maxdepth 3 -type d | grep -v \\.svn | sort > /tmp/list-pootle
-cd $TEMPDIR
-find . -mindepth 3 -maxdepth 3 -type d | sort > /tmp/list-tarball
+cd "$POOTLEDEBCONFDIR"
+find . -mindepth 3 -maxdepth 3 -type d | grep -v \\.svn | sort > "$TMPDIR/list-pootle"
+cd "$TEMPDIR"
+find . -mindepth 3 -maxdepth 3 -type d | sort > "$TMPDIR/list-tarball"
 # We display the diff. It will be up to a human to delete/add
 # the relevant dirs in SVN (too dangerous)
-diff -d -I "lintian" -I "powertweak" /tmp/list-tarball  /tmp/list-pootle
+diff -d -I "lintian" -I "powertweak" "$TMPDIR/list-tarball" "$TMPDIR/list-pootle" || true
 
 # Cleaning out
 #Temporarily disabled to solve out a few issues
-#rm /tmp/list-tarball  /tmp/list-pootle >/dev/null 2>&1 || true
-rm -rf $TEMPDIR >/dev/null 2>&1 || true
+#rm "$TMPDIR/list-tarball" "$TMPDIR/list-pootle" >/dev/null 2>&1 || true
+rm -rf "$TEMPDIR" >/dev/null 2>&1 || true
 




More information about the Debian-l10n-commits mailing list