/[smeserver]/builds_bin/update_templates
ViewVC logotype

Annotation of /builds_bin/update_templates

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.19 - (hide annotations) (download)
Tue Mar 28 17:53:55 2017 UTC (7 years, 7 months ago) by unnilennium
Branch: MAIN
Changes since 1.18: +5 -2 lines
SME8 EOL

1 slords 1.1 #!/bin/bash
2    
3     # Functions
4 slords 1.11 . /var/lib/pootle/bin/functions
5 slords 1.1
6     # Clean up tmp dir
7 slords 1.11 rm -rf /var/lib/pootle/tmp
8 unnilennium 1.18 mkdir -p /var/lib/pootle/tmp/ /var/www/html/pootle/{patches,errors,anaconda}
9 slords 1.1
10     #==========================================================
11 unnilennium 1.18 # to help debugging set to 1 and it will help to follow where errors occurs
12     debug=0
13 slords 1.1
14     export CVS_RSH=ssh
15    
16 unnilennium 1.18 (($debug)) && builtin echo "Update/expand smeserver cvs"
17 slords 1.1 # Update/expand smeserver cvs
18 slords 1.11 cd /var/lib/pootle/cvs/smeserver
19     for pkg in *e-smith*/sme* *sme*/sme* anaconda/sme* booty/sme*
20 slords 1.1 do
21     make -C $pkg clean &> /dev/null
22     done
23     cvs update -dPA > /dev/null
24 slords 1.11 for pkg in *e-smith*/sme* *sme*/sme* anaconda/sme* booty/sme*
25 slords 1.1 do
26     make -C $pkg prep &> /dev/null
27     done
28    
29 unnilennium 1.18 (($debug)) && builtin echo "Update/expand smecontribs cvs"
30 slords 1.1 # Update/expand smecontribs cvs
31 slords 1.11 cd /var/lib/pootle/cvs/smecontribs
32     for pkg in *e-smith*/contribs* *sme*/contribs*
33 slords 1.1 do
34     make -C $pkg clean &> /dev/null
35     done
36     cvs update -dPA > /dev/null
37 slords 1.11 for pkg in *e-smith*/contribs* *sme*/contribs*
38 slords 1.1 do
39     make -C $pkg prep &> /dev/null
40     done
41    
42     #==========================================================
43    
44 slords 1.11 cd /var/lib/pootle/tmp
45 slords 1.1
46 slords 1.16 # Sync database stores to filesystem
47     django-admin sync_stores --settings=pootle.settings &> /dev/null
48    
49 unnilennium 1.19 for ver in sme9 sme10
50 slords 1.11 do
51 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "anaconda $ver" # debug jpp
52 slords 1.11 # Update anaconda template
53     anacondatmpl $ver > anaconda.pot
54     diffmv anaconda.pot /var/lib/pootle/po/$ver/templates/anaconda.pot
55    
56 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "console template $ver "
57 slords 1.11 # Update console templates
58     potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-quota/$ver/ -type f -name adminQuotaSummary.tmpl) > adminQuotaSummary.tmpl.pot
59     diffmv adminQuotaSummary.tmpl.pot /var/lib/pootle/po/$ver/templates/adminQuotaSummary.tmpl.pot
60     potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-backup/$ver/ -type f -name do_backup -o -regex '.*/crontab/backup') > backup-console.pot
61     diffmv backup-console.pot /var/lib/pootle/po/$ver/templates/backup-console.pot
62     potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-manager/$ver/ -type f -name 25Copyright) > foot.tmpl.pot
63     diffmv foot.tmpl.pot /var/lib/pootle/po/$ver/templates/foot.tmpl.pot
64 slords 1.15 potempl $(find /var/lib/pootle/cvs/smeserver/*/$ver/ -type f -regex '.*/e-?smith/console.*' -not -regex '.*\+ldap/.*') > server-console.pot
65 slords 1.11 diffmv server-console.pot /var/lib/pootle/po/$ver/templates/server-console.pot
66     potempl $(find /var/lib/pootle/cvs/smeserver/e-smith-quota/$ver/ -type f -name userOverQuota.tmpl) > userOverQuota.tmpl.pot
67     diffmv userOverQuota.tmpl.pot /var/lib/pootle/po/$ver/templates/userOverQuota.tmpl.pot
68 slords 1.1
69 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "panel template $ver "
70 slords 1.11 # Update panel templates
71     for pkg in $(find /var/lib/pootle/cvs/smeserver/*/$ver/*/root/etc/e-smith/locale/en-us/ -type f -not -regex '.*\+ldap/.*' 2> /dev/null)
72     do
73     xmltempl $ver $pkg
74     diffcp /var/lib/pootle/templates/$ver/$(basename $pkg).pot /var/lib/pootle/po/$ver/templates/$(basename $pkg).pot
75     done
76     done
77 slords 1.5
78 unnilennium 1.19 for ver in contribs9
79 slords 1.1 do
80 unnilennium 1.18 nver=$(echo $ver| tr -dc '0-9')
81     if [ "$nver" -ge "9" ]
82 slords 1.11 then
83 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "sme*admin template $ver "
84     # Update sme*admin template
85     #echo "smeserver-sme${nver}admin"
86     potempl /var/lib/pootle/cvs/smecontribs/smeserver-sme${nver}admin/$ver/*/root/{etc/e-smith/web/functions/sme${nver}admin,usr/bin/sme${nver}admind} > sme${nver}admin.pot
87     diffmv sme${nver}admin.pot /var/lib/pootle/po/$ver/templates/sme${nver}admin.pot
88 slords 1.11 fi
89    
90 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "contribs others template $ver"
91 slords 1.11 # Update contrib panel templates
92     for pkg in $(find /var/lib/pootle/cvs/smecontribs/*/$ver/*/root/etc/e-smith/locale/en-us/ -type f 2> /dev/null)
93     do
94     xmltempl $ver $pkg
95     diffcp /var/lib/pootle/templates/$ver/$(basename $pkg).pot /var/lib/pootle/po/$ver/templates/$(basename $pkg).pot
96     done
97 slords 1.1 done
98    
99     #==========================================================
100    
101 slords 1.11 # Create copy of po files without obsolete strings
102     rsync -amR --include '*/' --include '*.po' --exclude '*' /var/lib/pootle/po/./{sme,contribs}[0-9]/ /var/lib/pootle/tmp/errors/
103     find /var/lib/pootle/tmp/errors/ -type f -exec sed -i '/^#~/d' {} \+
104    
105 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "Apply templates to languages"
106 slords 1.1 # Apply templates to languages
107 slords 1.11 for lang in $(ls -I templates /var/lib/pootle/po/{sme,contribs}[0-9] 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
108 slords 1.1 do
109     # Create compendium to assist translations
110 slords 1.11 msgcat --use-first <(msgcat $(find /var/lib/pootle/tmp/errors/*/$lang/ -name '*.po') | msgattrib --translated --no-fuzzy) \
111 slords 1.14 <(msgcat --to-code UTF-8 $(find /var/lib/pootle/po/*/$lang/ -name '*.po') | msgattrib --translated --no-fuzzy) \
112 slords 1.11 > /var/lib/pootle/tmp/compendium-$lang.po
113 slords 1.1
114     # Use compendium to migrate each project to new template
115 slords 1.12 for ver in $(ls -d /var/lib/pootle/po/{sme,contribs}[0-9]/$lang 2> /dev/null | sed 's@.*/\([^/]\+\)/[^/]\+$@\1@')
116 slords 1.1 do
117 slords 1.12 mkdir -p /var/lib/pootle/tmp/$ver/$lang
118 slords 1.11 pomigrate2 -F -C=/var/lib/pootle/tmp/compendium-$lang.po -q --locale=$lang \
119 slords 1.12 /var/lib/pootle/po/$ver/$lang /var/lib/pootle/tmp/$ver/$lang /var/lib/pootle/po/$ver/templates > /dev/null
120 slords 1.1
121     # Ensure language is correct
122 slords 1.12 sed -i "/msgid \"en-us\"/{N;s@msgstr \"[^\"]*\"@msgstr \"$lang\"@}" /var/lib/pootle/tmp/$ver/$lang/* 2> /dev/null
123 slords 1.1
124 slords 1.13 # Set package version in po files
125     sed -i "s@\(Id-Version:\)[^\\]*@\1 SME $(echo $ver | sed 's@sme@Server @;s@contribs@Contribs @')@" /var/lib/pootle/tmp/$ver/$lang/*.po 2> /dev/null
126    
127 slords 1.1 # Generate translation memory for panels
128 slords 1.12 updatetm --progress none -c 4 -i /var/lib/pootle/tmp/$ver/$lang -t /var/lib/pootle/tmp/compendium-$lang.po -o /var/lib/pootle/tmp/$ver/$lang
129 slords 1.1
130 slords 1.12 find /var/lib/pootle/tmp/$ver/$lang -type f | while read pkg
131     do
132     # Move files that have changed
133     diffmv $pkg $(echo $pkg | sed 's@/tmp/@/po/@')
134     done
135     done
136 slords 1.1 done
137    
138 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "Copy po files so we can create error reports"
139 slords 1.10 # Copy po files so we can create error reports
140 slords 1.11 rsync -amR --include '*/' --include '*.po' --exclude '*' /var/lib/pootle/po/./{sme,contribs}[0-9]/ /var/lib/pootle/tmp/errors/
141 slords 1.9
142 slords 1.1 #==========================================================
143    
144 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "Sync filesystem to database stores"
145 slords 1.16 # Sync filesystem to database stores
146     django-admin update_stores --settings=pootle.settings &> /dev/null
147    
148 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "Recalculate stats and restart server"
149 slords 1.1 # Recalculate stats and restart server
150 slords 1.16 django-admin refresh_stats --settings=pootle.settings &> /dev/null
151 slords 1.1
152     #==========================================================
153    
154 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "Create error compendium to assist translators"
155 slords 1.10 # Create error compendium to assist translators
156 slords 1.11 find /var/lib/pootle/tmp/errors/ -type f -exec sed -i '/^#~/d' {} \+
157     for lang in $(ls -I templates /var/lib/pootle/po/{sme,contribs}[0-9] 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
158 slords 1.10 do
159 slords 1.11 msgcat $(find /var/lib/pootle/tmp/errors/*/$lang/ -name '*.po') \
160     | msgattrib --only-fuzzy \
161     | sed '0,/^$/d;/^#~/d' \
162     | sed ':a;/^\n*$/{$d;N;ba;}' \
163 slords 1.17 > errors-$lang.err
164     chmod 644 errors-$lang.err
165 unnilennium 1.18 diffmv errors-$lang.err /var/www/html/pootle/errors/errors-$lang.err
166 slords 1.10 done
167    
168 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "Build diffs for languages"
169 slords 1.1 # Build diffs for languages
170 slords 1.11 for pkg in $(ls /var/lib/pootle/po/{sme,contribs}[0-9]/templates/ | sed -n 's@\.pot@@p' | sort -u)
171 slords 1.1 do
172 slords 1.11 pkgs=$(find /var/lib/pootle/cvs/*/*/*/*/root/etc/e-smith/locale/en-us -name $pkg -not -regex '.*\+ldap/.*')
173     if [ -z "$pkgs" ]
174     then
175     if [ $pkg == "anaconda" ]
176     then
177     ls /var/lib/pootle/po/*/*/$pkg.po | cut -d/ --output-delimiter " " -f6,7 | while read ver lang
178     do
179 unnilennium 1.18 [[ $ver == *7 ]] && continue
180 unnilennium 1.19 [[ $ver == *8 ]] && continue
181 unnilennium 1.18
182     (($debug)) && echo&& echo builtin echo "anaconda $ver $lang "
183     mkdir -p /var/www/html/pootle/anaconda/$ver/$lang/LC_MESSAGES
184     anacondagen $ver $lang > /var/www/html/pootle/anaconda/$ver/$lang/LC_MESSAGES/anaconda.mo
185     [ -s /var/www/html/pootle/anaconda/$ver/$lang/LC_MESSAGES/anaconda.mo ] || rm -rf /var/www/html/pootle/anaconda/$ver/$lang
186 slords 1.11 done
187     else
188     pkgs=$(ls -d /var/lib/pootle/cvs/*/smeserver-$pkg/*/*/root 2> /dev/null)
189     [ -z "$pkgs" ] && pkgs=$(ls -d /var/lib/pootle/cvs/*/smeserver-locale/*/*/root)
190    
191     echo "$pkgs" | cut -d/ --output-delimiter " " -f8,9 | while read ver pkgname
192     do
193 unnilennium 1.18 [[ $ver == *7 ]] && continue
194 unnilennium 1.19 [[ $ver == *8 ]] && continue
195 unnilennium 1.18
196     (($debug)) && echo&& echo builtin echo "$pkg $ver"
197 slords 1.11 for lang in $(ls -I templates /var/lib/pootle/po/$ver/ 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
198     do
199 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "* $pkg $lang "
200 slords 1.17 if [ -f "/var/lib/pootle/po/$ver/$lang/${pkg}.po" ]
201     then
202     mkdir -p diff/$ver/${pkgname}.update/po/$lang
203     msgcat -F --no-wrap /var/lib/pootle/po/$ver/$lang/${pkg}.po \
204     | grep -v 'Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|X-Generator' \
205     | sed '0,/msgid ""/{/^#/d};/^#,/d;s@^\(#: \)[^/]\+/root@\1root@' \
206     > diff/$ver/${pkgname}.update/po/$lang/${pkg/backup-console/backup}.po
207     fi
208 slords 1.11 done
209     done
210     fi
211     else
212     echo "$pkgs" | grep -qv '/contribs[0-9]/' && pkgs=$(echo "$pkgs" | grep '/contribs[0-9]/'; ls -d /var/lib/pootle/cvs/*/smeserver-locale/*/*/root)
213     echo "$pkgs" | cut -d/ --output-delimiter " " -f8,9 | while read ver pkgname
214     do
215 unnilennium 1.18 [[ $ver == *7 ]] && continue
216 unnilennium 1.19 [[ $ver == *8 ]] && continue
217 unnilennium 1.18
218     if [[ $ver == contribs* ]]
219 slords 1.11 then
220 unnilennium 1.18 if [ -f /var/lib/pootle/templates/$ver/$pkg.orig ]
221     then
222     (($debug)) && echo&& echo builtin echo "$pkg update $ver"
223     mkdir -p diff/$ver/${pkgname}.update/$(localedir en-us $pkg)
224     cat /var/lib/pootle/templates/$ver/$pkg.orig \
225     | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \
226     > diff/$ver/${pkgname}.update/$(localedir en-us $pkg)/$pkg
227     fi
228 slords 1.11 fi
229     for lang in $(ls -I templates /var/lib/pootle/po/$ver/ 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
230     do
231 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "* $pkg $lang "
232 slords 1.11 mkdir -p diff/$ver/${pkgname}.update/$(localedir $lang $pkg)
233     xmlgen $ver /var/lib/pootle/po/$ver/$lang/${pkg}.po \
234     > diff/$ver/${pkgname}.update/$(localedir $lang $pkg)/$pkg
235     done
236     done
237     fi
238 slords 1.1 done
239    
240 unnilennium 1.18 (($debug)) && echo&& echo builtin echo "Build patches"
241 slords 1.11 # Build diffs
242     ls -d diff/*/* | sed 's@.update$@@' | cut -d/ --output-delimiter " " -f2,3 | while read ver pkg
243 slords 1.1 do
244 unnilennium 1.18 mkdir -p /var/www/html/pootle/patches/$ver
245     rm -f /var/www/html/pootle/patches/$ver/$(echo $pkg | sed 's/-[^-]\+$//')-*-locale-*.patch
246 slords 1.11 if [ -d "diff/$ver/$pkg.update/root" ]
247 slords 1.1 then
248 slords 1.11 diff -ruN {/var/lib/pootle/cvs/*/*/$ver/$pkg,diff/$ver/$pkg.update}/root/etc/e-smith/locale \
249     | sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/root/.*\)@\1 \2@;/^diff -ruN/d' \
250 unnilennium 1.18 >> /var/www/html/pootle/patches/$ver/$pkg-locale-$(date +%F).patch
251 slords 1.11 fi
252     if [ -d "diff/$ver/$pkg.update/po" ]
253     then
254     diff -ruN {/var/lib/pootle/cvs/*/*/$ver/$pkg,diff/$ver/$pkg.update}/po \
255     | sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/po/.*\)@\1 \2@;/^diff -ruN/d' \
256 unnilennium 1.18 >> /var/www/html/pootle/patches/$ver/$pkg-locale-$(date +%F).patch
257 slords 1.1 fi
258     done
259    

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed