/[smeserver]/builds_bin/update_templates
ViewVC logotype

Contents of /builds_bin/update_templates

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


Revision 1.14 - (show annotations) (download)
Thu Apr 8 20:03:57 2010 UTC (14 years, 7 months ago) by slords
Branch: MAIN
Changes since 1.13: +1 -1 lines
Tools update

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

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