diff --git a/translation-update-upstream.changes b/translation-update-upstream.changes index 4951e55..af9e7b8 100644 --- a/translation-update-upstream.changes +++ b/translation-update-upstream.changes @@ -1,9 +1,10 @@ ------------------------------------------------------------------- -Fri Aug 19 16:38:20 CEST 2011 - sbrabec@suse.cz +Tue Sep 6 16:46:07 CEST 2011 - sbrabec@suse.cz - Supplementary scripts improvements: * Support for pot-only run (COLLECT_UPSTREAM=false). * Implemented check for possible strings in patches. + * Support for import of strings from different gettext domain. ------------------------------------------------------------------- Thu Jul 7 20:57:26 CEST 2011 - sbrabec@suse.cz diff --git a/upstream-collect.sh b/upstream-collect.sh index 4f0877c..3831629 100644 --- a/upstream-collect.sh +++ b/upstream-collect.sh @@ -10,7 +10,6 @@ DEBUG=false # Set to false to generate only pot files, true to collect po files. COLLECT_UPSTREAM=true -# FIXME: false has problems with stamps!!! # Number of CPUs. When > 1, then parallel processing of more po files is possible. CPUS=$(cat /proc/cpuinfo | grep processor | wc -l) WORK_DIR=$PWD @@ -20,6 +19,13 @@ shopt -s nullglob source ${0%.sh}.conf +function get_pot_name { + POT= + for POT in *.pot ; do + : + done +} + function rpmprep { RPMDIR=$HOME/.var.rpmpatch$$ rm -rf BUILD $HOME/.var.rpmpatch$$ @@ -81,11 +87,14 @@ mkdir -p ~/.upstream-collect.tmp cat >~/.upstream-collect.tmp/translation-update-upstream <\${1:-po}/.translation-update-upstream-implemented +echo \${3:-intltool-update\${2+ --gettext-package=\$2} --pot} >\${1:-po}/.translation-update-upstream-implemented cd \${1:-po} # Generate and save a copy of the pot file now and compare later. -\${3:-intltool-update --gettext-package=\${2:-\$T_U_U_DOMAIN} --pot} -mv \${2:-\$T_U_U_DOMAIN}.pot \${2:-\$T_U_U_DOMAIN}-t-u-u.pot +eval \${3:-intltool-update\${2+ --gettext-package=\$2} --pot} +mkdir -p tuu +for POT in *.pot ; do + mv \$POT tuu/ +done EOF chmod +x ~/.upstream-collect.tmp/translation-update-upstream @@ -118,13 +127,13 @@ if ! $FULL_PROCESS ; then for ARCHIVE_ in translation-update-upstream-*.tar.bz2 ; do ARCHIVE=$ARCHIVE_ done - if ! test -d UPDATE_OLD ; then - mkdir UPDATE_OLD - cd UPDATE_OLD + if ! test -f STAMPS/UPDATE_old_tarball ; then + cd UPDATE tar -jxf ../$ARCHIVE # If it is not a full process, increment only release # SNAPSHOT 20090213 -> 20090213.1, 20090213.1 -> 20090213.2 cd .. + touch STAMPS/UPDATE_old_tarball fi SNAPSHOT=${ARCHIVE#translation-update-upstream-} SNAPSHOT=${SNAPSHOT%.tar.bz2} @@ -158,7 +167,7 @@ for TLST in *.tlst ; do fi echo - echo "$(tput setf 3)Processing: package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:-(default)} mandatory=$MANDATORY$(tput init)" + echo "$(tput setf 3)Processing: package=$PACKAGE domain=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:-(default)} mandatory=$MANDATORY$(tput init)" # NOTE: Force a limitation: tlst rules for one package must be placed on contiguous line sequence if ! $DEBUG ; then @@ -184,31 +193,16 @@ for TLST in *.tlst ; do fi done if $SKIP_PACKAGE ; then - if test -d $WORK_DIR/UPDATE_OLD/po/$DOMAIN ; then - if test -d $WORK_DIR/UPDATE/po/$DOMAIN ; then - echo "Should not happen. Internal error." - exit 255 - else - echo " Not scheduled to process. Recycling old update..." - mkdir -p $WORK_DIR/UPDATE/po - mv $WORK_DIR/UPDATE_OLD/po/$DOMAIN $WORK_DIR/UPDATE/po/ - fi - else - if test -d $WORK_DIR/UPDATE/po/$DOMAIN ; then - echo " Already recycled old update..." - else - echo " Not scheduled to process. No update available..." - fi - fi - mkdir -p $WORK_DIR/STAMPS/$PACKAGE/$DOMAIN/$METHOD/${REPO//[\/:.]/_}/$DIR/${BRANCH:-__HEAD__} - touch $WORK_DIR/STAMPS/$PACKAGE/.builddir_ok + echo " Not scheduled to process. Recycling old update..." +#FIXME mkdir -p $WORK_DIR/STAMPS/$PACKAGE/$DOMAIN/$METHOD/${REPO//[\/:.]/_}/$DIR/${BRANCH:-__HEAD__} +# touch $WORK_DIR/STAMPS/$PACKAGE/.builddir_ok continue fi fi cd $WORK_DIR/OSC - RPMPKGDIR=$(echo $WORK_DIR/PACKAGES/$PACKAGE) + RPMPKGDIR=$WORK_DIR/PACKAGES/$PACKAGE if ! test -f $WORK_DIR/STAMPS/$PACKAGE/.builddir_ok ; then if ! test -d "$RPMPKGDIR" ; then @@ -235,9 +229,8 @@ for TLST in *.tlst ; do echo "$(tput setf 4)Removed possibly incorrect temporary files from previous runs. Please re-run $0 now.$(tput init)" exit 1 fi - RPMPKGDIR=$(echo $WORK_DIR/PACKAGES/$PACKAGE) cd $RPMPKGDIR - T_U_U_DOMAIN=$DOMAIN rpmprep $PACKAGE.spec + rpmprep $PACKAGE.spec else # During processing, builddir may contain incomplete po files: rm $WORK_DIR/STAMPS/$PACKAGE/.builddir_ok @@ -250,39 +243,48 @@ for TLST in *.tlst ; do fi cd $RPMPODIR + get_pot_name + REAL_DOMAIN=${POT%.pot} if test -f .gnome-patch-translation-implemented ; then echo $PACKAGE >>$WORK_DIR/gnome-patch-translation.lst fi if test -f .translation-update-upstream-implemented ; then if bash ./.translation-update-upstream-implemented ; then - cp -a $DOMAIN.pot $WORK_DIR/pot/ - cp -a $DOMAIN-t-u-u.pot $WORK_DIR/pot-tuu/$DOMAIN.pot + get_pot_name + REAL_DOMAIN=${POT%.pot} + cp -a $REAL_DOMAIN.pot $WORK_DIR/pot/ + # pot-tuu DOMAIN is the external domain - LCN may use different domain + cp -a tuu/$REAL_DOMAIN.pot $WORK_DIR/pot-tuu/$DOMAIN.pot # Verify that patches don't introduce new strings. - msgcomm --uniq $DOMAIN.pot $DOMAIN-t-u-u.pot -o $WORK_DIR/pot-diff/$DOMAIN.pot + msgcomm --uniq $REAL_DOMAIN.pot tuu/$REAL_DOMAIN.pot -o $WORK_DIR/pot-diff/$DOMAIN.pot if ! test -f .gnome-patch-translation-implemented ; then if test -f $WORK_DIR/pot-diff/$DOMAIN.pot ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: new pot file contains unique strings, please check gnome-patch-translation" + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN gettext-package=$REAL_DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: new pot file contains unique strings, please check gnome-patch-translation" fi fi else # translation-update-upstream is implemented but fails: - if test -f $DOMAIN.pot ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: pot file update error, continuing with original $DOMAIN.pot" + get_pot_name + REAL_DOMAIN=${POT%.pot} + if test -f $REAL_DOMAIN.pot ; then + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: pot file update error, continuing with original $DOMAIN.pot" cp -a $DOMAIN.pot $WORK_DIR/pot/ else - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: pot file update error, no way to update" + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: pot file update error, no way to update" mkdir -p $WORK_DIR/STAMPS/$PACKAGE/$DOMAIN/$METHOD/${REPO//[\/:.]/_}/$REPODIR/${BRANCH:-__HEAD__} continue fi fi else echo "$RPMPODIR: Missing or incorrect translation-update-upstream in the spec file." - # translation-update-upstream is implemented, try the default: + # translation-update-upstream is implemented, try the default with the upstream domain: if intltool-update --gettext-package=$DOMAIN --pot ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: packaging error, package does not call translation-update-upstream properly" + get_pot_name + REAL_DOMAIN=${POT%.pot} + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN gettext-package=$REAL_DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: packaging error, package does not call translation-update-upstream properly" cp -a $DOMAIN.pot $WORK_DIR/pot/ else - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: packaging error, package does not call translation-update-upstream properly and intltool-update fails, no way to update" + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)}: packaging error, package does not call translation-update-upstream properly and intltool-update fails, no way to update" mkdir -p $WORK_DIR/STAMPS/$PACKAGE/$DOMAIN/$METHOD/${REPO//[\/:.]/_}/$REPODIR/${BRANCH:-__HEAD__} continue fi @@ -431,35 +433,35 @@ for TLST in *.tlst ; do ( if $MANDATORY ; then # Mandatory sources: copy the whole source to the mandatory po directory. Strings must not be skipped. - mkdir -p $WORK_DIR/UPDATE/po-mandatory/$DOMAIN - if test -f $WORK_DIR/UPDATE/po-mandatory/$DOMAIN/$PO ; then - msgcat --use-first $PO $WORK_DIR/UPDATE/po-mandatory/$DOMAIN/$PO -o $WORK_DIR/UPDATE/po-mandatory/$DOMAIN/$PO~ - mv $WORK_DIR/UPDATE/po-mandatory/$DOMAIN/$PO~ $WORK_DIR/UPDATE/po-mandatory/$DOMAIN/$PO + mkdir -p $WORK_DIR/UPDATE/po-mandatory/$REAL_DOMAIN + if test -f $WORK_DIR/UPDATE/po-mandatory/$REAL_DOMAIN/$PO ; then + msgcat --use-first $PO $WORK_DIR/UPDATE/po-mandatory/$REAL_DOMAIN/$PO -o $WORK_DIR/UPDATE/po-mandatory/$REAL_DOMAIN/$PO~ + mv $WORK_DIR/UPDATE/po-mandatory/$REAL_DOMAIN/$PO~ $WORK_DIR/UPDATE/po-mandatory/$REAL_DOMAIN/$PO else - msgcat $PO -o $WORK_DIR/UPDATE/po-mandatory/$DOMAIN/$PO + msgcat $PO -o $WORK_DIR/UPDATE/po-mandatory/$REAL_DOMAIN/$PO fi else # step 0: Merge new po file into old project. Removes unused (too new) translations. - if ! msgmerge --no-fuzzy-matching $PO $RPMPODIR/$DOMAIN.pot -o ${PO%.po}-backport.po~ ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)} po=$PO: msgmerge error" + if ! msgmerge --no-fuzzy-matching $PO $RPMPODIR/$REAL_DOMAIN.pot -o ${PO%.po}-backport.po~ ; then + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN gettext-package=$REAL_DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)} po=$PO: msgmerge error" continue fi if test -f $RPMPODIR/$PO ; then # step 1: Clean the RPM po file to be safe. - if ! msgmerge --no-fuzzy-matching $RPMPODIR/$PO $RPMPODIR/$DOMAIN.pot -o $RPMPODIR/${PO%.po}-downstream.po ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN repository=$REPO directory=$RPMPODIR branch=${BRANCH:(default)} po=$PO: package msgmerge error" + if ! msgmerge --no-fuzzy-matching $RPMPODIR/$PO $RPMPODIR/$REAL_DOMAIN.pot -o $RPMPODIR/${PO%.po}-downstream.po ; then + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN gettext-package=$REAL_DOMAIN repository=$REPO directory=$RPMPODIR branch=${BRANCH:(default)} po=$PO: package msgmerge error" # Failed initial msgmerge is fatal. There is no way to update. Build may fail. continue fi # Do the magic: # step 2: Merge new upstream po and previous upstream updates to RPM po (if any). OLD_UPDATE=false - if test -f $WORK_DIR/UPDATE/po/$DOMAIN/$PO ; then - if $WORK_DIR/msgheadermerge $WORK_DIR/UPDATE/po/$DOMAIN/$PO $PO ${PO%.po}-uheader.po --mergemode --continue ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN repository=$REPO directory=$RPMPODIR branch=${BRANCH:(default)} po=$PO: old po file, skipping fixes" + if test -f $WORK_DIR/UPDATE/po/$REAL_DOMAIN/$PO ; then + if $WORK_DIR/msgheadermerge $WORK_DIR/UPDATE/po/$REAL_DOMAIN/$PO $PO ${PO%.po}-uheader.po --mergemode --continue ; then + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN gettext-package=$REAL_DOMAIN repository=$REPO directory=$RPMPODIR branch=${BRANCH:(default)} po=$PO: old po file, skipping fixes" OLD_UPDATE=true fi - msgcat --force-po --use-first ${PO%.po}-uheader.po ${PO%.po}-backport.po~ $WORK_DIR/UPDATE/po/$DOMAIN/$PO -o ${PO%.po}-upstream.po + msgcat --force-po --use-first ${PO%.po}-uheader.po ${PO%.po}-backport.po~ $WORK_DIR/UPDATE/po/$REAL_DOMAIN/$PO -o ${PO%.po}-upstream.po else cp -a ${PO%.po}-backport.po~ ${PO%.po}-upstream.po fi @@ -491,7 +493,7 @@ for TLST in *.tlst ; do if test -f ${PO%.po}-additions.po~ ; then msgattrib --no-obsolete --force-po ${PO%.po}-additions.po~ -o ${PO%.po}-additions.po mkdir -p $WORK_DIR/po-review/${PO%.po}/additions - msgcat --use-first ${PO%.po}-header.po ${PO%.po}-additions.po -o $WORK_DIR/po-review/${PO%.po}/additions/$DOMAIN.po + msgcat --use-first ${PO%.po}-header.po ${PO%.po}-additions.po -o $WORK_DIR/po-review/${PO%.po}/additions/$REAL_DOMAIN.po rmdir --ignore-fail-on-non-empty --parents $WORK_DIR/po-review/${PO%.po}/additions fi if test -f ${PO%.po}-fixes.po~ ; then @@ -504,16 +506,16 @@ for TLST in *.tlst ; do msgcat ${PO%.po}-fixes-review.po~~ -o ${PO%.po}-fixes-review.po if $OLD_UPDATE ; then mkdir -p $WORK_DIR/po-review/${PO%.po}/excluded-changes/${REPO//[\/:.]/_}/$REPODIR - cp -a ${PO%.po}-fixes-clean.po $WORK_DIR/po-review/${PO%.po}/excluded-changes/${REPO//[\/:.]/_}/$REPODIR/$DOMAIN.po - cp -a ${PO%.po}-fixes-review.po $WORK_DIR/po-review/${PO%.po}/excluded-changes/${REPO//[\/:.]/_}/$REPODIR/$DOMAIN-review.po + cp -a ${PO%.po}-fixes-clean.po $WORK_DIR/po-review/${PO%.po}/excluded-changes/${REPO//[\/:.]/_}/$REPODIR/$REAL_DOMAIN.po + cp -a ${PO%.po}-fixes-review.po $WORK_DIR/po-review/${PO%.po}/excluded-changes/${REPO//[\/:.]/_}/$REPODIR/$REAL_DOMAIN-review.po rmdir --ignore-fail-on-non-empty --parents $WORK_DIR/po-review/${PO%.po}/excluded-changes/${REPO//[\/:.]/_}/$REPODIR if test -d $WORK_DIR/po-review/${PO%.po}/excluded-changes ; then echo -e "Excluded changes contains changes introduced by upstream po files with\ntime stamp older than our package." >$WORK_DIR/po-review/${PO%.po}/excluded-changes/README fi else mkdir -p $WORK_DIR/po-review/${PO%.po}/changes - cp -a ${PO%.po}-fixes-clean.po $WORK_DIR/po-review/${PO%.po}/changes/$DOMAIN.po - cp -a ${PO%.po}-fixes-review.po $WORK_DIR/po-review/${PO%.po}/changes/$DOMAIN-review.po + cp -a ${PO%.po}-fixes-clean.po $WORK_DIR/po-review/${PO%.po}/changes/$REAL_DOMAIN.po + cp -a ${PO%.po}-fixes-review.po $WORK_DIR/po-review/${PO%.po}/changes/$REAL_DOMAIN-review.po rmdir --ignore-fail-on-non-empty --parents $WORK_DIR/po-review/${PO%.po}/changes fi fi @@ -529,20 +531,20 @@ for TLST in *.tlst ; do fi if test -f $RPMPODIR/${PO%.po}-updates.po ; then if ! msgcat --force-po --use-first ${PO%.po}-backport.po $RPMPODIR/${PO%.po}-updates.po -o $RPMPODIR/${PO%.po}-updates.po~ ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)} po=$PO: msgcat error" + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN gettext-package=$REAL_DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)} po=$PO: msgcat error" continue fi mv $RPMPODIR/${PO%.po}-updates.po~ $RPMPODIR/${PO%.po}-updates.po else # To get surely a valid po file, use msgcat instead of cp. if ! msgcat ${PO%.po}-backport.po -o $RPMPODIR/${PO%.po}-updates.po ; then - echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE gettext-package=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)} po=$PO: msgcat error" + echo >>$WORK_DIR/upstream-collect.log "package=$PACKAGE domain=$DOMAIN gettext-package=$REAL_DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:(default)} po=$PO: msgcat error" continue fi fi # step 2: Prepare texts for review. mkdir -p $WORK_DIR/po-review/${PO%.po}/new-files - cp -a $RPMPODIR/${PO%.po}-updates.po $WORK_DIR/po-review/${PO%.po}/new-files/$DOMAIN.po + cp -a $RPMPODIR/${PO%.po}-updates.po $WORK_DIR/po-review/${PO%.po}/new-files/$REAL_DOMAIN.po rmdir --ignore-fail-on-non-empty --parents $WORK_DIR/po-review/${PO%.po}/new-files fi fi @@ -572,11 +574,11 @@ for TLST in *.tlst ; do wait fi - mkdir -p $WORK_DIR/UPDATE/po/$DOMAIN + mkdir -p $WORK_DIR/UPDATE/po/$REAL_DOMAIN cd $RPMPODIR for POX in *-updates.po ; do PO=${POX/-updates/} - cp -a $POX $WORK_DIR/UPDATE/po/$DOMAIN/$PO + cp -a $POX $WORK_DIR/UPDATE/po/$REAL_DOMAIN/$PO done if ! $DEBUG ; then