source: calamares/trunk/fuentes/ci/txpull.sh @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

  • Property svn:executable set to *
File size: 3.8 KB
Line 
1#!/bin/sh
2#
3# Fetch the Transifex translations for Calamares and incorporate them
4# into the source tree, adding commits of the different files.
5
6### INITIAL SETUP
7#
8# This stuff needs to be done once; in a real CI environment where it
9# runs regularly in a container, the setup needs to be done when
10# creating the container.
11#
12#
13# cp ~/jenkins-master/.transifexrc ~  # Transifex user settings
14# cp ~/jenkins-master/.gitconfig ~    # Git config, user settings
15# cp -R ~/jenkins-master/.ssh ~       # SSH, presumably for github
16#
17# cd "$WORKSPACE"
18# git config --global http.sslVerify false
19
20test -f "CMakeLists.txt" || { echo "! Not at Calamares top-level" ; exit 1 ; }
21test -f ".tx/config" || { echo "! Not at Calamares top-level" ; exit 1 ; }
22test -f "calamares.desktop" || { echo "! Not at Calamares top-level" ; exit 1 ; }
23
24### FETCH TRANSLATIONS
25#
26# Use Transifex client to get translations; this depends on the
27# .tx/config file to locate files, and overwrites them in the
28# filesystem with new (merged) translations.
29export QT_SELECT=5
30tx pull --force --source --all
31
32### CLEANUP TRANSLATIONS
33#
34# Some languages have been deprecated. They may still exist in Transifex,
35# so clean them up after pulling.
36#
37drop_language() {
38  rm -rf lang/python/"$1" src/modules/dummypythonqt/lang/"$1" lang/calamares_"$1".ts
39  grep -v "\\[$1]" calamares.desktop > calamares.desktop.new
40  mv calamares.desktop.new calamares.desktop
41}
42
43drop_language es_ES
44drop_language pl_PL
45
46# Also fix the .desktop file, which has some fields removed by Transifex.
47#
48{ cat calamares.desktop.in ; grep "\\[[a-zA-Z_@]*]=" calamares.desktop ; } > calamares.desktop.new
49mv calamares.desktop.new calamares.desktop
50
51### COMMIT TRANSLATIONS
52#
53# Produce multiple commits (for the various parts of the i18n
54# infrastructure used by Calamares) of the updated translations.
55# Try to be a little smart about not committing trivial changes.
56
57# Who is credited with these CI commits
58AUTHOR="--author='Calamares CI <groot@kde.org>'"
59# Message to put after the module name
60BOILERPLATE="Automatic merge of Transifex translations"
61
62git add --verbose lang/calamares*.ts
63git commit "$AUTHOR" --message="i18n: [calamares] $BOILERPLATE" | true
64
65rm -f lang/desktop*.desktop
66awk '
67        BEGIN {skip=0;}
68        /^# Translations/ {skip=1;}
69        {if (!skip || (length($0)>1 && $0 != "# Translations")) {
70                skip=0; print $0;
71        }}' < calamares.desktop > calamares.desktop.new
72mv calamares.desktop.new calamares.desktop
73git add --verbose calamares.desktop
74git commit "$AUTHOR" --message="i18n: [desktop] $BOILERPLATE" | true
75
76# Transifex updates the PO-Created timestamp also when nothing interesting
77# has happened, so drop the files which have just 1 line changed (the
78# PO-Created line). This applies only to modules which use po-files.
79git diff --numstat src/modules | awk '($1==1 && $2==1){print $3}' | xargs git checkout --
80
81# Go through the Python modules; those with a lang/ subdir have their
82# own complete gettext-based setup.
83for MODULE_DIR in $(find src/modules -maxdepth 1 -mindepth 1 -type d) ; do
84  FILES=$(find "$MODULE_DIR" -name "*.py" -a -type f)
85  if test -n "$FILES" ; then
86    MODULE_NAME=$(basename ${MODULE_DIR})
87    if [ -d ${MODULE_DIR}/lang ]; then
88      # Convert PO files to MO files
89      for POFILE in $(find ${MODULE_DIR} -name "*.po") ; do
90        sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' $POFILE
91        msgfmt -o ${POFILE%.po}.mo $POFILE
92      done
93      git add --verbose ${MODULE_DIR}/lang/*
94      git commit "$AUTHOR" --message="i18n: [${MODULE_NAME}] $BOILERPLATE" | true
95    fi
96  fi
97done
98
99for POFILE in $(find lang -name "python.po") ; do
100  sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' $POFILE
101  msgfmt -o ${POFILE%.po}.mo $POFILE
102done
103git add --verbose lang/python*
104git commit "$AUTHOR" --message="i18n: [python] $BOILERPLATE" | true
105
106# git push --set-upstream origin master
Note: See TracBrowser for help on using the repository browser.