/[smeserver]/builds_bin/functions
ViewVC logotype

Diff of /builds_bin/functions

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

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


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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