/[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.20 - (hide annotations) (download)
Sun Jun 14 05:54:39 2020 UTC (4 years, 5 months ago) by jpp
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +20 -55 lines
global update of current bins

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

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