File: maintenanceTasks.sh

package info (click to toggle)
0ad 0.0.23.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,292 kB
  • sloc: cpp: 245,166; ansic: 200,249; python: 13,754; sh: 6,104; perl: 4,620; makefile: 977; xml: 810; java: 533; ruby: 229; erlang: 46; pascal: 30; sql: 21; tcl: 4
file content (68 lines) | stat: -rwxr-xr-x 2,219 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash

# Regenerates the POT files and uploads them to Transifex, downloads the latest
# translations from Transifex, and commits the updated POT and PO files.

SCRIPT_PATH="`dirname \"$0\"`"


# VCS Config ##################################################################

VCS="svn"
VCS_UPDATE="svn update"
VCS_REVERT="svn revert %s@"
VCS_ADD="svn add %s"
VCS_COMMIT_AND_PUSH="svn commit -m '[i18n] Updated POT and PO files.'"
git rev-parse &> /dev/null
if [[ "$?" = "0" ]]; then
    VCS="git"
    VCS_UPDATE="git pull --rebase origin master"
    VCS_REVERT="git checkout -- %s"
    VCS_ADD="git add %s"
    VCS_COMMIT_AND_PUSH="git commit -am '[i18n] Updated POT and PO files.' &&
                         git pull --rebase origin master &&
                         git push origin master"
fi


# Source Update ###############################################################

echo ":: Updating sources…"
${VCS_UPDATE}


# POT Generation ##############################################################

echo ":: Regenerating the translation templates…"
python2 "${SCRIPT_PATH}/updateTemplates.py"


# PO Download #################################################################

echo ":: Downloading translations from Transifex…"
python2 "${SCRIPT_PATH}/pullTranslations.py"


# Pre-Commit Cleanup  #########################################################

# Note: I (Gallaecio) tried using GNU parallel for this, the problem is that
# poediff accesses Subversion, and when you use Subversion more than once
# simultaneously you end up with commands not running properly due to the
# Subversion database being locked. So just take a beverage, put some music on
# and wait for the task to eventually finish.

echo ":: Reverting unnecessary changes…"
for FILE_PATH in $(find "${SCRIPT_PATH}/../../../binaries/data" -name "*.pot" -o -name "*.po")
do
    if [[ ! -n "$(poediff -c ${VCS} -rHEAD -qs "${FILE_PATH}")" ]]; then
        $(printf "${VCS_REVERT}" "${FILE_PATH}")
    else
        $(printf "${VCS_ADD}" ${FILE_PATH}) &> /dev/null
    fi
done


# Commit ######################################################################

echo ":: Done"
echo "   Now you can commit your changes to the server."