]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find-lang
- fixed (finally?) GConf scripts, rel 0.6
[packages/rpm.git] / rpm-find-lang
1 #!/bin/sh
2 #findlang - automagically generate list of language specific files
3 #for inclusion in an rpm spec file.
4 #This does assume that the *.mo files are under .../share/locale/...
5 #Run with no arguments gets a usage message.
6
7 #findlang is copyright (c) 1998 by W. L. Estes <wlestes@uncg.edu>
8
9 #Redistribution and use of this software are hereby permitted for any
10 #purpose as long as this notice and the above copyright notice remain
11 #in tact and are included with any redistribution of this file or any
12 #work based on this file.
13
14 #changes:
15 # $Id$
16 # 2001-01-08 Micha³ Kochanowicz <mkochano@pld.org.pl>
17 #   * --all-name support for KDE.
18 # 2000-11-28 Rafa³ Cygnarowski <pascalek@pld.org.pl>
19 #   * next simple rule for KDE
20 # 2000-11-12 Rafa³ Cygnarowski <pascalek@pld.org.pl>
21 #   * simple rules for KDE help files
22 # 2000-06-05 Micha³ Kochanowicz <mkochano@pld.org.pl>
23 #   * exact, not substring matching $NAME, i.e. find-lang top_dir NAME will
24 #     no longer find /usr/share/locale/pl/LC_MESSAGES/<anything>NAME.mo.
25 # 2000-04-17 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
26 #   * exit 1 when no files found
27 # 1999-10-19 Artur Frysiak <wiget@pld.org.pl>
28 #   * added support for GNOME help files
29 #   * start support for KDE help files
30
31 usage () {
32 cat <<EOF
33
34 Usage: $0 TOP_DIR PACKAGE_NAME [prefix]
35
36 where TOP_DIR is
37 the top of the tree containing the files to be processed--should be
38 \$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list.
39 PACKAGE_NAME is the %{name} of the package. This should also be
40 the basename of the .mo files.  the output is written to
41 PACKAGE_NAME.lang unless \$3 is given in which case output is written
42 to \$3.
43 Additional options:
44   --with-gnome          find GNOME help files
45   --with-kde            find KDE help files
46   --all-name            match all package/domain names
47   --without-mo          skip *.mo locale files
48 EOF
49 exit 1
50 }
51
52 if [ -z "$1" ] ; then usage
53 elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2
54 elif [ ! -d $1 ] ; then
55  echo $0: $1: no such directory
56  exit 1
57 else TOP_DIR="`echo $1|sed -e 's:/$::'`"
58 fi
59 shift
60
61 if [ -z "$1" ] ; then usage
62 else NAME=$1
63 fi
64 shift
65
66 GNOME=#
67 KDE=#
68 MO=
69 MO_NAME=$NAME.lang
70 ALL_NAME=#
71 NO_ALL_NAME=
72 while test $# -gt 0 ; do
73     case "${1}" in
74         --with-gnome )
75                 GNOME=
76                 shift
77                 ;;
78         --with-kde )
79                 KDE=
80                 shift
81                 ;;
82         --without-mo )
83                 MO=#
84                 shift
85                 ;;
86         --all-name )
87                 ALL_NAME=
88                 NO_ALL_NAME=#
89                 shift
90                 ;;
91         * )
92                 MO_NAME=${1}
93                 shift
94                 ;;
95     esac
96 done    
97
98 echo '%defattr(644,root,root,755)' > $MO_NAME
99
100 find $TOP_DIR -type f -name \*.mo | xargs -r file | egrep -v ', 1 messages$' |\
101 sed '
102 s/:.*//
103 s:'"$TOP_DIR"'::
104 '"$ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*\.mo$\):%lang(\2) \1\2\3:
105 '"$NO_ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/]\+\)\(.*/'"$NAME"'\.mo$\):%lang(\2) \1\2\3:
106 s:^\([^%].*\)::
107 s:%lang(C) ::
108 s:^\$::' | egrep -v '^$' >> $MO_NAME
109
110 find $TOP_DIR -type d|sed '
111 s:'"$TOP_DIR"'::
112 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1:
113 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'/[a-zA-Z0-9.\_\-]/.\+\)::
114 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'\/\)\([^/]\+\):%lang(\2) \1\2:
115 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+$\):%dir \1:
116 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]/.\+\)::
117 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+\/\)\([^/]\+\):%lang(\2) \1\2:
118 s:%lang(.*) .*/gnome/help/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]\+/.*::
119 s:^\([^%].*\)::
120 s:%lang(C) ::' | egrep -v '^$' >> $MO_NAME
121
122 find $TOP_DIR -type d|sed '
123 s:'"$TOP_DIR"'::
124 '"$NO_ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'/\)::
125 '"$NO_ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'\)$:%lang(\2) \1\2\3:
126 '"$ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+/\)::
127 '"$ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+$\):%lang(\2) \1\2\3:
128 s:^\([^%].*\)::
129 s:%lang(C) ::' | egrep -v '^$' >> $MO_NAME
130
131 if [ "$(cat $MO_NAME | egrep -v '(^%defattr|^$)' | wc -l)" -le 0  ]; then
132         echo 'Error: international files not found !'
133         exit 1
134 fi
135
This page took 0.02981 seconds and 3 git commands to generate.