[TASK] Script to package 3rd party TYPO3 extensions 68/41368/2
authorXavier Perseguers <xavier@typo3.org>
Wed, 15 Jul 2015 21:12:36 +0000 (23:12 +0200)
committerXavier Perseguers <xavier@typo3.org>
Wed, 15 Jul 2015 21:15:01 +0000 (23:15 +0200)
Change-Id: I23e194af7c5281baa494261d1b1925101680be7a
Reviewed-on: http://review.typo3.org/41368
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
19 files changed:
LEGACY/bin/build-language-pack [deleted file]
LEGACY/bin/pootle-batch-check-project
LEGACY/bin/pootle-batch-import-projects
LEGACY/bin/pootle-check-project
LEGACY/bin/pootle-create-project
LEGACY/bin/pootle-notify-hassuggestion
LEGACY/bin/pootle-refresh-project
LEGACY/bin/pootle-snapshot
LEGACY/bin/pootle-upgrade-all-extensions
LEGACY/bin/pootle-upgrade-extension
LEGACY/bin/pootle-upgrade-extension-git
nginx/templates/virtualhost.conf.j2
typo3/files/scripts/bin/build-language-pack [new file with mode: 0755]
typo3/files/scripts/bin/pootle-manage
typo3/files/scripts/bin/update-typo3-core-template
typo3/files/scripts/etc/functions
typo3/files/templates/languages.txt
typo3/tasks/main.yml
typo3/templates/scripts/etc/pootle.conf.j2

