-
Notifications
You must be signed in to change notification settings - Fork 345
/
run.sh
executable file
·186 lines (158 loc) · 7.02 KB
/
run.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
#
# This script uses the themestringstool to automate the generation of
# themestrings.
#
# The themes are downloaded from the internet and the strings are extracted
# from specific themes or from all of the available themes.
#
# Strings related to the frontend or the backend goes into the "mythtv"
# translation. Strings related to a plugin goes into the respective plugin.
#
# It should be sufficient to run this script once without any arguments, to
# update all themestrings for mythfrontend and the plugins.
#
set -e
TS=$(pwd)/themestrings
DOWNLOAD_DIR="temp_download"
MYTHTHEMES_CORE=$(ls ../mythtv/themes/ --file-type |grep "/$")
MYTHTHEMES_DL="http://themes.mythtv.org/themes/repository/trunk/themes.zip"
REAL_XMLPLUGINS="browser-ui.xml gallery-ui.xml game-ui.xml music-ui.xml \
mytharchive-ui.xml mythburn-ui.xml netvision-ui.xml \
news-ui.xml zoneminder-ui.xml weather-ui.xml \
mythnative-ui.xml musicsettings-ui.xml steppes-music.xml music-base.xml"
BOGUS_XMLPLUGINS="dvd-ui.xml gallery2-ui.xml" # dvd-ui.xml (DVD ripper) needs
# to be in this list to be excluded from mythtv. It isn't used anymore,
# but some themes still contains it.
# gallery2-ui.xml is a bogus file in the blue-abstract theme.
XMLPLUGINS="${REAL_XMLPLUGINS} ${BOGUS_XMLPLUGINS}"
if [ ! -e ${TS} ]; then
echo ""
echo "ERROR: The executable ${TS} doesn't exist, have you compiled it yet?"
echo ""
exit 1
fi
if [ $(id -u) -eq 0 ]; then
echo ""
echo "ERROR: You need to run this script as a regular user, you\
cannot run it with root/sudo."
echo ""
exit 1
fi
# Download overview of themes to extract their descriptions and URLs
[ -d ${DOWNLOAD_DIR}/themes ] && rm -rf temp_download/themes/*
[ -d ${DOWNLOAD_DIR}/trunk ] && rm -rf temp_download/trunk/*
[ ! -d ${DOWNLOAD_DIR}/themes ] && mkdir -p temp_download/themes
echo "Downloading list of themes.."
wget -q ${MYTHTHEMES_DL} -O ${DOWNLOAD_DIR}/themes.zip
echo "Extracting list of themes.."
unzip -q -o ${DOWNLOAD_DIR}/themes.zip -d temp_download/
# Download the themes
echo ""
echo "Downloading and extracting all available themes:"
echo ""
for i in $(ls ${DOWNLOAD_DIR}/trunk/); do
THEME_URL=$(cat ${DOWNLOAD_DIR}/trunk/${i}/themeinfo.xml |grep "</*url>"|sed -e "s/ *<\/*url>//g")
THEME_FILENAME=$(basename ${THEME_URL})
[ ! -f ${DOWNLOAD_DIR}/${THEME_FILENAME} ] && echo "Downloading theme ${THEME_FILENAME}.." && wget -q ${THEME_URL} -P temp_download/
echo "Extracting theme ${THEME_FILENAME}.."
unzip -q -o ${DOWNLOAD_DIR}/${THEME_FILENAME} -d temp_download/themes/
done
#####################################################################
# #
# Select the themes from which strings should be extracted #
# #
#####################################################################
# Select the themes that should be translatable (theme name = directory name after extraction)
TRANSLATABLE_THEMES="Arclight Childish Graphite Mythbuntu MythCenter MythCenter-wide Steppes Steppes-narrow Terra"
#TRANSLATABLE_THEMES=$(ls ${DOWNLOAD_DIR}/themes/ --file-type |grep "/$"|tr '/' ' ') #All themes
#Remove the extracted themes which shouldn't be translatable
echo ""
echo "Strings will be extracted from the following themes:"
echo ${TRANSLATABLE_THEMES} | tr ' ' '\n'
shopt -s extglob
rm -rf ${DOWNLOAD_DIR}/themes/!($(echo ${TRANSLATABLE_THEMES}|tr ' ' '|'))
shopt -u extglob
#####################################################################
# #
# Generate a themestrings.h file for mythtv #
# #
# Contains non-plugin related strings as well as theme descriptions #
# #
#####################################################################
# Exclude mythplugins directory and myththemes files related to plugins as
# we don't want these strings added to mythfrontend
chmod a-x ../mythplugins
for I in ${TRANSLATABLE_THEMES}; do
for J in ${XMLPLUGINS}; do
[ -e ${DOWNLOAD_DIR}/themes/${I}/${J} ] && chmod a-r temp_download/themes/${I}/${J}
done
done
# Also exclude the plugin-related theme files in the mythtv core themes
pushd ../mythtv/themes > /dev/null
for I in ${MYTHTHEMES_CORE}; do
for J in ${XMLPLUGINS}; do
[ -e ${I}${J} ] && chmod a-r ${I}${J}
done
done
popd > /dev/null
# Generate themestrings.h file for mythtv
pushd ../mythtv/themes > /dev/null
echo ""
echo "Generating themestrings.h file for mythtv.."
${TS} ../.. . &> /dev/null
ls -l themestrings.h
echo "Number of strings: $(( $(cat themestrings.h|wc -l)-2 ))"
popd > /dev/null
# Restore directory permissions for mythplugins
chmod a+x ../mythplugins
for I in ${TRANSLATABLE_THEMES}; do
for J in ${XMLPLUGINS}; do
[ -e ${DOWNLOAD_DIR}/themes/${I}/${J} ] && chmod a+r temp_download/themes/${I}/${J}
done
done
# Restore file permissions for plugin-related theme files
pushd ../mythtv/themes > /dev/null
for I in ${MYTHTHEMES_CORE}; do
for J in ${XMLPLUGINS}; do
[ -e ${I}${J} ] && chmod a+r ${I}${J}
done
done
popd > /dev/null
#####################################################################
# #
# Generate themestrings.h files for the plugins #
# #
# Contains plugin-related strings from core and downloadable themes #
# #
#####################################################################
# updateplugin plugindir [xml files]
function updateplugin {
ARGS=($@)
XML_FILES=${ARGS[@]:1}
pushd ../mythplugins/${1} > /dev/null
[ ! -d temp_themestrings ] && mkdir temp_themestrings &> /dev/null
for xmlfile in ${XML_FILES}; do
COUNT=0
[ -n "${xmlfile}" ] && for sourcefile in $(ls ../../themestringstool/${DOWNLOAD_DIR}/themes/*/${xmlfile} ../../mythtv/themes/*/${xmlfile} 2>/dev/null); do
cp ${sourcefile} temp_themestrings/${COUNT}-${xmlfile}
COUNT=$((COUNT+1))
done
done
echo ""
echo "Generating themestrings.h file for ${1}.."
${TS} . $(pwd)/i18n > /dev/null
ls -l i18n/themestrings.h
echo "Number of strings: $(( $(cat i18n/themestrings.h|wc -l)-2 ))"
rm -rf temp_themestrings
popd > /dev/null
}
updateplugin mytharchive mytharchive-ui.xml mythburn-ui.xml mythnative-ui.xml
updateplugin mythbrowser browser-ui.xml
updateplugin mythgallery gallery-ui.xml
updateplugin mythgame game-ui.xml
updateplugin mythmusic music-ui.xml musicsettings-ui.xml steppes-music.xml music-base.xml
updateplugin mythnetvision netvision-ui.xml
updateplugin mythnews news-ui.xml
updateplugin mythweather weather-ui.xml
updateplugin mythzoneminder zoneminder-ui.xml