/[smeserver]/builds_bin/functions
ViewVC logotype

Contents of /builds_bin/functions

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


Revision 1.9 - (show annotations) (download)
Sun Apr 28 18:53:34 2024 UTC (6 months, 4 weeks ago) by jpp
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +25 -31 lines
20240428

1 #!/usr/bash
2
3 diffmv() {
4 if [ ! -z "$1" -a ! -z "$2" ]
5 then
6 if [ -f "$2" ]
7 then
8 if [ "${1%%.tm}" == "$1" ]
9 then
10 if diff -u "$2" "$1"
11 then
12 /bin/rm -f "$1"
13 else
14 /bin/mv -f "$1" "$2"
15 fi
16 else
17 if diff -q "$2" "$1" > /dev/null
18 then
19 /bin/rm -f "$1"
20 else
21 /bin/mv -f "$1" "$2"
22 fi
23 fi
24 else
25 /bin/mv -f "$1" "$2"
26 fi
27 fi
28 }
29
30 diffcp() {
31 if [ ! -z "$1" -a ! -z "$2" ]
32 then
33 if [ -f "$2" ]
34 then
35 if [ "${1%%.tm}" == "$1" ]
36 then
37 if ! diff -u "$2" "$1"
38 then
39 /bin/cp -a "$1" "$2"
40 fi
41 else
42 if ! diff -q "$2" "$1" > /dev/null
43 then
44 /bin/cp -a "$1" "$2"
45 fi
46 fi
47 else
48 /bin/cp -a "$1" "$2"
49 fi
50 fi
51 }
52
53 potempl() {
54 xgettext --from-code UTF-8 -L perl -o - $@ \
55 | sed 's@charset=CHARSET@charset=UTF-8@;s@[^ ]\+/\([^/]\+\)/[^/]\+/root/@\1/root/@g;s@Id-Version.*\\n@Id-Version: SME Template\\n@' \
56 | sed '/Report-Msgid-Bugs-To/d;/POT-Creation-Date/d;/PO-Revision-Date/d;/Language-Team/d;/X-Generator/d;0,/^msgid/{/^#/d}' \
57 | msgcat -F -t UTF-8 -
58 }
59
60 xmltempl() {
61 mkdir -p /var/lib/pootle/templates/$1/
62
63 root=$(echo $2 | sed 's@.*/root/@root/@')
64 cat $2 \
65 | perl -pe 's@<@_{_@g;s@>@_}_@g;s@&@_AMP_@g;s@_{_(/?(?:lexicon|entry|base|trans).*?)_}_@<$1>@g' \
66 | sed '/<\\\?lexicon/p;0,/<lexicon/d;/<\\lexicon/,$d' \
67 > /var/lib/pootle/tmp/$(basename $2).orig
68
69 xml2po -m sme -e -o - /var/lib/pootle/tmp/$(basename $2).orig \
70 | sed "/(lexicon)/{N;N;N;d};s@[^ ]\+\(:[0-9]\+([^)]\+)\)@$1/$root\1@g" \
71 | tee >(cat - | sed '/^msgid/{p;s@msgid@msgstr@p;N;d}' \
72 | xml2po -m sme -p - /var/lib/pootle/tmp/$(basename $2).orig \
73 > /var/lib/pootle/tmp/$(basename $2) ) \
74 | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \
75 | msgcat -F -t UTF-8 - \
76 | sed "/^\"POT-Creation-Date:/d;s@Id-Version.*\\\n@Id-Version: SME Template\\\n@" \
77 > /var/lib/pootle/tmp/$(basename $2).pot
78 diffmv /var/lib/pootle/tmp/$(basename $2).orig /var/lib/pootle/templates/$1/$(basename $2).orig
79 diffmv /var/lib/pootle/tmp/$(basename $2) /var/lib/pootle/templates/$1/$(basename $2)
80 diffmv /var/lib/pootle/tmp/$(basename $2).pot /var/lib/pootle/templates/$1/$(basename $2).pot
81 }
82
83 anacondatmpl() {
84 xgettext -L python \
85 -k=_ \
86 -k=N_ \
87 -o - \
88 $(sed -n "/\.py/s@^\([^ \t]\+\)[ \t]\+\([^/]\+\)\(/.*\)\?@/var/lib/pootle/cvs/smeserver/\2/$1/\2-*\3/\1@p" \
89 /var/lib/pootle/cvs/smeserver/cdrom.image/$1/updates/README.txt) \
90 /var/lib/pootle/cvs/smeserver/cdrom.image/$1/updates/*.py \
91 /var/lib/pootle/cvs/smeserver/cdrom.image/$1/*/installclasses/*.py \
92 | sed 's@charset=CHARSET@charset=UTF-8@;s@Id-Version.*\\n@Id-Version: SME Template\\n@' \
93 | sed 's@/var/lib/pootle/cvs/smeserver/[^/]\+/@@' \
94 | msgcat -u \
95 --use-first \
96 - \
97 <(sed 's@CHARSET@UTF-8@' /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/anaconda.pot) \
98 <(sed 's@CHARSET@UTF-8@' /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/anaconda.pot) \
99 | sed '/Report-Msgid-Bugs-To/d;/POT-Creation-Date/d;/PO-Revision-Date/d;/Last-Translator/d;/Language-Team/d;/X-Generator/d;0,/^msgid/{/^#/d}' \
100 | msgcat -F -t UTF-8 -
101 }
102
103 xmltrans() {
104 if [ ! -f /var/lib/pootle/templates/$1/$(basename $2) ]
105 then
106 echo "Missing /var/lib/pootle/templates/$1/$(basename $2)"
107 elif [ ! -f /var/lib/pootle/templates/$1/$(basename $2).pot ]
108 then
109 echo "Missing /var/lib/pootle/templates/$1/$(basename $2).pot"
110 else
111 #| iconv -f ISO-8859-1 -t UTF-8 \
112 #lang=$(echo $2 | sed 's@.*/locale/\([^/]\+\)/.*@\1@')
113 cat $2 \
114 | perl -pe 's@<@_{_@g;s@>@_}_@g;s@&@_AMP_@g;s@_{_(/?(?:lexicon|entry|base|trans).*?)_}_@<$1>@g' \
115 | sed '/<\\\?lexicon/p;0,/<lexicon/d;/<\\lexicon/,$d' \
116 | xml2po -m sme -r - -o - /var/lib/pootle/templates/$1/$(basename $2) \
117 | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \
118 | sed "/(lexicon)/{N;N;N;d}" \
119 | msgcat -F -t UTF-8 - \
120 | msgmerge -q -F - /var/lib/pootle/templates/$1/$(basename $2).pot
121 fi
122 }
123
124 xmlgen() {
125 if [ ! -f /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@') ]
126 then
127 echo "Missing /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@')" 1>&2
128 else
129 #lang=$(basename $(dirname $2))
130 msgcat -F $2 \
131 | perl -pe 's@<@_{_@g;s@>@_}_@g;s@&@_AMP_@g' \
132 | sed '/#,/d' | sed '1,/X-Generator/{;s,_{_,<,g;s,_}_,>,g;s,_AMP_,\&,g;}' \
133 | sed '/#,/d' \
134 | xml2po -m sme -p - /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@') \
135 | sed '1d' \
136 | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \
137 | perl -pe 's@(lexicon\s+lang[^"]+"[^"]+)_([^"]+)"@"$1-".lc($2)."\""@e'
138 fi
139 }
140
141 anacondagen() {
142 if [ -f /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po ]
143 then
144 msgcat --use-first \
145 /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po \
146 /var/lib/pootle/po/$1/$2/anaconda.po \
147 | msgfmt -f -o - - 2> /dev/null
148 if [ $? -ne 0 ]
149 then
150 msgcat --use-first \
151 /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po \
152 /var/lib/pootle/po/$1/$2/anaconda.po \
153 | msgfmt -o - - 2> /dev/null
154 fi
155 fi
156 }
157
158 localedir() {
159 dir=$(echo $1 | perl -pe 's/_(.*)/-lc($1)/e')
160 if [ "$2" == "general" ]
161 then
162 echo "root/etc/e-smith/locale/$dir/FormMagick"
163 elif [ "$2" == "userpassword" ]
164 then
165 echo "root/etc/e-smith/locale/$dir/etc/e-smith/web/panels/password/cgi-bin"
166 else
167 echo "root/etc/e-smith/locale/$dir/etc/e-smith/web/functions"
168 fi
169 }
170

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