diff --git a/LEGACY/bin/build-language-pack b/LEGACY/bin/build-language-pack
deleted file mode 100755 (executable)
index eebcddc..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-#!/bin/bash
-
-BASE_DIR=/var/www/vhosts/pootle.typo3.org/pootle/po
-EXPORT_DIR=/var/www/vhosts/pootle.typo3.org/l10n_ter
-STATE_DIR=/var/www/vhosts/pootle.typo3.org/home/scripts/.build-language-pack-state
-POOTLE_CONFIG=/var/www/vhosts/pootle.typo3.org/pootle/localsettings.py
-
-# -- no need to modify anything below
-
-FORCE_EXTENSION=$1
-EXT_PREFIX=TYPO3.TYPO3
-EXTENSIONS=$(ls $BASE_DIR | grep $EXT_PREFIX | cut -b13-)
-DATABASE_NAME=$(grep ^DATABASE_NAME $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
-DATABASE_USER=$(grep ^DATABASE_USER $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
-DATABASE_PASSWORD=$(grep ^DATABASE_PASSWORD $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
-DATABASE_HOST=$(grep ^DATABASE_HOST $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
-
-if [ ! -z "$FORCE_EXTENSION" ]; then
-       EXTENSIONS=$FORCE_EXTENSION
-fi
-
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
-
-# Usage: mysqlpipe "sql-query"
-function mysqlpipe() {
-       echo $@ | mysql -u $DATABASE_USER -p"$DATABASE_PASSWORD" -h $DATABASE_HOST $DATABASE_NAME | sed '1d'
-}
-
-# Usage: lastedit "project" "language"
-function lastedit() {
-       local PROJECT="$1"
-       local LANGUAGE="$2"
-
-       # XP/19.06.2013: Using filesystem instead of database
-       #timestamp=$(mysqlpipe "SELECT p.id, p.code, l.code AS lang, u.mtime, UNIX_TIMESTAMP(u.mtime) AS tstamp
-       #       FROM pootle_app_project AS p
-       #       LEFT JOIN pootle_app_translationproject as tp ON p.id = tp.project_id
-       #       LEFT JOIN pootle_store_store AS s ON tp.id = s.translation_project_id
-       #       LEFT JOIN pootle_store_unit AS u ON s.id = u.store_id
-       #       INNER JOIN pootle_app_language l ON l.id = tp.language_id
-       #       WHERE ( u.state = 50 OR u.state = 200 )
-       #       AND p.code = '$PROJECT'
-       #       AND l.code = '$LANGUAGE'
-       #       GROUP BY p.id, l.code;" \
-       #| awk '{ print $6 }')
-
-       LANGUAGE_DIR=$BASE_DIR/$PROJECT/$LANGUAGE
-       if [ -d $LANGUAGE_DIR ]; then
-               timestamp=$(find $LANGUAGE_DIR -type f -printf '%T@ %p\n' \
-                       | grep -v "./.translation_index" \
-                       | sort -n \
-                       | tail -n 1 \
-                       | cut -f1 -d.
-               )
-       fi
-
-       if [ -z "$timestamp" ]; then
-               echo 0
-       else
-               echo $timestamp
-       fi
-}
-
-cd $(dirname $0)
-if [ -z "$FORCE_EXTENSION" ]; then
-       # Sync whole stores, --project seems not totally reliable
-       echo "Synchronizing all stores ... "
-       ./pootle-manage sync_stores 2>&1
-fi
-
-for EXT in $EXTENSIONS; do
-       EXTNAME=$(echo $EXT | sed -r 's/^[^.]+\.//')
-       echo "Packaging $EXTNAME"
-       if [ ! -z "$FORCE_EXTENSION" ]; then
-               echo -n "   synchronizing store ... "
-               ./pootle-manage sync_stores --project=$EXT_PREFIX.$EXT >/dev/null 2>&1
-               echo "done."
-       fi
-       echo -n "   updating statistics ... "
-       ./pootle-manage refresh_stats --project="$EXT_PREFIX.$EXT" >/dev/null 2>&1
-       echo "done."
-       pushd $BASE_DIR/$EXT_PREFIX.$EXT >/dev/null
-       rm -rf $EXPORT_DIR/_$EXTNAME
-
-       _LANGUAGE_PACK_PATH=${EXPORT_DIR}/${EXTNAME:0:1}/${EXTNAME:1:1}/${EXTNAME}-l10n
-       mkdir -p $_LANGUAGE_PACK_PATH
-       mkdir -p $STATE_DIR/$EXT_PREFIX.$EXT
-
-       LANGUAGES="$(ls | grep -v templates) ba br ch cz dk si se gr hk kr ua jp qc vn ge ga"
-       for LANG in $LANGUAGES; do
-               ORIG_LANG=$LANG
-               case "$LANG" in
-                       'ba')
-                               ORIG_LANG=bs ;;
-                       'br')
-                               ORIG_LANG=pt_BR ;;
-                       'ch')
-                               ORIG_LANG=zh_CN ;;
-                       'cz')
-                               ORIG_LANG=cs ;;
-                       'dk')
-                               ORIG_LANG=da ;;
-                       'si')
-                               ORIG_LANG=sl ;;
-                       'se')
-                               ORIG_LANG=sv ;;
-                       'gr')
-                               ORIG_LANG=el ;;
-                       'hk')
-                               ORIG_LANG=zh_HK ;;
-                       'kr')
-                               ORIG_LANG=ko ;;
-                       'ua')
-                               ORIG_LANG=uk ;;
-                       'jp')
-                               ORIG_LANG=ja ;;
-                       'qc')
-                               ORIG_LANG=fr_CA ;;
-                       'vn')
-                               ORIG_LANG=vi ;;
-                       'ge')
-                               ORIG_LANG=ka ;;
-                       'ga')
-                               ORIG_LANG=gl ;;
-               esac
-
-               echo -n "   processing $LANG ... "
-               #/home/pootle/scripts/pootle-manage sync_stores --project="$EXT_PREFIX.$EXT" --language=$ORIG_LANG >/dev/null 2>&1
-
-               # Compute current state
-               STATUS_FILE=$STATE_DIR/$EXT_PREFIX.$EXT/$LANG.time
-               if [[ -f $STATUS_FILE && -z "$FORCE_EXTENSION" ]]; then
-                       LAST_GENERATION=$(cat $STATE_DIR/$EXT_PREFIX.$EXT/$LANG.time)
-               else
-                       LAST_GENERATION=0
-               fi
-               LAST_EDIT=$(lastedit "$EXT_PREFIX.$EXT" $ORIG_LANG)
-               if [[ $LAST_EDIT -gt 0 && $LAST_EDIT -ne $LAST_GENERATION ]]; then
-                       mkdir -p $EXPORT_DIR/_$EXTNAME/$LANG/$EXTNAME
-                       cp -r $ORIG_LANG/* $EXPORT_DIR/_$EXTNAME/$LANG/$EXTNAME
-                       pushd $EXPORT_DIR/_$EXTNAME/$LANG/$EXTNAME >/dev/null
-                       for XLF in $(find . -type f); do
-                               DIR=$(dirname $XLF)
-                               FILE=$(basename $XLF)
-                               mv $XLF $DIR/$LANG.$FILE
-
-                               # Convert XLIFF to LLXML
-                               _SOURCE_XLIFF_FILE=$BASE_DIR/$EXT_PREFIX.$EXT/templates/$DIR/$FILE
-                               LLXML=$DIR/$LANG.$(echo $FILE | sed s/\.xlf$/\.xml/)
-                               llxml2xliff $EXTNAME \
-                                       $LANG \
-                                       $_SOURCE_XLIFF_FILE \
-                                       $DIR/$LANG.$FILE > $LLXML
-                       done
-                       find . -name \*.xlf -exec chmod 644 {} \;
-                       find . -name \*.xml -exec chmod 644 {} \;
-                       rm -f $_LANGUAGE_PACK_PATH/$EXTNAME-l10n-$LANG.zip
-                       # ../ to include $EXTNAME directory
-                       cd ../
-                       zip -9 $_LANGUAGE_PACK_PATH/$EXTNAME-l10n-$LANG.zip -r . >/dev/null
-
-                       popd >/dev/null
-
-                       # Save current state
-                       echo $LAST_EDIT > $STATUS_FILE
-                       echo "done."
-               else
-                       echo "skipped."
-               fi
-       done
-
-       # Create language pack index
-       pushd $_LANGUAGE_PACK_PATH >/dev/null
-
-       _LANGUAGE_PACK_NAME=${EXTNAME}-l10n
-       _LANGUAGE_INDEX_FILE=${_LANGUAGE_PACK_NAME}.xml
-       rm -f $_LANGUAGE_INDEX_FILE
-        touch $_LANGUAGE_INDEX_FILE
-
-       echo -e "<?xml version=\"1.0\" standalone=\"yes\" ?>"                   >> $_LANGUAGE_INDEX_FILE
-       echo -e "<TERlanguagePackIndex>"                                        >> $_LANGUAGE_INDEX_FILE
-       echo -e "\t<meta>"                                                      >> $_LANGUAGE_INDEX_FILE
-       echo -e "\t\t<timestamp>$(date +"%s")</timestamp>"                      >> $_LANGUAGE_INDEX_FILE
-       echo -e "\t\t<date>$(date +"%F %T")</date>"                             >> $_LANGUAGE_INDEX_FILE
-       echo -e "\t</meta>"                                                     >> $_LANGUAGE_INDEX_FILE
-       echo -e "\t<languagePackIndex>"                                         >> $_LANGUAGE_INDEX_FILE
-
-       for p in $(find . -name \*.zip | sort);
-       do
-               _LANGUAGE_KEY=$(echo $p | sed -r "s/.*${_LANGUAGE_PACK_NAME}-(.*)\.zip\$/\1/")
-               echo -e "\t\t<languagepack language=\"$_LANGUAGE_KEY\">"        >> $_LANGUAGE_INDEX_FILE
-               echo -e "\t\t\t<md5>$(md5sum $p | cut -d" " -f1)</md5>"         >> $_LANGUAGE_INDEX_FILE
-               echo -e "\t\t</languagepack>"                                   >> $_LANGUAGE_INDEX_FILE
-       done
-
-       echo -e "\t</languagePackIndex>"                                        >> $_LANGUAGE_INDEX_FILE
-       echo -e "</TERlanguagePackIndex>"                                       >> $_LANGUAGE_INDEX_FILE
-
-       popd >/dev/null
-
-       rm -rf $EXPORT_DIR/_$EXTNAME
-       popd >/dev/null
-done
index 5799acd..14ebeab 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -e
 
index 05cf769..9c836f7 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 . /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
 . /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
index e0117fa..c46b9fb 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -e
 
index d54684c..64a7371 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -e
 
index 08cf0e7..c7c7074 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 POOTLE_CONFIG=/var/www/vhosts/pootle.typo3.org/pootle/localsettings.py
 
index 31572e8..a5bc182 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -e
 
index 7b5c885..a944a14 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 SNAPSHOT_DIRECTORY="/var/www/vhosts/pootle.typo3.org/home/archives/snapshot"
 
index 9ad8bf0..6a672d7 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -o errtrace
 set -o nounset
index b493d22..57e19d2 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -o errtrace
 set -o nounset
index 78e98a1..d70c458 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -o errtrace
 set -o nounset
index 3e27357..734fe44 100644 (file)
@@ -22,6 +22,11 @@ server {
         root {{ pootle_virtualenv }}/lib/python2.7/site-packages/pootle/;
     }
 
+    location ^~ /l10n_ter/ {
+        root /var/www/{{ domain }}/public/;
+        autoindex on;
+    }
+
     location / {
         fastcgi_pass 127.0.0.1:8080;
         fastcgi_param QUERY_STRING $query_string;
diff --git a/typo3/files/scripts/bin/build-language-pack b/typo3/files/scripts/bin/build-language-pack
new file mode 100755 (executable)
index 0000000..4528da8
--- /dev/null
@@ -0,0 +1,155 @@
+#!/usr/bin/env bash
+
+. /home/pootle/scripts/etc/pootle.conf
+. /home/pootle/scripts/etc/functions
+
+# -- no need to modify anything below
+
+FORCE_EXTENSION=$1
+EXT_PREFIX=TYPO3.TYPO3.ext
+EXT_PREFIX_LENGTH=$(($(echo -n ${EXT_PREFIX} | wc -c) + 2))
+if [ ! -z "${FORCE_EXTENSION}" ]; then
+       EXTENSIONS=${FORCE_EXTENSION}
+else
+       EXTENSIONS=$(ls ${POOTLE_PO} | grep ${EXT_PREFIX} | cut -b${EXT_PREFIX_LENGTH}-)
+fi
+
+cd $(dirname $0)
+#if [ -z "$FORCE_EXTENSION" ]; then
+#      # Sync whole stores, --project seems not totally reliable
+#      echo "Synchronizing all stores ... "
+#      ./pootle-manage sync_stores 2>&1
+#fi
+
+for EXTNAME in $EXTENSIONS; do
+       echo "Packaging $EXTNAME"
+       if [ ! -z "$FORCE_EXTENSION" ]; then
+               echo -n "   synchronizing store ... "
+               ./pootle-manage sync_stores --project=$EXT_PREFIX.$EXTNAME >/dev/null 2>&1
+               echo "done."
+       fi
+       echo -n "   updating statistics ... "
+       ./pootle-manage refresh_stats --project="$EXT_PREFIX.$EXTNAME" >/dev/null 2>&1
+       echo "done."
+       pushd ${POOTLE_PO}/$EXT_PREFIX.$EXTNAME >/dev/null
+       rm -rf ${TER_L10N_PATH}/_$EXTNAME
+
+       _LANGUAGE_PACK_PATH=${TER_L10N_PATH}/${EXTNAME:0:1}/${EXTNAME:1:1}/${EXTNAME}-l10n
+       mkdir -p $_LANGUAGE_PACK_PATH
+       mkdir -p $STATE_DIR/$EXT_PREFIX.$EXTNAME
+
+       LANGUAGES="$(ls | grep -v templates) ba br ch cz dk si se gr hk kr ua jp qc vn ge ga"
+       for LANG in $LANGUAGES; do
+               ORIG_LANG=$LANG
+               case "$LANG" in
+                       'ba')
+                               ORIG_LANG=bs ;;
+                       'br')
+                               ORIG_LANG=pt_BR ;;
+                       'ch')
+                               ORIG_LANG=zh_CN ;;
+                       'cz')
+                               ORIG_LANG=cs ;;
+                       'dk')
+                               ORIG_LANG=da ;;
+                       'si')
+                               ORIG_LANG=sl ;;
+                       'se')
+                               ORIG_LANG=sv ;;
+                       'gr')
+                               ORIG_LANG=el ;;
+                       'hk')
+                               ORIG_LANG=zh_HK ;;
+                       'kr')
+                               ORIG_LANG=ko ;;
+                       'ua')
+                               ORIG_LANG=uk ;;
+                       'jp')
+                               ORIG_LANG=ja ;;
+                       'qc')
+                               ORIG_LANG=fr_CA ;;
+                       'vn')
+                               ORIG_LANG=vi ;;
+                       'ge')
+                               ORIG_LANG=ka ;;
+                       'ga')
+                               ORIG_LANG=gl ;;
+               esac
+
+               echo -n "   processing $LANG ... "
+               #./pootle-manage sync_stores --project="$EXT_PREFIX.$EXTNAME" --language=$ORIG_LANG >/dev/null 2>&1
+
+               # Compute current state
+               STATUS_FILE=$STATE_DIR/$EXT_PREFIX.$EXTNAME/$LANG.time
+               if [[ -f $STATUS_FILE && -z "$FORCE_EXTENSION" ]]; then
+                       LAST_GENERATION=$(cat $STATE_DIR/$EXT_PREFIX.$EXTNAME/$LANG.time)
+               else
+                       LAST_GENERATION=0
+               fi
+               LAST_EDIT=$(lastedit "$EXT_PREFIX.$EXTNAME" $ORIG_LANG)
+               if [[ $LAST_EDIT -gt 0 && $LAST_EDIT -ne $LAST_GENERATION ]]; then
+                       mkdir -p ${TER_L10N_PATH}/_$EXTNAME/$LANG/$EXTNAME
+                       cp -r $ORIG_LANG/* ${TER_L10N_PATH}/_$EXTNAME/$LANG/$EXTNAME
+                       pushd ${TER_L10N_PATH}/_$EXTNAME/$LANG/$EXTNAME >/dev/null
+                       for XLF in $(find . -type f); do
+                               DIR=$(dirname $XLF)
+                               FILE=$(basename $XLF)
+                               mv $XLF $DIR/$LANG.$FILE
+
+                               # Convert XLIFF to LLXML
+                               _SOURCE_XLIFF_FILE=${POOTLE_PO}/$EXT_PREFIX.$EXTNAME/templates/$DIR/$FILE
+                               LLXML=$DIR/$LANG.$(echo $FILE | sed s/\.xlf$/\.xml/)
+                               llxml2xliff $EXTNAME \
+                                       $LANG \
+                                       $_SOURCE_XLIFF_FILE \
+                                       $DIR/$LANG.$FILE > $LLXML
+                       done
+                       find . -name \*.xlf -exec chmod 644 {} \;
+                       find . -name \*.xml -exec chmod 644 {} \;
+                       rm -f $_LANGUAGE_PACK_PATH/$EXTNAME-l10n-$LANG.zip
+                       # ../ to include $EXTNAME directory
+                       cd ../
+                       zip -9 $_LANGUAGE_PACK_PATH/$EXTNAME-l10n-$LANG.zip -r . >/dev/null
+
+                       popd >/dev/null
+
+                       # Save current state
+                       echo $LAST_EDIT > $STATUS_FILE
+                       echo "done."
+               else
+                       echo "skipped."
+               fi
+       done
+
+       # Create language pack index
+       pushd $_LANGUAGE_PACK_PATH >/dev/null
+
+       _LANGUAGE_PACK_NAME=${EXTNAME}-l10n
+       _LANGUAGE_INDEX_FILE=${_LANGUAGE_PACK_NAME}.xml
+       rm -f $_LANGUAGE_INDEX_FILE
+        touch $_LANGUAGE_INDEX_FILE
+
+       echo -e "<?xml version=\"1.0\" standalone=\"yes\" ?>"                   >> $_LANGUAGE_INDEX_FILE
+       echo -e "<TERlanguagePackIndex>"                                        >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t<meta>"                                                      >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t\t<timestamp>$(date +"%s")</timestamp>"                      >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t\t<date>$(date +"%F %T")</date>"                             >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t</meta>"                                                     >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t<languagePackIndex>"                                         >> $_LANGUAGE_INDEX_FILE
+
+       for p in $(find . -name \*.zip | sort);
+       do
+               _LANGUAGE_KEY=$(echo $p | sed -r "s/.*${_LANGUAGE_PACK_NAME}-(.*)\.zip\$/\1/")
+               echo -e "\t\t<languagepack language=\"$_LANGUAGE_KEY\">"        >> $_LANGUAGE_INDEX_FILE
+               echo -e "\t\t\t<md5>$(md5sum $p | cut -d" " -f1)</md5>"         >> $_LANGUAGE_INDEX_FILE
+               echo -e "\t\t</languagepack>"                                   >> $_LANGUAGE_INDEX_FILE
+       done
+
+       echo -e "\t</languagePackIndex>"                                        >> $_LANGUAGE_INDEX_FILE
+       echo -e "</TERlanguagePackIndex>"                                       >> $_LANGUAGE_INDEX_FILE
+
+       popd >/dev/null
+
+       rm -rf ${TER_L10N_PATH}/_$EXTNAME
+       popd >/dev/null
+done
index c28ff9e..7b9af68 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -e
 
index f7b674a..835de2e 100755 (executable)
@@ -1,11 +1,13 @@
 #!/usr/bin/env bash
 
-. ~/scripts/etc/pootle.conf
-. ~/scripts/etc/functions
+. /home/pootle/scripts/etc/pootle.conf
+. /home/pootle/scripts/etc/functions
 
 # Clone of the TYPO3 CMS sources
 SOURCES=${LOCAL_GIT_CLONE_DIRECTORY}/TYPO3.CMS
 
+cd $(dirname $0)
+
 # Usage; check_typo3_typo3_core_projects_languages
 function check_typo3_typo3_core_projects_languages() {
        echo
@@ -238,14 +240,14 @@ for PROJECT in ${PROJECTS}; do
        echo "[INFO]    Refreshing Pootle for project ${PROJECT}"
 
        # Find new files automatically
-       pootle-manage update_stores --project=${PROJECT} --language=templates
+       ./pootle-manage update_stores --project=${PROJECT} --language=templates
 
        # Add new languages if needed
-       pootle-manage update_translation_projects --project=${PROJECT}
+       ./pootle-manage update_translation_projects --project=${PROJECT}
 
        # Update translations with labels from templates (source language)
-       pootle-manage update_against_templates --project=${PROJECT}
-       pootle-manage refresh_stats --project=${PROJECT}
+       ./pootle-manage update_against_templates --project=${PROJECT}
+       ./pootle-manage refresh_stats --project=${PROJECT}
 done
 
 popd >/dev/null
index d402bab..85d4e99 100644 (file)
@@ -21,7 +21,12 @@ function log_notice() {
 
 # Usage: mysqlpipe "sql-query"
 function mysqlpipe() {
-       echo $@ | mysql pootle | sed '1d'
+       local DATABASE_NAME=$(grep ^DATABASE_NAME ${POOTLE_CONF} | sed -r "s/.* = '([^']+)'.*/\1/")
+       local DATABASE_USER=$(grep ^DATABASE_USER ${POOTLE_CONF} | sed -r "s/.* = '([^']+)'.*/\1/")
+       local DATABASE_PASSWORD=$(grep ^DATABASE_PASSWORD ${POOTLE_CONF} | sed -r "s/.* = '([^']+)'.*/\1/")
+       local DATABASE_HOST=$(grep ^DATABASE_HOST ${POOTLE_CONF} | sed -r "s/.* = '([^']+)'.*/\1/")
+
+       echo $@ | mysql -u ${DATABASE_USER} -p"${DATABASE_PASSWORD}" -h ${DATABASE_HOST} ${DATABASE_NAME} | sed '1d'
 }
 
 #
