]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find-lang
external find-lang.sh source
[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 # 2001-01-08 Micha³ Kochanowicz <mkochano@pld.org.pl>
16 #   * --all-name support for KDE.
17 # 2000-11-28 Rafa³ Cygnarowski <pascalek@pld.org.pl>
18 #   * next simple rule for KDE
19 # 2000-11-12 Rafa³ Cygnarowski <pascalek@pld.org.pl>
20 #   * simple rules for KDE help files
21 # 2000-06-05 Micha³ Kochanowicz <mkochano@pld.org.pl>
22 #   * exact, not substring matching $NAME, i.e. find-lang top_dir NAME will
23 #     no longer find /usr/share/locale/pl/LC_MESSAGES/<anything>NAME.mo.
24 # 2000-04-17 Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
25 #   * exit 1 when no files found
26 # 1999-10-19 Artur Frysiak <wiget@pld.org.pl>
27 #   * added support for GNOME help files
28 #   * start support for KDE help files
29
30 usage () {
31 cat <<EOF
32
33 Usage: $0 TOP_DIR PACKAGE_NAME [prefix]
34
35 where TOP_DIR is
36 the top of the tree containing the files to be processed--should be
37 \$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list.
38 PACKAGE_NAME is the %{name} of the package. This should also be
39 the basename of the .mo files.  the output is written to
40 PACKAGE_NAME.lang unless \$3 is given in which case output is written
41 to \$3.
42 Additional options:
43   --with-gnome          find GNOME help files
44   --with-kde            find KDE help files (not implemented yet)
45   --without-mo          not find locales files
46 EOF
47 exit 1
48 }
49
50 if [ -z "$1" ] ; then usage
51 elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2
52 elif [ ! -d $1 ] ; then
53  echo $0: $1: no such directory
54  exit 1
55 else TOP_DIR="`echo $1|sed -e 's:/$::'`"
56 fi
57 shift
58
59 if [ -z "$1" ] ; then usage
60 else NAME=$1
61 fi
62 shift
63
64 GNOME=#
65 KDE=#
66 MO=
67 MO_NAME=$NAME.lang
68 ALL_NAME=#
69 NO_ALL_NAME=
70 while test $# -gt 0 ; do
71     case "${1}" in
72         --with-gnome )
73                 GNOME=
74                 shift
75                 ;;
76         --with-kde )
77                 KDE=
78                 shift
79                 ;;
80         --without-mo )
81                 MO=#
82                 shift
83                 ;;
84         --all-name )
85                 ALL_NAME=
86                 NO_ALL_NAME=#
87                 shift
88                 ;;
89         * )
90                 MO_NAME=${1}
91                 shift
92                 ;;
93     esac
94 done    
95
96 find $TOP_DIR -type f|sed '
97 1i\
98 %defattr (644, root, root, 755)
99 s:'"$TOP_DIR"'::
100 '"$ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*\.mo$\):%lang(\2) \1\2\3:
101 '"$NO_ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/]\+\)\(.*/'"$NAME"'\.mo$\):%lang(\2) \1\2\3:
102 s:^\([^%].*\)::
103 s:%lang(C) ::
104 s:^\$::' > $MO_NAME
105
106 find $TOP_DIR -type d|sed '
107 s:'"$TOP_DIR"'::
108 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1:
109 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'/[a-zA-Z0-9\_\-]/.\+\)::
110 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'\/\)\([^/]\+\):%lang(\2) \1\2:
111 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9\_\-]\+$\):%dir \1:
112 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9\_\-]\+/[a-zA-Z0-9\_\-]/.\+\)::
113 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9\_\-]\+\/\)\([^/]\+\):%lang(\2) \1\2:
114 s:%lang(.*) .*/gnome/help/[a-zA-Z0-9\_\-]\+/[a-zA-Z0-9\_\-]\+/.*::
115 '#'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1:
116 '#'s:\(.*/gnome/help/'"$NAME"'/\)\([^/]\+\):%dir %lang(\2) \1\2:
117 s:^\([^%].*\)::
118 s:%lang(C) ::' >> $MO_NAME
119
120 find $TOP_DIR -type d|sed '
121 s:'"$TOP_DIR"'::
122 '"$NO_ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'/\)::
123 '"$NO_ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'\):%lang(\2) \1\2\3:
124 '"$ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9\_\-]\+/\)::
125 '"$ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9\_\-]\+$\):%lang(\2) \1\2\3:
126 s:^\([^%].*\)::
127 s:%lang(C) ::' >> $MO_NAME
128
129 if [ "$(cat $MO_NAME | grep -v defattr | wc -w)" -le 0  ]; then
130         echo "Error: international files not found !"
131         exit 1
132 fi
133
This page took 0.040638 seconds and 4 git commands to generate.