[Debian-l10n-commits] r1074 - /dl10n/trunk/pootle/sync-projects.d/10debconf

bubulle at users.alioth.debian.org bubulle at users.alioth.debian.org
Sun Jul 20 17:32:51 UTC 2008


Author: bubulle
Date: Sun Jul 20 17:32:51 2008
New Revision: 1074

URL: http://svn.debian.org/wsvn/?sc=1&rev=1074
Log:
Improved version:
- more comments
- some cleaning
- now display the diff between Pootle and the tarball to allow removing
  stuff in SVN
- and some more cleaning..:-)

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

Modified: dl10n/trunk/pootle/sync-projects.d/10debconf
URL: http://svn.debian.org/wsvn/dl10n/trunk/pootle/sync-projects.d/10debconf?rev=1074&op=diff
==============================================================================
--- dl10n/trunk/pootle/sync-projects.d/10debconf (original)
+++ dl10n/trunk/pootle/sync-projects.d/10debconf Sun Jul 20 17:32:51 2008
@@ -6,28 +6,49 @@
 rm $TEMPDIR
 PROJECTDIR=/var/lib/pootle/debconf
 
+# Packages that are false positives: they don't really have po-debconf
+# translations
+IGNORE="lintian powertweak"
+
+# tarball location
+TARBALL=/org/dl10n-stuff/www/po-debconf.tar.gz
+[ -f $TARBALL ] || exit 1
+
+# First we extract the tarball in the temporary directory
 echo "  Extract files gathered from the archive"
 mkdir $TEMPDIR
 cd $TEMPDIR
 umask 002
-tar xfz /org/dl10n-stuff/www/po-debconf.tar.gz
+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
 #	echo -n "."
+        # Files are originall in debian/po. Move them the the root
+        # of the directory
 	mv $pkg/debian/po/*gz $pkg 2>/dev/null
+	# And clean out the remaining stuff
 	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
 	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
+		        # Rename the file to "templates.pot"
 			mv $pots $pkg/`basename $pots | sed "s/$root//g"`
 		done
 		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
 			else
@@ -37,34 +58,58 @@
 			fi
 		done
 	done
+	# Now we have a directory withe only $LANGUAGE.po and templates.pot
 	TEMPFILE=`tempfile`
 #	echo "    Updating $PROJECTDIR/$pkg"
+	# 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
+	# 
+	# 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 $PROJECTDIR/$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 $PROJECTDIR/$pkg/$filename ] ; then
+			        # Give priority to the file in Pootle
 				msgcat --use-first $PROJECTDIR/$pkg/$filename $pofile >$TEMPFILE 2>/dev/null
+				# And merge with the POT file from the tarball
 				msgmerge -U $TEMPFILE $PROJECTDIR/$pkg/templates.pot >/dev/null 2>&1
+				# And overwrite the Pootle file
 				cp $TEMPFILE $PROJECTDIR/$pkg/$filename
 			else
+			        # Maybe *that* file didn't exist in Pootle
+			        # In such case, just copy it
 				cp $pofile $PROJECTDIR/$pkg
 				msgmerge -U $PROJECTDIR/$pkg/$filename $PROJECTDIR/$pkg/templates.pot  >/dev/null 2>&1
 			fi
 		done
 	else
+	        # There was no directory in Pootle yet, just copy
 		mkdir -p $PROJECTDIR/$pkg
 		cp -r $pkg/* $PROJECTDIR/$pkg
 	fi
 	rm $TEMPFILE 2>/dev/null || true
 done
 
+# Now we have the Pootle directory updated with files from the tarball
+# Let's do some cleaning'
+
+# When there are known broken files, let's clean them
 echo "  Cleaning out broken files"
 
+# Some packages should be ignored for various reasons
+echo "  Cleaning out ignored packages"
+for $pkg in $IGNORE; do
+ echo "    $pkg"
+ rm -rf `find $PROJECTDIR -mindepth 3 -maxdepth 3 -name $pkg` #2>/dev/null
+done
+
+# And some packages provide useless garbage 
 echo "  Cleaning out garbage"
-echo "    lintian"
-rm -rf $PROJECTDIR/main/l/lintian #2>/dev/null
-echo "    powertweak"
-rm -rf $PROJECTDIR/main/p/powertweak #2>/dev/null
 echo "    openttd"
 rm -rf $PROJECTDIR/contrib/o/openttd/os #2>/dev/null
 echo "    clamav-getfiles"
@@ -80,8 +125,14 @@
 echo "    root-system"
 rm -rf $PROJECTDIR/main/r/root-system/build #2>/dev/null
 
+# What languages are present?
 LANGUAGES=`find $PROJECTDIR -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
 
+# Now we fill in all packages directories with one file per language
+# That's slightly suboptimal but this is the only way to have correct
+# statistics in Pootle
 echo "  Updating Pootle files:"
 for pkg in `find $PROJECTDIR -maxdepth 3 -mindepth 3 -type d` ; do
 #	echo -n "."
@@ -89,7 +140,7 @@
 		if [ ! -f $pkg/$lang.po ] ; then
 			cp $pkg/templates.pot $pkg/$lang.po
 		else
-			msgmerge -U $pkg/lang.po templates.pot >/dev/null 2>&1
+			msgmerge -U $pkg/lang.po $pkg/templates.pot >/dev/null 2>&1
 		fi
 	done
 #	echo " Done."
@@ -98,4 +149,23 @@
 
 rm -rf $TEMPDIR >/dev/null 2>&1 || true
 
+# Now commit the whole stuff to SVN
+echo "  Committing to SVN"
+cd $PROJECTDIR
+echo "   Adding new directories"
+# find . -type d | grep -v \.svn | xargs svn add -N
+echo "   Adding PO files"
+# find . -type f -name \*.po | grep -v \.svn | xargs svn add
+echo "   Adding POT files"
+# find . -type f -name templates.pot | grep -v \.svn | xargs svn add
 
+# Now we need to find out what directories are in $PROJECTDIR but
+# aren't anymore in the tarball. Most of the time, this will be
+# packages that dropped po-debconf support
+cd $PROJECTDIR
+find . -mindepth 3 -maxdepth 3 -type d | grep -v \.svn > /tmp/list-pootle
+cd $TEMPDIR/po/unstable
+find . -mindepth 3 -maxdepth 3 -type d > /tmp/list-tarball
+# We display the diff. It will be up to a human to delete
+# the relevant dirs in SVN (too dangerous)
+diff -d -I "lintian" -I "powertweak" /tmp/list-tarball  /tmp/list-pootle




More information about the Debian-l10n-commits mailing list