@@ -34,7 +39,7 @@ function llxml2xliff() {
        local SOURCE=$3
        local TARGET=$4
 
-       if [ "$EXTENSION" = "" ] || [ "$LANG" = "" ] || [ "$SOURCE" = "" ] || [ "$TARGET" = "" ]; then
+       if [ -z "$EXTENSION" ] || [ -z "$LANG" ] || [ -z "$SOURCE" ] || [ -z "$TARGET" ]; then
                echo
                msg "Please provide source and target XLIFF. Unable to convert XLIFF to LLXML."
                echo
@@ -64,7 +69,7 @@ function list_typo3_typo3_core_projects() {
 # Usage: project_exist project.name
 function project_exist() {
        echo -n "[INFO]    Check if project \"$1\" exists: "
-       if [ "$1" != "" ] && [ -d ${POOTLE_PO}/$1 ]; then
+       if [ -n "$1" ] && [ -d ${POOTLE_PO}/$1 ]; then
                echo "OK"
                if [ ! -d ${POOTLE_PO}/$1/templates ]; then
                        mkdir -p ${POOTLE_PO}/$1/templates
@@ -80,7 +85,7 @@ function project_exist() {
 # Usage: check_available_languages project.name
 function check_available_languages() {
        for LANGUAGE_KEY in $(cat ~/templates/languages.txt); do
-               if [ "$1" != "" ] && [ ! -d ${POOTLE_PO}/$1/$LANGUAGE_KEY ]; then
+               if [ -n "$1" ] && [ ! -d ${POOTLE_PO}/$1/$LANGUAGE_KEY ]; then
                        mkdir -p $POOTLE_PO/$1/$LANGUAGE_KEY
                        echo "[NOTICE]  Create project language \"$LANGUAGE_KEY\" for \"$1\""
                        pootle-manage update_translation_projects --project=$1 --language=$LANGUAGE_KEY
@@ -95,12 +100,12 @@ function getProjectUpdatedSince() {
        local SINCE=$1
        local PROJECT_ONLY=$2
 
-       if [ "$SINCE" = "" ]; then
+       if [ -z "$SINCE" ]; then
                echo "[ERROR]   Empty date, unable to select updated project" >&2
                exit 1
        fi
 
-       if [ "$PROJECT_ONLY" = "" ]; then
+       if [ -z "$PROJECT_ONLY" ]; then
                mysqlpipe "SELECT p.id, p.code, u.mtime, UNIX_TIMESTAMP(u.mtime) AS tstamp
                        FROM pootle_app_project AS p
                        LEFT JOIN pootle_app_translationproject as tp ON p.id = tp.project_id
@@ -126,12 +131,12 @@ function getProjectUpdatedSince() {
 # Usage: getLanguageProjectUpdatedSince project-id 2011-07-14
 function getLanguageProjectUpdatedSince() {
        local PROJECT_ID=$1
-       if [ "$PROJECT_ID" = "" ]; then
+       if [ -z "$PROJECT_ID" ]; then
                echo "[ERROR]   Empty project id, unable to select updated language project" >&2
                exit 1
        fi
        local SINCE=$2
-       if [ "$SINCE" = "" ]; then
+       if [ -z "$SINCE" ]; then
                echo "[ERROR]   Empty date, unable to select updated language project" >&2
                exit 1
        fi
@@ -147,6 +152,41 @@ function getLanguageProjectUpdatedSince() {
                ORDER BY u.mtime DESC;"
 }
 
+# Usage: lastedit "project" "language"
+function lastedit() {
+       local PROJECT="$1"
+       local LANGUAGE="$2"
+
+       # XP/19.06.2013: Using filesystem instead of database
+       #timestamp=$(mysqlpipe "SELECT p.id, p.code, l.code AS lang, u.mtime, UNIX_TIMESTAMP(u.mtime) AS tstamp
+       #       FROM pootle_app_project AS p
+       #       LEFT JOIN pootle_app_translationproject as tp ON p.id = tp.project_id
+       #       LEFT JOIN pootle_store_store AS s ON tp.id = s.translation_project_id
+       #       LEFT JOIN pootle_store_unit AS u ON s.id = u.store_id
+       #       INNER JOIN pootle_app_language l ON l.id = tp.language_id
+       #       WHERE ( u.state = 50 OR u.state = 200 )
+       #       AND p.code = '$PROJECT'
+       #       AND l.code = '$LANGUAGE'
+       #       GROUP BY p.id, l.code;" \
+       #| awk '{ print $6 }')
+
+       LANGUAGE_DIR=${POOTLE_PO}/${PROJECT}/${LANGUAGE}
+       if [ -d ${LANGUAGE_DIR} ]; then
+               timestamp=$(find ${LANGUAGE_DIR} -type f -printf '%T@ %p\n' \
+                       | grep -v "./.translation_index" \
+                       | sort -n \
+                       | tail -n 1 \
+                       | cut -f1 -d.
+               )
+       fi
+
+       if [ -z "$timestamp" ]; then
+               echo 0
+       else
+               echo $timestamp
+       fi
+}
+
 # Usage: validProjectName project.name
 function validProjectName() {
        local PROJECT_NAME=$1
index f82784f..6b66577 100644 (file)
@@ -3,7 +3,6 @@ ar
 bg
 bs
 ca
-ch
 cs
 da
 de
@@ -38,7 +37,6 @@ no
 pl
 pt
 pt_BR
-qc
 ro
 ru
 sk
@@ -49,4 +47,5 @@ th
 tr
 uk
 vi
-zh
\ No newline at end of file
+zh_CN
+zh_HK
\ No newline at end of file
index 52f3318..2f59db8 100644 (file)
@@ -1,4 +1,7 @@
 ---
+- name: Create web directory for localisation packages
+  file: dest=/var/www/{{ domain }}/public/l10n_ter mode=755 state=directory owner=pootle group=www-data recurse=yes
+
 - name: Install git
   apt: pkg=git state=installed update_cache=true
 
index 1255b86..cb6064a 100644 (file)
@@ -8,6 +8,8 @@ POOTLE_LOG=/var/log/pootle/pootle.log
 POOTLE_ERR=/var/log/pootle/pootle.err
 POOTLE_PO={{ pootle_po_directory }}
 
+STATE_DIR=${POOTLE_SCRIPT_HOME}/.build-language-pack-state
+
 CONF_LANG_COMPAT=${POOTLE_SCRIPT_HOME}/etc/lang-compat.conf
 
 LOCAL_GIT_CLONE_DIRECTORY="{{ pootle_git_directory }}"
@@ -17,7 +19,7 @@ XSL_LLXML2XLIFF_TARGET=${POOTLE_SCRIPT_HOME}/etc/xsl/xliff2llxml-target.xsl
 
 _LAST_BUILD_FILE="${POOTLE_SCRIPT_HOME}/.build-language-pack-lastbuild"
 
-TER_L10N_PATH=/var/www/{{ domain }}/l10n_ter
+TER_L10N_PATH=/var/www/{{ domain }}/public/l10n_ter
 
 # Requires bash >= v4.x
 # These are the supported Git branches. Once an older branch