From 94b59469d8607e8bda19646a31294130e6598eec Mon Sep 17 00:00:00 2001 From: daisy-ycguo Date: Thu, 27 Jun 2013 17:19:47 +0800 Subject: [PATCH] Improve the robustness of manuals translation scripts Add codes to get the list of document's names in openstack manuals, other than hard code. Check whether the files/folders exist before taking actions, to improve the robustness. bug 1195180 Change-Id: I3e3d17a77920c99bed6881ac0cc460b1fce54cea Reviewed-on: https://review.openstack.org/34700 Reviewed-by: Jeremy Stanley Reviewed-by: James E. Blair Approved: Clark Boylan Reviewed-by: Clark Boylan Tested-by: Jenkins --- .../propose_translation_update_manuals.sh | 37 +++++++++++-------- .../upstream_translation_update_manuals.sh | 29 ++++++++------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/modules/jenkins/files/slave_scripts/propose_translation_update_manuals.sh b/modules/jenkins/files/slave_scripts/propose_translation_update_manuals.sh index bd8bfecceb..c098fc3f79 100755 --- a/modules/jenkins/files/slave_scripts/propose_translation_update_manuals.sh +++ b/modules/jenkins/files/slave_scripts/propose_translation_update_manuals.sh @@ -1,5 +1,7 @@ #!/bin/bash -xe +# Copyright 2013 IBM Corp. +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -16,10 +18,7 @@ # and push to Gerrit. PROJECT="openstack-manuals" -DocNameList="basic-install cli-guide common openstack-block-storage-admin \ -openstack-compute-admin openstack-ha openstack-install \ -openstack-network-connectivity-admin openstack-object-storage-admin \ -openstack-ops" +DocFolder="doc/src/docbkx" COMMIT_MSG="Imported Translations from Transifex" @@ -52,26 +51,30 @@ fi # tx init --host=https://www.transifex.com # generate pot one by one -for DOCNAME in ${DocNameList} +for FILE in ${DocFolder}/* do + DOCNAME=${FILE#${DocFolder}/} # openstack-ha needs to create new DocBook files if [ "$DOCNAME" == "openstack-ha" ] then - asciidoc -b docbook -d book -o - doc/src/docbkx/openstack-ha/ha-guide.txt \ + asciidoc -b docbook -d book -o - ${DocFolder}/openstack-ha/ha-guide.txt \ | xsltproc -o - /usr/share/xml/docbook/stylesheet/docbook5/db4-upgrade.xsl - \ | xmllint --format - | sed -e 's, doc/src/docbkx/openstack-ha/bk-ha-guide.xml +> ${DocFolder}/openstack-ha/bk-ha-guide.xml fi # Update the .pot file ./tools/generatepot ${DOCNAME} - # Add all changed files to git - git add doc/src/docbkx/${DOCNAME}/locale/* - # Set auto-local - tx set --auto-local -r openstack-manuals-i18n.${DOCNAME} \ -"doc/src/docbkx/${DOCNAME}/locale/.po" --source-lang en \ ---source-file doc/src/docbkx/${DOCNAME}/locale/${DOCNAME}.pot \ + if [ -f ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot ] + then + # Add all changed files to git + git add ${DocFolder}/${DOCNAME}/locale/* + # Set auto-local + tx set --auto-local -r openstack-manuals-i18n.${DOCNAME} \ +"${DocFolder}/${DOCNAME}/locale/.po" --source-lang en \ +--source-file ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot \ -t PO --execute + fi done if [ ! `git diff --cached --quiet HEAD --` ] @@ -83,9 +86,13 @@ fi # Pull all upstream translations tx pull -a -for DOCNAME in ${DocNameList} +for FILE in ${DocFolder}/* do - git add doc/src/docbkx/${DOCNAME}/locale/* + DOCNAME=${FILE#${DocFolder}/} + if [ -d ${DocFolder}/${DOCNAME}/locale ] + then + git add ${DocFolder}/${DOCNAME}/locale/* + fi done # Don't send a review if the only things which have changed are the creation diff --git a/modules/jenkins/files/slave_scripts/upstream_translation_update_manuals.sh b/modules/jenkins/files/slave_scripts/upstream_translation_update_manuals.sh index 0e7f2d9f99..16119efe1b 100755 --- a/modules/jenkins/files/slave_scripts/upstream_translation_update_manuals.sh +++ b/modules/jenkins/files/slave_scripts/upstream_translation_update_manuals.sh @@ -1,5 +1,7 @@ #!/bin/bash -xe +# Copyright 2013 IBM Corp. +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -14,10 +16,7 @@ # The script is to push the updated PoT to Transifex. -DocNameList="basic-install cli-guide common openstack-block-storage-admin \ -openstack-compute-admin openstack-ha openstack-install \ -openstack-network-connectivity-admin openstack-object-storage-admin \ -openstack-ops" +DocFolder="doc/src/docbkx" if [ ! `echo $ZUUL_REFNAME | grep master` ] then @@ -32,26 +31,30 @@ git config user.email "jenkins@openstack.org" # tx init --host=https://www.transifex.com # generate pot one by one -for DOCNAME in ${DocNameList} +for FILE in ${DocFolder}/* do + DOCNAME=${FILE#${DocFolder}/} # openstack-ha needs to create new DocBook files if [ "$DOCNAME" == "openstack-ha" ] then - asciidoc -b docbook -d book -o - doc/src/docbkx/openstack-ha/ha-guide.txt \ + asciidoc -b docbook -d book -o - ${DocFolder}/openstack-ha/ha-guide.txt \ | xsltproc -o - /usr/share/xml/docbook/stylesheet/docbook5/db4-upgrade.xsl - \ | xmllint --format - | sed -e 's, doc/src/docbkx/openstack-ha/bk-ha-guide.xml +> ${DocFolder}/openstack-ha/bk-ha-guide.xml fi # Update the .pot file ./tools/generatepot ${DOCNAME} - # Add all changed files to git - git add doc/src/docbkx/${DOCNAME}/locale/* - # Set auto-local - tx set --auto-local -r openstack-manuals-i18n.${DOCNAME} \ -"doc/src/docbkx/${DOCNAME}/locale/.po" --source-lang en \ ---source-file doc/src/docbkx/${DOCNAME}/locale/${DOCNAME}.pot \ + if [ -f ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot ] + then + # Add all changed files to git + git add ${DocFolder}/${DOCNAME}/locale/* + # Set auto-local + tx set --auto-local -r openstack-manuals-i18n.${DOCNAME} \ +"${DocFolder}/${DOCNAME}/locale/.po" --source-lang en \ +--source-file ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot \ -t PO --execute + fi done if [ ! `git diff --cached --quiet HEAD --` ]