summaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
authorAdriaan de Groot <groot@kde.org>2020-01-25 16:31:28 +0100
committerAdriaan de Groot <groot@kde.org>2020-01-25 17:02:07 +0100
commit053fa28b19db23c1645acf0357022f4d26beeb39 (patch)
tree45bdca4dbcb49464b3227d574913faacca5b1525 /ci
parent5dad5dae02980d3c7da8b33dd11aeaf8f35a6fa5 (diff)
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
Diffstat (limited to 'ci')
-rw-r--r--ci/txcheck.sh42
-rwxr-xr-xci/txpush.sh35
2 files changed, 64 insertions, 13 deletions
diff --git a/ci/txcheck.sh b/ci/txcheck.sh
index a28caaee9..6c5d86c77 100644
--- a/ci/txcheck.sh
+++ b/ci/txcheck.sh
@@ -8,6 +8,13 @@
#
# 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()
{
# Cleanup artifacs of checking
@@ -22,6 +29,21 @@ if test "x$1" = "x--cleanup" ; then
fi
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
:
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
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
test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; }
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 ; }
( 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 )
echo "$_SUM"
}
# Check from the translation tag as well
-HEAD_SUM=`tx_sum build-txcheck-head ""`
-PREV_SUM=`tx_sum build-txcheck-prev translation`
+HEAD_SUM=`tx_sum build-txcheck-head ""` || { echo "$HEAD_SUM" ; exit 1 ; }
+PREV_SUM=`tx_sum build-txcheck-prev translation` || { echo "$HEAD_SUM" ; exit 1 ; }
+echp "$?"
# An error message will have come from the shell function
test -d build-txcheck-head || { echo "$HEAD_SUM" ; exit 1 ; }
@@ -80,6 +110,6 @@ else
exit 1
fi
-tx_cleanup
+# tx_cleanup
exit 0
diff --git a/ci/txpush.sh b/ci/txpush.sh
index 930b7ebc2..7d2c1ffaa 100755
--- a/ci/txpush.sh
+++ b/ci/txpush.sh
@@ -45,11 +45,10 @@ else
}
fi
-### CREATE TRANSLATIONS
-#
-# Use local tools (depending on type of source) to create translation
-# sources, then push to Transifex
+### FIND EXECUTABLES
+#
+#
LUPDATE=""
for _lupdate in lupdate lupdate-qt5
do
@@ -58,19 +57,41 @@ do
$_lupdate -version > /dev/null 2>&1 && LUPDATE=$_lupdate
test -n "$LUPDATE" && break
done
-
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,
# those are done separately.
_srcdirs="src/calamares src/libcalamares src/libcalamaresui src/modules src/qml"
$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.tz
tx push --source --no-interactive -r calamares.fdo
+
### PYTHON MODULES
#
# The Python tooling depends on the underlying distro to provide