/[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.11 - (hide annotations) (download)
Tue Mar 2 21:16:48 2010 UTC (14 years, 9 months ago) by slords
Branch: MAIN
Changes since 1.10: +138 -141 lines
Update for new version of pootle and separating sme7 from sme8

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     mkdir -p /var/lib/pootle/tmp/ /var/www/html/{patches,errors,anaconda}
9 slords 1.1
10     #==========================================================
11    
12     export CVS_RSH=ssh
13    
14     # Update/expand smeserver cvs
15 slords 1.11 cd /var/lib/pootle/cvs/smeserver
16     for pkg in *e-smith*/sme* *sme*/sme* anaconda/sme* booty/sme*
17 slords 1.1 do
18     make -C $pkg clean &> /dev/null
19     done
20     cvs update -dPA > /dev/null
21 slords 1.11 for pkg in *e-smith*/sme* *sme*/sme* anaconda/sme* booty/sme*
22 slords 1.1 do
23     make -C $pkg prep &> /dev/null
24     done
25    
26     # Update/expand smecontribs cvs
27 slords 1.11 cd /var/lib/pootle/cvs/smecontribs
28     for pkg in *e-smith*/contribs* *sme*/contribs*
29 slords 1.1 do
30     make -C $pkg clean &> /dev/null
31     done
32     cvs update -dPA > /dev/null
33 slords 1.11 for pkg in *e-smith*/contribs* *sme*/contribs*
34 slords 1.1 do
35     make -C $pkg prep &> /dev/null
36     done
37    
38     #==========================================================
39    
40 slords 1.11 cd /var/lib/pootle/tmp
41 slords 1.1
42 slords 1.11 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 slords 1.1
60 slords 1.11 # 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 slords 1.5
68 slords 1.11 for ver in contribs7 contribs8
69 slords 1.1 do
70 slords 1.11 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 slords 1.1 done
84    
85     #==========================================================
86    
87 slords 1.11 # 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 slords 1.1 # Apply templates to languages
92 slords 1.11 for lang in $(ls -I templates /var/lib/pootle/po/{sme,contribs}[0-9] 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
93 slords 1.1 do
94     # Create compendium to assist translations
95 slords 1.11 msgcat --use-first <(msgcat $(find /var/lib/pootle/tmp/errors/*/$lang/ -name '*.po') | msgattrib --translated --no-fuzzy) \
96     <(msgcat $(find /var/lib/pootle/po/*/$lang/ -name '*.po') | msgattrib --translated --no-fuzzy) \
97     > /var/lib/pootle/tmp/compendium-$lang.po
98 slords 1.1
99     # Use compendium to migrate each project to new template
100 slords 1.11 for proj in $(ls -d /var/lib/pootle/po/{sme,contribs}[0-9]/$lang 2> /dev/null | sed 's@.*/\([^/]\+\)/[^/]\+$@\1@')
101 slords 1.1 do
102 slords 1.11 mkdir -p /var/lib/pootle/tmp/$proj/$lang
103     pomigrate2 -F -C=/var/lib/pootle/tmp/compendium-$lang.po -q --locale=$lang \
104     /var/lib/pootle/po/$proj/$lang /var/lib/pootle/tmp/$proj/$lang /var/lib/pootle/po/$proj/templates > /dev/null
105 slords 1.1
106     # Ensure language is correct
107 slords 1.11 sed -i "/msgid \"en-us\"/{N;s@msgstr \"[^\"]*\"@msgstr \"$lang\"@}" /var/lib/pootle/tmp/$proj/$lang/* 2> /dev/null
108 slords 1.1
109     # Generate translation memory for panels
110 slords 1.11 updatetm --progress none -c 4 -i /var/lib/pootle/tmp/$proj/$lang -t /var/lib/pootle/tmp/compendium-$lang.po -o /var/lib/pootle/tmp/$proj/$lang
111 slords 1.1 done
112     done
113    
114     # Set package name/version in new po files
115 slords 1.11 for ver in 7 8
116     do
117     find /var/lib/pootle/tmp/sme$ver/ -name '*.po' -printf "sed -i 's@Id-Version:[^\\\\]*@Id-Version: SME Server $ver (%f)@' %p\n" | sh
118     find /var/lib/pootle/tmp/contribs$ver/ -name '*.po' -printf "sed -i 's@Id-Version:[^\\\\]*@Id-Version: SME Contribs $ver (%f)@' %p\n" | sh
119     done
120 slords 1.1
121     # Move files that have changed
122 slords 1.11 for chk in $(find /var/lib/pootle/tmp/{sme,contribs}[0-9]/ -type f)
123 slords 1.1 do
124     diffmv $chk $(echo $chk | sed 's@/tmp/@/po/@')
125     done
126    
127 slords 1.10 # Copy po files so we can create error reports
128 slords 1.11 rsync -amR --include '*/' --include '*.po' --exclude '*' /var/lib/pootle/po/./{sme,contribs}[0-9]/ /var/lib/pootle/tmp/errors/
129 slords 1.9
130 slords 1.1 #==========================================================
131    
132     # Recalculate stats and restart server
133 slords 1.11 /usr/sbin/PootleServer --refreshstats &> /dev/null
134 slords 1.1
135     #==========================================================
136    
137 slords 1.10 # Create error compendium to assist translators
138 slords 1.11 find /var/lib/pootle/tmp/errors/ -type f -exec sed -i '/^#~/d' {} \+
139     for lang in $(ls -I templates /var/lib/pootle/po/{sme,contribs}[0-9] 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
140 slords 1.10 do
141 slords 1.11 msgcat $(find /var/lib/pootle/tmp/errors/*/$lang/ -name '*.po') \
142     | msgattrib --only-fuzzy \
143     | sed '0,/^$/d;/^#~/d' \
144     | sed ':a;/^\n*$/{$d;N;ba;}' \
145     > errors-$lang.po
146 slords 1.10 chmod 644 errors-$lang.po
147     diffmv errors-$lang.po /var/www/html/errors/errors-$lang.po
148     done
149    
150 slords 1.1 # Build diffs for languages
151 slords 1.11 for pkg in $(ls /var/lib/pootle/po/{sme,contribs}[0-9]/templates/ | sed -n 's@\.pot@@p' | sort -u)
152 slords 1.1 do
153 slords 1.11 pkgs=$(find /var/lib/pootle/cvs/*/*/*/*/root/etc/e-smith/locale/en-us -name $pkg -not -regex '.*\+ldap/.*')
154     if [ -z "$pkgs" ]
155     then
156     if [ $pkg == "anaconda" ]
157     then
158     ls /var/lib/pootle/po/*/*/$pkg.po | cut -d/ --output-delimiter " " -f6,7 | while read ver lang
159     do
160     mkdir -p /var/www/html/anaconda/$ver/$lang/LC_MESSAGES
161     anacondagen $ver $lang > /var/www/html/anaconda/$ver/$lang/LC_MESSAGES/anaconda.mo
162     [ -s /var/www/html/anaconda/$ver/$lang/LC_MESSAGES/anaconda.mo ] || rm -rf /var/www/html/anaconda/$ver/$lang
163     done
164     else
165     pkgs=$(ls -d /var/lib/pootle/cvs/*/smeserver-$pkg/*/*/root 2> /dev/null)
166     [ -z "$pkgs" ] && pkgs=$(ls -d /var/lib/pootle/cvs/*/smeserver-locale/*/*/root)
167    
168     echo "$pkgs" | cut -d/ --output-delimiter " " -f8,9 | while read ver pkgname
169     do
170     for lang in $(ls -I templates /var/lib/pootle/po/$ver/ 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
171     do
172     mkdir -p diff/$ver/${pkgname}.update/po/$lang
173     msgcat -F --no-wrap /var/lib/pootle/po/$ver/$lang/${pkg}.po \
174     | grep -v 'Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|X-Generator' \
175     | sed '0,/msgid ""/{/^#/d};/^#,/d;s@^\(#: \)[^/]\+/root@\1root@' \
176     > diff/$ver/${pkgname}.update/po/$lang/${pkg/backup-console/backup}.po
177     done
178     done
179     fi
180     else
181     echo "$pkgs" | grep -qv '/contribs[0-9]/' && pkgs=$(echo "$pkgs" | grep '/contribs[0-9]/'; ls -d /var/lib/pootle/cvs/*/smeserver-locale/*/*/root)
182     echo "$pkgs" | cut -d/ --output-delimiter " " -f8,9 | while read ver pkgname
183     do
184     if echo $ver | grep -q contribs
185     then
186     mkdir -p diff/$ver/${pkgname}.update/$(localedir en-us $pkg)
187     cat /var/lib/pootle/templates/$ver/$pkg.orig \
188     | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \
189     > diff/$ver/${pkgname}.update/$(localedir en-us $pkg)/$pkg
190     fi
191     for lang in $(ls -I templates /var/lib/pootle/po/$ver/ 2> /dev/null | grep '[[:alpha:]]$' | sort -u)
192     do
193     mkdir -p diff/$ver/${pkgname}.update/$(localedir $lang $pkg)
194     xmlgen $ver /var/lib/pootle/po/$ver/$lang/${pkg}.po \
195     > diff/$ver/${pkgname}.update/$(localedir $lang $pkg)/$pkg
196     done
197     done
198     fi
199 slords 1.1 done
200    
201 slords 1.11 # Build diffs
202     ls -d diff/*/* | sed 's@.update$@@' | cut -d/ --output-delimiter " " -f2,3 | while read ver pkg
203 slords 1.1 do
204 slords 1.11 mkdir -p /var/www/html/patches/$ver
205     rm -f /var/www/html/patches/$ver/$(echo $pkg | sed 's/-[^-]\+$//')-*-locale-*.patch
206     if [ -d "diff/$ver/$pkg.update/root" ]
207 slords 1.1 then
208 slords 1.11 diff -ruN {/var/lib/pootle/cvs/*/*/$ver/$pkg,diff/$ver/$pkg.update}/root/etc/e-smith/locale \
209     | sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/root/.*\)@\1 \2@;/^diff -ruN/d' \
210     >> /var/www/html/patches/$ver/$pkg-locale-$(date +%F).patch
211     fi
212     if [ -d "diff/$ver/$pkg.update/po" ]
213     then
214     diff -ruN {/var/lib/pootle/cvs/*/*/$ver/$pkg,diff/$ver/$pkg.update}/po \
215     | sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/po/.*\)@\1 \2@;/^diff -ruN/d' \
216     >> /var/www/html/patches/$ver/$pkg-locale-$(date +%F).patch
217 slords 1.1 fi
218     done
219    

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