From 02f723f87f92f2b3f59934048492ea0345b4913b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 8 Sep 2010 20:36:08 +0300 Subject: [PATCH] Add multithreading to backport script. --- backport | 26 +++++++++++++++++++++++--- poupdate | 11 ++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/backport b/backport index 6e9eb98..e4e5a8d 100755 --- a/backport +++ b/backport @@ -2,10 +2,30 @@ source "`dirname $0`/ths-variables" -./poupdate -NS trunk stable pot-stable -./poupdate -NS doc-trunk doc-stable doc-pot-stable +function jobidfromstring() +{ + local STRING; + local RET; -echo -e $BLUE"Running sed script on all files..."$ENDCOLOR + STRING=$1; + RET="$(echo $STRING | sed 's/^[^0-9]*//' | sed 's/[^0-9].*$//')" + + echo $RET; +} + +echo -e $BLUE"Running poupdate..."$ENDCOLOR +./poupdate -NS --silent trunk stable pot-stable & +LASTJOB=`jobidfromstring $(jobs %%)` +JOBLIST="$LASTJOB" +./poupdate -NS --silent doc-trunk doc-stable doc-pot-stable & +LASTJOB=`jobidfromstring $(jobs %%)` +JOBLIST="$JOBLIST $LASTJOB" + +for JOB in $JOBLIST ; do + wait %$JOB +done + +echo -e $BLUE"Running sed script..."$ENDCOLOR for po in `find stable doc-stable -follow -name "*.po"`; do sed -ie 's/\"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10==1 \&\& n%100!=11 ? 1 : n\"/\"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10==1 \&\& n%100!=11 ? 1 : n%\"/ diff --git a/poupdate b/poupdate index 4233a3f..0ae9b7c 100755 --- a/poupdate +++ b/poupdate @@ -46,6 +46,7 @@ function usage() { echo " as secondary (default - use the new files" echo " as primary translations)" echo " -v|--verbose - print msgmerge output" + echo " -s|--silent - print only summary" exit 1 } @@ -61,6 +62,10 @@ do option_verbose="Y" shift ;; + -s|--silent) + option_silent="Y" + shift + ;; -*|--*) usage ;; @@ -89,8 +94,8 @@ changed_files=0 if [ "$option_verbose" = "Y" ]; then echo "Checking if updated files are in the specified directory ..." -else - echo -ne "\r$processed_files/$total_files merged" +elif [ ! "$option_silent" = "Y" ]; then + echo -ne "\r$processed_files/$total_files processed" fi if [ "$newtrans" == "" ]; then echo -e $RED"\t\t... no updated files found in: $upd_dir"$ENDCOLOR @@ -187,7 +192,7 @@ fi rm $tra_tree/${trafile}.old $tra_tree/${trafile}.new processed_files=$(($processed_files+1)) -if [ ! "$option_verbose" = "Y" ]; then +if [ ! "$option_verbose" = "Y" ] && [ ! "$option_silent" = "Y" ]; then echo -ne "\r$processed_files/$total_files processed" if [ $DIFF ] && [ ! $changed_files -eq 0 ]; then echo -ne ", $changed_files changed"