CI: improve TX consistency

- txpush
   - don't try to push TX for the timezone list
   - xmllint --format the .ts files to avoid inconsistency between
     TX tool versions
 - txcheck
   - xmllint --format
   - hard-code the list of files, it's not worth the hassle
   - don't apply XML cleanups to POT files
   - strip linenumbers from POT files for diffing
This commit is contained in:
Adriaan de Groot 2020-01-25 16:31:28 +01:00
parent 5dad5dae02
commit 053fa28b19
2 changed files with 64 additions and 13 deletions

View File

@ -8,6 +8,13 @@
# #
# Use --cleanup as an argument to clean things up. # Use --cleanup as an argument to clean things up.
# The files that are translated; should match the contents of .tx/config
TX_FILE_LIST="lang/calamares_en.ts lang/python.pot src/modules/dummypythonqt/lang/dummypythonqt.pot calamares.desktop"
### COMMAND ARGUMENTS
#
# We need to define tx_cleanup for the --cleanup argument, although it's
# normally used much later in the script.
tx_cleanup() tx_cleanup()
{ {
# Cleanup artifacs of checking # Cleanup artifacs of checking
@ -22,6 +29,21 @@ if test "x$1" = "x--cleanup" ; then
fi fi
test -z "$1" || { echo "! Usage: txcheck.sh [--cleanup]" ; exit 1 ; } test -z "$1" || { echo "! Usage: txcheck.sh [--cleanup]" ; exit 1 ; }
### FIND EXECUTABLES
#
#
XMLLINT=""
for _xmllint in xmllint
do
$_xmllint --version > /dev/null 2>&1 && XMLLINT=$_xmllint
test -n "$XMLLINT" && break
done
### CHECK WORKING DIRECTORY
#
#
if git describe translation > /dev/null 2>&1 ; then if git describe translation > /dev/null 2>&1 ; then
: :
else else
@ -42,8 +64,6 @@ test "$DATE_PREV" -le "$DATE_HEAD" || { echo "! Translation tag has not aged eno
# Tag is good, do real work of checking strings: collect names of relevant files # Tag is good, do real work of checking strings: collect names of relevant files
test -f ".tx/config" || { echo "! No Transifex configuration is present." ; exit 1 ; } test -f ".tx/config" || { echo "! No Transifex configuration is present." ; exit 1 ; }
# Print part after = for each source_file line and delete all the rest
TX_FILE_LIST=$( sed -e '/^source_file/s+.*=++p' -e d .tx/config )
for f in $TX_FILE_LIST ; do for f in $TX_FILE_LIST ; do
test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; } test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; }
done done
@ -56,14 +76,24 @@ tx_sum()
git worktree add $WORKTREE_NAME $WORKTREE_TAG > /dev/null 2>&1 || { echo "! Could not create worktree." ; exit 1 ; } git worktree add $WORKTREE_NAME $WORKTREE_TAG > /dev/null 2>&1 || { echo "! Could not create worktree." ; exit 1 ; }
( cd $WORKTREE_NAME && sh ci/txpush.sh --no-tx ) > /dev/null 2>&1 || { echo "! Could not re-create translations." ; exit 1 ; } ( cd $WORKTREE_NAME && sh ci/txpush.sh --no-tx ) > /dev/null 2>&1 || { echo "! Could not re-create translations." ; exit 1 ; }
( cd $WORKTREE_NAME && sed -i'' -e '/<location filename/d' $TX_FILE_LIST ) # Clean up the TS (XML) files (like txpush would)
TS_FILE="$WORKTREE_NAME/lang/calamares_en.ts"
if test -n "$XMLLINT" ; then
$XMLLINT --format -o "$TS_FILE".new "$TS_FILE" && mv "$TS_FILE".new "$TS_FILE"
fi
sed -i'' -e '/<location filename/d' $TS_FILE
# Remove linenumbers from .pot
sed -i'' -e '/^#: src..*[0-9]$/d' $WORKTREE_NAME/lang/python.pot $WORKTREE_NAME/src/modules/dummypythonqt/lang/dummypythonqt.pot
_SUM=$( cd $WORKTREE_NAME && cat $TX_FILE_LIST | sha256sum ) _SUM=$( cd $WORKTREE_NAME && cat $TX_FILE_LIST | sha256sum )
echo "$_SUM" echo "$_SUM"
} }
# Check from the translation tag as well # Check from the translation tag as well
HEAD_SUM=`tx_sum build-txcheck-head ""` HEAD_SUM=`tx_sum build-txcheck-head ""` || { echo "$HEAD_SUM" ; exit 1 ; }
PREV_SUM=`tx_sum build-txcheck-prev translation` PREV_SUM=`tx_sum build-txcheck-prev translation` || { echo "$HEAD_SUM" ; exit 1 ; }
echp "$?"
# An error message will have come from the shell function # An error message will have come from the shell function
test -d build-txcheck-head || { echo "$HEAD_SUM" ; exit 1 ; } test -d build-txcheck-head || { echo "$HEAD_SUM" ; exit 1 ; }
@ -80,6 +110,6 @@ else
exit 1 exit 1
fi fi
tx_cleanup # tx_cleanup
exit 0 exit 0

