--- builds_bin/update_templates 2009/03/05 19:32:51 1.5 +++ builds_bin/update_templates 2010/03/04 18:16:04 1.13 @@ -1,207 +1,215 @@ #!/bin/bash # Functions -. /etc/pootle/bin/functions +. /var/lib/pootle/bin/functions # Clean up tmp dir -rm -rf /etc/pootle/tmp -mkdir -p /etc/pootle/tmp /var/www/html/{patches,errors,anaconda} +rm -rf /var/lib/pootle/tmp +mkdir -p /var/lib/pootle/tmp/ /var/www/html/{patches,errors,anaconda} #========================================================== export CVS_RSH=ssh # Update/expand smeserver cvs -cd /etc/pootle/cvs/smeserver -for pkg in */sme7 anaconda/sme8 +cd /var/lib/pootle/cvs/smeserver +for pkg in *e-smith*/sme* *sme*/sme* anaconda/sme* booty/sme* do make -C $pkg clean &> /dev/null done cvs update -dPA > /dev/null -for pkg in */sme7 anaconda/sme8 +for pkg in *e-smith*/sme* *sme*/sme* anaconda/sme* booty/sme* do make -C $pkg prep &> /dev/null done # Update/expand smecontribs cvs -cd /etc/pootle/cvs/smecontribs -for pkg in */contribs7 +cd /var/lib/pootle/cvs/smecontribs +for pkg in *e-smith*/contribs* *sme*/contribs* do make -C $pkg clean &> /dev/null done cvs update -dPA > /dev/null -for pkg in */contribs7 +for pkg in *e-smith*/contribs* *sme*/contribs* do make -C $pkg prep &> /dev/null done -cd /etc/pootle/tmp - #========================================================== -# Take server down to prevent translation issues -killall PootleServer +cd /var/lib/pootle/tmp -#========================================================== +for ver in sme7 sme8 +do + # Update anaconda template + anacondatmpl $ver > anaconda.pot + diffmv anaconda.pot /var/lib/pootle/po/$ver/templates/anaconda.pot + + # Update console templates + potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-quota/$ver/ -type f -name adminQuotaSummary.tmpl) > adminQuotaSummary.tmpl.pot + diffmv adminQuotaSummary.tmpl.pot /var/lib/pootle/po/$ver/templates/adminQuotaSummary.tmpl.pot + potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-backup/$ver/ -type f -name do_backup -o -regex '.*/crontab/backup') > backup-console.pot + diffmv backup-console.pot /var/lib/pootle/po/$ver/templates/backup-console.pot + potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-manager/$ver/ -type f -name 25Copyright) > foot.tmpl.pot + diffmv foot.tmpl.pot /var/lib/pootle/po/$ver/templates/foot.tmpl.pot + potempl $(find /var/lib/pootle/cvs/smeserver/*/$ver/ -type f -regex '.*/e-?smith/console.*') > server-console.pot + diffmv server-console.pot /var/lib/pootle/po/$ver/templates/server-console.pot + potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-quota/$ver/ -type f -name userOverQuota.tmpl) > userOverQuota.tmpl.pot + diffmv userOverQuota.tmpl.pot /var/lib/pootle/po/$ver/templates/userOverQuota.tmpl.pot -# Update anaconda templates -anacondatmpl > anaconda.pot -diffmv anaconda.pot /etc/pootle/po/sme7bc/templates/anaconda.pot - -# Update console templates -potempl $(find /etc/pootle/cvs/smeserver/e-smith-quota/ -type f -name adminQuotaSummary.tmpl) > adminQuotaSummary.tmpl.pot -diffmv adminQuotaSummary.tmpl.pot /etc/pootle/po/sme7bc/templates/adminQuotaSummary.tmpl.pot -potempl $(find /etc/pootle/cvs/smeserver/e-smith-backup/ -type f -name do_backup -o -regex '.*/crontab/backup') > backup.pot -diffmv backup.pot /etc/pootle/po/sme7bc/templates/backup.pot -potempl $(find /etc/pootle/cvs/smeserver/e-smith-manager/ -type f -name 25Copyright) > foot.tmpl.pot -diffmv foot.tmpl.pot /etc/pootle/po/sme7bc/templates/foot.tmpl.pot -potempl $(find /etc/pootle/cvs/smeserver/ -type f -regex '.*/e-?smith/console.*') > server-console.pot -diffmv server-console.pot /etc/pootle/po/sme7bc/templates/server-console.pot -potempl $(find /etc/pootle/cvs/smeserver/e-smith-quota/ -type f -name userOverQuota.tmpl) > userOverQuota.tmpl.pot -diffmv userOverQuota.tmpl.pot /etc/pootle/po/sme7bc/templates/userOverQuota.tmpl.pot - -# Update panel templates -for pkg in $(find /etc/pootle/cvs/smeserver/*/*7/*/root/etc/e-smith/locale/en-us/ -type f -print) -do - xmltempl $pkg "SME Panels" - diffcp /etc/pootle/templates/$(basename $pkg).pot /etc/pootle/po/sme7bp/templates/$(basename $pkg).pot -done - -# Update sme7admin templates -potempl /etc/pootle/cvs/smecontribs/smeserver-sme7admin/*/*/root/{etc/e-smith/web/functions/sme7admin,usr/bin/sme7admind} > sme7admin.pot -diffmv sme7admin.pot /etc/pootle/po/sme7cp/templates/sme7admin.pot + # Update panel templates + for pkg in $(find /var/lib/pootle/cvs/smeserver/*/$ver/*/root/etc/e-smith/locale/en-us/ -type f -not -regex '.*\+ldap/.*' 2> /dev/null) + do + xmltempl $ver $pkg + diffcp /var/lib/pootle/templates/$ver/$(basename $pkg).pot /var/lib/pootle/po/$ver/templates/$(basename $pkg).pot + done +done -# Update contrib panel templates -for pkg in $(find /etc/pootle/cvs/smecontribs/*/*7/*/root/etc/e-smith/locale/en-us/ -type f -print) +for ver in contribs7 contribs8 do - xmltempl $pkg "Contrib Panels" - diffcp /etc/pootle/templates/$(basename $pkg).pot /etc/pootle/po/sme7cp/templates/$(basename $pkg).pot + if [ "$ver" == "contribs7" ] + then + # Update sme7admin template + potempl /var/lib/pootle/cvs/smecontribs/smeserver-sme7admin/$ver/*/root/{etc/e-smith/web/functions/sme7admin,usr/bin/sme7admind} > sme7admin.pot + diffmv sme7admin.pot /var/lib/pootle/po/$ver/templates/sme7admin.pot + fi + + # Update contrib panel templates + for pkg in $(find /var/lib/pootle/cvs/smecontribs/*/$ver/*/root/etc/e-smith/locale/en-us/ -type f 2> /dev/null) + do + xmltempl $ver $pkg + diffcp /var/lib/pootle/templates/$ver/$(basename $pkg).pot /var/lib/pootle/po/$ver/templates/$(basename $pkg).pot + done done #========================================================== +# Create copy of po files without obsolete strings +rsync -amR --include '*/' --include '*.po' --exclude '*' /var/lib/pootle/po/./{sme,contribs}[0-9]/ /var/lib/pootle/tmp/errors/ +find /var/lib/pootle/tmp/errors/ -type f -exec sed -i '/^#~/d' {} \+ + # Apply templates to languages -for lang in $(ls -I templates /etc/pootle/po/sme* | grep '[[:alpha:]]$' | sort -u) +for lang in $(ls -I templates /var/lib/pootle/po/{sme,contribs}[0-9] 2> /dev/null | grep '[[:alpha:]]$' | sort -u) do - # Create error compendium to assist translators - pocompendium -e errors-$lang.po -d /etc/pootle/po/sme*/$lang - sed -i '0,/^$/d;/^#~/d' errors-$lang.po - sed -i ':a;/^\n*$/{$d;N;ba;}' errors-$lang.po - chmod 644 errors-$lang.po - diffmv errors-$lang.po /var/www/html/errors/errors-$lang.po - # Create compendium to assist translations - pocompendium -c /etc/pootle/tmp/compendium-$lang.po -d /etc/pootle/po/*/$lang + msgcat --use-first <(msgcat $(find /var/lib/pootle/tmp/errors/*/$lang/ -name '*.po') | msgattrib --translated --no-fuzzy) \ + <(msgcat $(find /var/lib/pootle/po/*/$lang/ -name '*.po') | msgattrib --translated --no-fuzzy) \ + > /var/lib/pootle/tmp/compendium-$lang.po # Use compendium to migrate each project to new template - for proj in $(ls -d /etc/pootle/po/sme*/$lang | sed 's@.*/\([^/]\+\)/[^/]\+$@\1@') + for ver in $(ls -d /var/lib/pootle/po/{sme,contribs}[0-9]/$lang 2> /dev/null | sed 's@.*/\([^/]\+\)/[^/]\+$@\1@') do - mkdir -p /etc/pootle/tmp/$proj/$lang - pomigrate2 -F -C=/etc/pootle/tmp/compendium-$lang.po -q --no-wrap --locale=$lang /etc/pootle/po/$proj/$lang /etc/pootle/tmp/$proj/$lang /etc/pootle/po/$proj/templates > /dev/null + mkdir -p /var/lib/pootle/tmp/$ver/$lang + pomigrate2 -F -C=/var/lib/pootle/tmp/compendium-$lang.po -q --locale=$lang \ + /var/lib/pootle/po/$ver/$lang /var/lib/pootle/tmp/$ver/$lang /var/lib/pootle/po/$ver/templates > /dev/null # Ensure language is correct - sed -i "/msgid \"en-us\"/{N;s@msgstr \"[^\"]*\"@msgstr \"$lang\"@}" /etc/pootle/tmp/$proj/$lang/* + sed -i "/msgid \"en-us\"/{N;s@msgstr \"[^\"]*\"@msgstr \"$lang\"@}" /var/lib/pootle/tmp/$ver/$lang/* 2> /dev/null + + # Set package version in po files + sed -i "s@\(Id-Version:\)[^\\]*@\1 SME $(echo $ver | sed 's@sme@Server @;s@contribs@Contribs @')@" /var/lib/pootle/tmp/$ver/$lang/*.po 2> /dev/null # Generate translation memory for panels - updatetm --progress none -c 4 -i /etc/pootle/tmp/$proj/$lang -t /etc/pootle/tmp/compendium-$lang.po -o /etc/pootle/tmp/$proj/$lang + updatetm --progress none -c 4 -i /var/lib/pootle/tmp/$ver/$lang -t /var/lib/pootle/tmp/compendium-$lang.po -o /var/lib/pootle/tmp/$ver/$lang + + find /var/lib/pootle/tmp/$ver/$lang -type f | while read pkg + do + # Move files that have changed + diffmv $pkg $(echo $pkg | sed 's@/tmp/@/po/@') + done done done -# Set package name/version in new po files -sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: SME Console\\n@' /etc/pootle/tmp/sme7bc/*/*.po -sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: SME Anadonda\\n@' /etc/pootle/tmp/sme7bc/*/anaconda.po -sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: SME Panels\\n@' /etc/pootle/tmp/sme7bp/*/*.po -sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: Contrib Panels\\n@' /etc/pootle/tmp/sme7cp/*/*.po - -# Move files that have changed -for chk in $(find /etc/pootle/tmp/sme* -type f) -do - diffmv $chk $(echo $chk | sed 's@/tmp/@/po/@') -done +# Copy po files so we can create error reports +rsync -amR --include '*/' --include '*.po' --exclude '*' /var/lib/pootle/po/./{sme,contribs}[0-9]/ /var/lib/pootle/tmp/errors/ #========================================================== # Recalculate stats and restart server -cd /etc/pootle -PootleServer --refreshstats &> /dev/null -nohup PootleServer --prefsfile /etc/pootle/pootle.prefs >> /var/log/pootle.log 2>&1 & +/usr/sbin/PootleServer --refreshstats &> /dev/null #========================================================== -cd /etc/pootle/tmp - -# Build diffs for languages -for lang in $(ls /etc/pootle/po/sme7bp -I templates) +# Create error compendium to assist translators +find /var/lib/pootle/tmp/errors/ -type f -exec sed -i '/^#~/d' {} \+ +for lang in $(ls -I templates /var/lib/pootle/po/{sme,contribs}[0-9] 2> /dev/null | grep '[[:alpha:]]$' | sort -u) do - # Build anaconda files - mkdir -p /var/www/html/anaconda/sme7/$lang/LC_MESSAGES - anacondagen sme7 $lang > /var/www/html/anaconda/sme7/$lang/LC_MESSAGES/anaconda.mo - [ -s /var/www/html/anaconda/sme7/$lang/LC_MESSAGES/anaconda.mo ] || rm -rf /var/www/html/anaconda/sme7/$lang - - mkdir -p /var/www/html/anaconda/sme8/$lang/LC_MESSAGES - anacondagen sme8 $lang > /var/www/html/anaconda/sme8/$lang/LC_MESSAGES/anaconda.mo - [ -s /var/www/html/anaconda/sme8/$lang/LC_MESSAGES/anaconda.mo ] || rm -rf /var/www/html/anaconda/sme8/$lang - - # Build console files - pkgname=$(ls -d /etc/pootle/cvs/smeserver/smeserver-locale/*7/*/root | cut -d/ -f8) - mkdir -p ${pkgname}.update/po/$lang - for pkg in $(ls /etc/pootle/po/sme7bc/templates/ -I anaconda.pot | sed -n 's@\.pot@\.po@p') - do - msgcat -F --no-wrap /etc/pootle/po/sme7bc/$lang/$pkg \ - | grep -v 'Project-Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|X-Generator' \ - | sed '0,/msgid ""/{/^#/d};/^#,/d' \ - > ${pkgname}.update/po/$lang/$pkg - done - - # Build sme7admin file - pkgname=$(ls -d /etc/pootle/cvs/smecontribs/smeserver-sme7admin/*7/*/root | cut -d/ -f8) - mkdir -p ${pkgname}.update/po/$lang - msgcat -F --no-wrap /etc/pootle/po/sme7cp/$lang/sme7admin.po \ - | grep -v 'Project-Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|X-Generator' \ - | sed '0,/msgid ""/{/^#/d};/^#,/d' \ - > ${pkgname}.update/po/$lang/sme7admin.po + msgcat $(find /var/lib/pootle/tmp/errors/*/$lang/ -name '*.po') \ + | msgattrib --only-fuzzy \ + | sed '0,/^$/d;/^#~/d' \ + | sed ':a;/^\n*$/{$d;N;ba;}' \ + > errors-$lang.po + chmod 644 errors-$lang.po + diffmv errors-$lang.po /var/www/html/errors/errors-$lang.po done -# Build translated xml files -for pkg in $(ls /etc/pootle/po/sme7*p/templates/ -I sme7admin.pot | sed -n 's@\.pot@@p') +# Build diffs for languages +for pkg in $(ls /var/lib/pootle/po/{sme,contribs}[0-9]/templates/ | sed -n 's@\.pot@@p' | sort -u) do - pkgname=$(find /etc/pootle/cvs/smecontribs/*/*7/*/root/etc/e-smith/locale/en-us -name $pkg | cut -d/ -f8) - if [ -z "$pkgname" ] + pkgs=$(find /var/lib/pootle/cvs/*/*/*/*/root/etc/e-smith/locale/en-us -name $pkg -not -regex '.*\+ldap/.*') + if [ -z "$pkgs" ] then - if [ -z "$(find /etc/pootle/cvs/smeserver/*/*7/*/root/etc/e-smith/locale/en-us -name $pkg)" ] - then - echo -e "\n *** Can't find package for $pkg ***\n" - continue - fi - pkgname=$(ls -d /etc/pootle/cvs/smeserver/smeserver-locale/*7/*/root | cut -d/ -f8) + if [ $pkg == "anaconda" ] + then + ls /var/lib/pootle/po/*/*/$pkg.po | cut -d/ --output-delimiter " " -f6,7 | while read ver lang + do + mkdir -p /var/www/html/anaconda/$ver/$lang/LC_MESSAGES + anacondagen $ver $lang > /var/www/html/anaconda/$ver/$lang/LC_MESSAGES/anaconda.mo + [ -s /var/www/html/anaconda/$ver/$lang/LC_MESSAGES/anaconda.mo ] || rm -rf /var/www/html/anaconda/$ver/$lang + done + else + pkgs=$(ls -d /var/lib/pootle/cvs/*/smeserver-$pkg/*/*/root 2> /dev/null) + [ -z "$pkgs" ] && pkgs=$(ls -d /var/lib/pootle/cvs/*/smeserver-locale/*/*/root) + + echo "$pkgs" | cut -d/ --output-delimiter " " -f8,9 | while read ver pkgname + do + for lang in $(ls -I templates /var/lib/pootle/po/$ver/ 2> /dev/null | grep '[[:alpha:]]$' | sort -u) + do + mkdir -p diff/$ver/${pkgname}.update/po/$lang + msgcat -F --no-wrap /var/lib/pootle/po/$ver/$lang/${pkg}.po \ + | grep -v 'Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|X-Generator' \ + | sed '0,/msgid ""/{/^#/d};/^#,/d;s@^\(#: \)[^/]\+/root@\1root@' \ + > diff/$ver/${pkgname}.update/po/$lang/${pkg/backup-console/backup}.po + done + done + fi else - mkdir -p ${pkgname}.update/$(localedir en-us $pkg) - cat /etc/pootle/templates/$pkg.orig \ - | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \ - > ${pkgname}.update/$(localedir en-us $pkg)/$pkg + echo "$pkgs" | grep -qv '/contribs[0-9]/' && pkgs=$(echo "$pkgs" | grep '/contribs[0-9]/'; ls -d /var/lib/pootle/cvs/*/smeserver-locale/*/*/root) + echo "$pkgs" | cut -d/ --output-delimiter " " -f8,9 | while read ver pkgname + do + if echo $ver | grep -q contribs + then + mkdir -p diff/$ver/${pkgname}.update/$(localedir en-us $pkg) + cat /var/lib/pootle/templates/$ver/$pkg.orig \ + | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \ + > diff/$ver/${pkgname}.update/$(localedir en-us $pkg)/$pkg + fi + for lang in $(ls -I templates /var/lib/pootle/po/$ver/ 2> /dev/null | grep '[[:alpha:]]$' | sort -u) + do + mkdir -p diff/$ver/${pkgname}.update/$(localedir $lang $pkg) + xmlgen $ver /var/lib/pootle/po/$ver/$lang/${pkg}.po \ + > diff/$ver/${pkgname}.update/$(localedir $lang $pkg)/$pkg + done + done fi - for lang in $(ls /etc/pootle/po/sme7bp -I templates) - do - mkdir -p ${pkgname}.update/$(localedir $lang $pkg) - xmlgen /etc/pootle/po/sme7*p/$lang/${pkg}.po \ - > ${pkgname}.update/$(localedir $lang $pkg)/$pkg - done done -# Build xml diffs -for pkg in $(ls -d *.update | sed 's@.update$@@') +# Build diffs +ls -d diff/*/* | sed 's@.update$@@' | cut -d/ --output-delimiter " " -f2,3 | while read ver pkg do - orig=/etc/pootle/cvs/sme*/*/*7/$pkg/root/etc/e-smith/locale - rm -f /var/www/html/patches/$(echo $pkg | sed 's/-[^-]\+$//')-*-locale-*.patch - diff -ruN $orig $pkg.update/root/etc/e-smith/locale \ - | sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/root/.*\)@\1 \2@;/^diff -ruN/d' \ - > /var/www/html/patches/$pkg-locale-$(date +%F).patch -done - -# Build console diffs -pkg=$(ls -d smeserver-locale-* | sed 's@.update$@@') -orig=/etc/pootle/cvs/smeserver/smeserver-locale/*7/$pkg/po -diff -ruN $orig $pkg.update/po \ -| sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/po/.*\)@\1 \2@;/^diff -ruN/d' \ ->> /var/www/html/patches/$pkg-locale-$(date +%F).patch + mkdir -p /var/www/html/patches/$ver + rm -f /var/www/html/patches/$ver/$(echo $pkg | sed 's/-[^-]\+$//')-*-locale-*.patch + if [ -d "diff/$ver/$pkg.update/root" ] + then + diff -ruN {/var/lib/pootle/cvs/*/*/$ver/$pkg,diff/$ver/$pkg.update}/root/etc/e-smith/locale \ + | sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/root/.*\)@\1 \2@;/^diff -ruN/d' \ + >> /var/www/html/patches/$ver/$pkg-locale-$(date +%F).patch + fi + if [ -d "diff/$ver/$pkg.update/po" ] + then + diff -ruN {/var/lib/pootle/cvs/*/*/$ver/$pkg,diff/$ver/$pkg.update}/po \ + | sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/po/.*\)@\1 \2@;/^diff -ruN/d' \ + >> /var/www/html/patches/$ver/$pkg-locale-$(date +%F).patch + fi +done