From e29b0eb930888b2750af4cc6f05ce710dd421655 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 15 Dec 2023 20:26:09 +0200 Subject: [PATCH] script cleanups --- scripts/post_translate_stable.sh | 188 ------------------------------- scripts/pre_translate_stable.sh | 99 ---------------- 2 files changed, 287 deletions(-) delete mode 100755 scripts/post_translate_stable.sh delete mode 100755 scripts/pre_translate_stable.sh diff --git a/scripts/post_translate_stable.sh b/scripts/post_translate_stable.sh deleted file mode 100755 index f467517bd..000000000 --- a/scripts/post_translate_stable.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/bash -# Next line is a trick to get absolute path from relative path -# http://stackoverflow.com/questions/4045253/converting-relative-path-into-absolute-path -if [ "$USER" == "jenkins" ] -then - # Next line is a trick to get absolute path from relative path - # http://stackoverflow.com/questions/4045253/converting-relative-path-into-absolute-path - INASAFE_DEV_PATH=`cd "../../inasafe"; pwd` -else - INASAFE_DEV_PATH=`cd "../inasafe"; pwd` -fi -export QGIS_PREFIX_PATH=/usr/local/qgis-2.8 - -if [ -d $INASAFE_DEV_PATH ] -then - echo 'Using InaSAFE in' $INASAFE_DEV_PATH -else - # check the repo out since it does not exist - pushd . - mkdir -p $INASAFE_DEV_PATH - cd $INASAFE_DEV_PATH - git clone --depth 1 git://github.com/AIFDR/inasafe.git inasafe - popd -fi - -export LD_LIBRARY_PATH=$QGIS_PREFIX_PATH/lib -export PYTHONPATH=$QGIS_PREFIX_PATH/share/qgis/python:$INASAFE_DEV_PATH:$PYTHONPATH -export QGIS_DEBUG=0 -export QGIS_LOG_FILE=/dev/null -export QGIS_DEBUG_FILE=/dev/null - -echo "LIBRARY_PATH="$LD_LIBRARY_PATH -echo "PYTHONPATH="$PYTHONPATH - -# Based off the script from QGIS by Tim Sutton and Richard Duivenvoorde - -# Name of the dir containing static files -STATIC=_static -# Path to the documentation root relative to script execution dir -DOCROOT=docs -# Path from execution dir of this script to docs sources (could be just -# '' depending on how your sphinx project is set up). -SOURCE=source - -pushd . -cd $DOCROOT - -SPHINXBUILD=`which sphinx-build` -TEXI2PDF=`which texi2pdf` - -# GENERATE PDF AND HTML FOR FOLLOWING LOCALES (EN IS ALWAYS GENERATED) -LOCALES='id' - -if [ $1 ]; then - LOCALES=$1 -fi - -BUILDDIR=build -# be sure to remove an old build dir -rm -rf ${BUILDDIR} -mkdir -p ${BUILDDIR} - -# output dirs -PDFDIR=`pwd`/output/pdf -HTMLDIR=`pwd`/output/html -mkdir -p ${PDFDIR} -mkdir -p ${HTMLDIR} - -VERSION=`cat source/conf.py | grep "version = '.*'" | grep -o "[0-9]\.[0-9]"` - -if [[ $1 = "en" ]]; then - echo "Not running localization for English." -else - for LOCALE in ${LOCALES} - do - for POFILE in `find i18n/${LOCALE}/LC_MESSAGES/ -type f -name '*.po'` - do - MOFILE=`echo ${POFILE} | sed -e 's,\.po,\.mo,'` - # Compile the translated strings - echo "Compiling messages to ${MOFILE}" - msgfmt --statistics -o ${MOFILE} ${POFILE} - done - done -fi - -# We need to flush the build dir or the translations don't come through -rm -rf ${BUILDDIR} -mkdir ${BUILDDIR} -#Add english to the list and generated docs -LOCALES+=' en' - -if [ $1 ]; then - LOCALES=$1 -fi - -for LOCALE in ${LOCALES} -# Compile the html docs for this locale -do - # cleanup all images for the other locale - rm -rf source/static - mkdir -p source/static - # copy english (base) resources to the static dir - cp -r resources/en/* source/static - # now overwrite possible available (localised) resources over the english ones - cp -r resources/${LOCALE}/* source/static - - ################################# - # - # HTML Generation - # - ################################# - # Now prepare the index/irchat-[locale] template which is a manually translated, - # unique per locale page that gets copied to index.html/irchat.html for the doc - # generation process. - cp templates/index-${LOCALE}.html templates/index.html - cp templates/irchat-${LOCALE}.html templates/irchat.html - - echo "Building HTML for locale '${LOCALE}'..." - LOG=/tmp/sphinx$$.log - ${SPHINXBUILD} -d ${BUILDDIR}/doctrees -D language=${LOCALE} -b html source ${HTMLDIR}/${LOCALE} > $LOG - WARNINGS=`cat $LOG | grep warning` - ERRORS=`cat $LOG | grep ERROR` - if [[ $WARNINGS ]] - then - echo "***********************************************" - echo "* Sphinx build produces warnings - Please fix *" - echo $WARNINGS - echo "***********************************************" - exit 1 - fi - if [[ $ERRORS ]] - then - echo "*********************************************" - echo "* Sphinx build produces errors - Please fix *" - echo $ERRORS - echo "*********************************************" - exit 1 - fi - - # Remove the static html copy again - rm templates/index.html - rm templates/irchat.html - - # hack to avoid error when using Search in contents.html - rpl -q '#/../search.html' 'search.html' ./output/html/${LOCALE}/contents.html - # same applies for having the IRC-Chat Navigation Link - rpl -q '#/../irchat.html' 'irchat.html' ./output/html/${LOCALE}/contents.html - - ################################# - # - # PDF Generation - # - ################################# - # experimental sphinxbuild using rst2pdf... - #${SPHINXBUILD} -d ${BUILDDIR}/doctrees -D language=${LOCALE} -b pdf source ${BUILDDIR}/latex/${LOCALE} - - # Traditional using texi2pdf.... - # Compile the latex docs for that locale - ${SPHINXBUILD} -d ${BUILDDIR}/doctrees -D language=${LOCALE} -b latex source ${BUILDDIR}/latex/${LOCALE} > /dev/null 2>&1 - # Compile the pdf docs for that locale - # we use texi2pdf since latexpdf target is not available via - # sphinx-build which we need to use since we need to pass language flag - pushd . - cp resources/InaSAFE_footer.png ${BUILDDIR}/latex/${LOCALE}/ - cd ${BUILDDIR}/latex/${LOCALE}/ - # Manipulate our latex a little - first add a standard footer - - FOOTER1="\usepackage{wallpaper}" - FOOTER2="\LRCornerWallPaper{1}{InaSAFE_footer.png}" - - # need to build 3x to have proper toc and index - if [ -z $TEXI2PDF ] - then - echo You do not have texinfo package installed. Please install! - exit 1 - fi - - texi2pdf --quiet InaSAFE-Documentation.tex > /dev/null 2>&1 - texi2pdf --quiet InaSAFE-Documentation.tex > /dev/null 2>&1 - texi2pdf --quiet InaSAFE-Documentation.tex > /dev/null 2>&1 - mv InaSAFE-Documentation.pdf ${PDFDIR}/InaSAFE-${VERSION}-Documentation-${LOCALE}.pdf - popd -done - -rm -rf source/static -rm -rf ${BUILDDIR} - -popd diff --git a/scripts/pre_translate_stable.sh b/scripts/pre_translate_stable.sh deleted file mode 100755 index beab81a21..000000000 --- a/scripts/pre_translate_stable.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash - -INASAFE_DEV_PATH=$HOME/dev/python/inasafe/ -export QGIS_PREFIX_PATH=/usr/local/qgis-2.8/ - -if [ -d $INASAFE_DEV_PATH ] -then - export INASAFE_DEV_PATH=$HOME/dev/python/inasafe/ -else - echo Please set INASAFE_DEV_PATH as PATH to your local - echo clone of inasafe repository inside this script - exit 1 -fi - -export LD_LIBRARY_PATH=$QGIS_PREFIX_PATH/lib -export PYTHONPATH=$QGIS_PREFIX_PATH/share/qgis/python:$INASAFE_DEV_PATH:$PYTHONPATH -export QGIS_DEBUG=0 -export QGIS_LOG_FILE=/dev/null -export QGIS_DEBUG_FILE=/dev/null - -# Path to the documentation root relative to script execution dir -DOCROOT=docs -# Path from execution dir of this script to docs sources (could be just -# '' depending on how your sphinx project is set up). -SOURCE=source -# Name of the dir containing static files -STATIC=static - -LOCALES='id' - -if [ $1 ]; then - LOCALES=$1 -fi - -pushd . -cd $DOCROOT - -# Create / update the translation catalogue - this will generate the master .pot files -mkdir -p i18n/pot -# Create a (temporary) static directory in source to hold all (localised ) static content -mkdir -p source/static - -# copy english resources to static to be able to do a proper sphinx-build -cp -r resources/en/* source/static/ - -rm -rf - -BUILDDIR=build -# be sure to remove an old build dir -rm -rf ${BUILDDIR} -mkdir ${BUILDDIR} - -# Create / update the translation catalogue - this will generate the master -# .pot files -sphinx-build -d ${BUILDDIR}/doctrees -b gettext $SOURCE i18n/pot/ - -# We do not want the developer-docs/api-docs being translated so take them out of here -rm -rf i18n/pot/developer-docs -rm -rf i18n/pot/api-docs - -# Now iteratively update the locale specific .po files with any new strings -# needed translation -for LOCALE in ${LOCALES} -do - echo "Updating translation catalog for ${LOCALE}:" - echo "------------------------------------" - mkdir -p i18n/${LOCALE}/LC_MESSAGES - # cleanup images from static (different locales can have different localized images) - rm -rf source/static/* - # Clone the en resources and then overwrite with any localised versions of the same files. - cp -r resources/en/* source/static/ - PODIR=resources/${LOCALE} - if [ -d $PODIR ]; - then - cp -r ${PODIR}/* source/static/ - fi - - # Merge or copy all the updated pot files over to locale specific po files - for FILE in `find i18n/pot/ -type f` - do - POTFILE=${FILE} - POFILE=`echo ${POTFILE} | sed -e 's,\.pot,\.po,' | sed -e 's,pot,'${LOCALE}'/LC_MESSAGES,'` - if [ -f $POFILE ]; - then - echo "Updating strings for ${POFILE}" - msgmerge -U ${POFILE} ${POTFILE} - else - echo "Creating ${POFILE}" - mkdir -p `echo $(dirname ${POFILE})` - cp ${POTFILE} ${POFILE} - fi - done -done - -# Now get rid of temporary POT files -rm -rf i18n/pot -rm -rf source/static - -popd