View File

@ -45,11 +45,10 @@ else
} }
fi fi
### CREATE TRANSLATIONS
#
# Use local tools (depending on type of source) to create translation
# sources, then push to Transifex
### FIND EXECUTABLES
#
#
LUPDATE="" LUPDATE=""
for _lupdate in lupdate lupdate-qt5 for _lupdate in lupdate lupdate-qt5
do do
@ -58,19 +57,41 @@ do
$_lupdate -version > /dev/null 2>&1 && LUPDATE=$_lupdate $_lupdate -version > /dev/null 2>&1 && LUPDATE=$_lupdate
test -n "$LUPDATE" && break test -n "$LUPDATE" && break
done done
test -n "$LUPDATE" || { echo "! No working lupdate" ; lupdate -version ; exit 1 ; } test -n "$LUPDATE" || { echo "! No working lupdate" ; lupdate -version ; exit 1 ; }
XMLLINT=""
for _xmllint in xmllint
do
$_xmllint --version > /dev/null 2>&1 && XMLLINT=$_xmllint
test -n "$XMLLINT" && break
done
# XMLLINT is optional
### CREATE TRANSLATIONS
#
# Use local tools (depending on type of source) to create translation
# sources, then push to Transifex
# Don't pull branding translations in, # Don't pull branding translations in,
# those are done separately. # those are done separately.
_srcdirs="src/calamares src/libcalamares src/libcalamaresui src/modules src/qml" _srcdirs="src/calamares src/libcalamares src/libcalamaresui src/modules src/qml"
$LUPDATE -no-obsolete $_srcdirs -ts lang/calamares_en.ts $LUPDATE -no-obsolete $_srcdirs -ts lang/calamares_en.ts
$LUPDATE -no-obsolete -extensions cxxtr src/libcalamares/locale -ts lang/tz_en.ts # Updating the TZ only needs to happen when the TZ themselves are updated,
# very-very-rarely.
# $LUPDATE -no-obsolete -extensions cxxtr src/libcalamares/locale -ts lang/tz_en.ts
if test -n "$XMLLINT" ; then
for f in lang/calamares_en.ts
do
$XMLLINT --format -o "$f".new "$f" && mv "$f".new "$f"
done
fi
tx push --source --no-interactive -r calamares.calamares-master tx push --source --no-interactive -r calamares.calamares-master
tx push --source --no-interactive -r calamares.tz
tx push --source --no-interactive -r calamares.fdo tx push --source --no-interactive -r calamares.fdo
### PYTHON MODULES ### PYTHON MODULES
# #
# The Python tooling depends on the underlying distro to provide # The Python tooling depends on the underlying distro to provide