[TASK] Script to update all 3rd party extensions 03/41503/2
authorXavier Perseguers <xavier@typo3.org>
Thu, 16 Jul 2015 18:29:49 +0000 (20:29 +0200)
committerXavier Perseguers <xavier@typo3.org>
Thu, 16 Jul 2015 18:31:02 +0000 (20:31 +0200)
Change-Id: I6c9cd6b539bec2023f1f8cdce06a945562a1f1da
Reviewed-on: http://review.typo3.org/41503
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
LEGACY/bin/pootle-upgrade-all-extensions [deleted file]
typo3/files/scripts/bin/update-all-extensions [new file with mode: 0755]
typo3/files/scripts/etc/functions

diff --git a/LEGACY/bin/pootle-upgrade-all-extensions b/LEGACY/bin/pootle-upgrade-all-extensions
deleted file mode 100755 (executable)
index 6a672d7..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env bash
-
-set -o errtrace
-set -o nounset
-
-#  Trap non-normal exit signals: 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
-trap onexit 1 2 3 15
-
-#--- onexit() -----------------------------------------------------
-#  @param $1 integer  (optional) Exit status.  If not set, use `$?'
-function onexit() {
-       local exit_status=${1:-$?}
-       if [ $exit_status -gt 0 ]; then
-               echo Exiting $0 with $exit_status
-       fi
-       exit $exit_status
-}
-
-BASE_DIRECTORY="/var/www/vhosts/pootle.typo3.org/pootle/po"
-T3XUTILS=/var/www/vhosts/pootle.typo3.org/home/scripts/bin/t3xutils.phar
-UPGRADE_EXTENSION=/var/www/vhosts/pootle.typo3.org/home/scripts/bin/pootle-upgrade-extension
-
-echo "[INFO] Fetch and cache TER extension metadata"
-$T3XUTILS updateinfo >/dev/null
-
-cd $BASE_DIRECTORY
-PROJECTS=$(find . -maxdepth 1 -type d | egrep 'TYPO3\.TYPO3\.ext\.' | sort)
-
-for PROJECT in $PROJECTS;
-do
-       EXTENSION=$(echo $PROJECT | cut -b19-)
-
-       echo -n "[INFO] Looking for latest version of $EXTENSION on TER: "
-       LASTLINE=$($T3XUTILS info $EXTENSION 2>/dev/null | grep -v "Available versions:" | tail -n 1)
-       if [ -z "$LASTLINE" ]; then
-               echo "n/a"
-               echo "[ERROR] Extension $EXTENSION does not exist on TER"
-       else
-               LASTVERSION=$(echo $LASTLINE | awk '{ print $1 }' | egrep '^[0-9.]+$')
-               if [ -n "$LASTVERSION" ]; then
-                       echo $LASTVERSION
-                       LOCALVERSION=""
-                       if [ -f $BASE_DIRECTORY/$PROJECT/.ter-version ]; then
-                               LOCALVERSION=$(cat $BASE_DIRECTORY/$PROJECT/.ter-version)
-                       fi
-                       if [ -z "$LOCALVERSION" ] || [ "$LOCALVERSION" != "$LASTVERSION" ]; then
-                               echo "[INFO] Updating extension $EXTENSION to version $LASTVERSION"
-                               $UPGRADE_EXTENSION $EXTENSION $LASTVERSION
-                       fi
-               fi
-       fi
-done
-
-onexit
diff --git a/typo3/files/scripts/bin/update-all-extensions b/typo3/files/scripts/bin/update-all-extensions
new file mode 100755 (executable)
index 0000000..3c5603c
--- /dev/null
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+
+. /home/pootle/scripts/etc/pootle.conf
+. /home/pootle/scripts/etc/functions
+
+set -o errtrace
+set -o nounset
+
+#  Trap non-normal exit signals: 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
+trap onexit 1 2 3 15
+
+#--- onexit() -----------------------------------------------------
+#  @param $1 integer  (optional) Exit status.  If not set, use `$?'
+function onexit() {
+       local exit_status=${1:-$?}
+       if [ $exit_status -gt 0 ]; then
+               echo Exiting $0 with $exit_status
+       fi
+       exit $exit_status
+}
+
+echo "[INFO]    Fetch and cache TER extension metadata"
+$T3XUTILS updateinfo >/dev/null
+
+pushd ${POOTLE_PO} >/dev/null
+PROJECTS=$(find . -maxdepth 1 -name TYPO3.ext.\* -type d | sort)
+popd >/dev/null
+
+for PROJECT in ${PROJECTS};
+do
+       EXTENSION=$(echo ${PROJECT} | cut -b13-)
+
+       echo -n "[INFO]    Looking for latest version of ${EXTENSION} on TER: "
+       LASTLINE=$(${T3XUTILS} info ${EXTENSION} 2>/dev/null | grep -v "Available versions:" | tail -n 1)
+       if [ -z "$LASTLINE" ]; then
+               echo "n/a"
+               echo "[ERROR]   Extension ${EXTENSION} does not exist on TER"
+       else
+               LASTVERSION=$(echo ${LASTLINE} | awk '{ print $1 }' | egrep '^[0-9.]+$')
+               if [ -n "${LASTVERSION}" ]; then
+                       echo ${LASTVERSION}
+                       LOCALVERSION=""
+                       if [ -f ${POOTLE_PO}/${PROJECT}/.ter-version ]; then
+                               LOCALVERSION=$(cat ${POOTLE_PO}/${PROJECT}/.ter-version)
+                       fi
+                       if [ -z "${LOCALVERSION}" ] || [ "${LOCALVERSION}" != "${LASTVERSION}" ]; then
+                               echo "[INFO]    Updating extension ${EXTENSION} to version ${LASTVERSION}"
+                               ${POOTLE_SCRIPT_HOME}/bin/update-extension ${EXTENSION} ${LASTVERSION}
+                       fi
+               fi
+       fi
+done
+
+onexit
index fd80cc5..6d726e6 100644 (file)
@@ -88,9 +88,9 @@ function check_available_languages() {
                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
-                       pootle-manage update_against_templates --project=$1 --language=$LANGUAGE_KEY
-                       pootle-manage refresh_stats --project=$1 --language=$LANGUAGE_KEY
+                       pootle-manage update_translation_projects --project=$1 --language=$LANGUAGE_KEY >/dev/null 2>&1
+                       pootle-manage update_against_templates --project=$1 --language=$LANGUAGE_KEY >/dev/null 2>&1
+                       pootle-manage refresh_stats --project=$1 --language=$LANGUAGE_KEY >/dev/null 2>&1
                fi
        done
 }