initial commit
[profile/ivi/xterm.git] / minstall.sh
1 #!/bin/sh
2 # $XTermId: minstall.sh,v 1.20 2010/03/03 23:44:49 tom Exp $
3 # -----------------------------------------------------------------------------
4 # this file is part of xterm
5 #
6 # Copyright 2001-2009,2010 by Thomas E. Dickey
7 #
8 #                         All Rights Reserved
9 #
10 # Permission is hereby granted, free of charge, to any person obtaining a
11 # copy of this software and associated documentation files (the
12 # "Software"), to deal in the Software without restriction, including
13 # without limitation the rights to use, copy, modify, merge, publish,
14 # distribute, sublicense, and/or sell copies of the Software, and to
15 # permit persons to whom the Software is furnished to do so, subject to
16 # the following conditions:
17 #
18 # The above copyright notice and this permission notice shall be included
19 # in all copies or substantial portions of the Software.
20 #
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
25 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #
29 # Except as contained in this notice, the name(s) of the above copyright
30 # holders shall not be used in advertising or otherwise to promote the
31 # sale, use or other dealings in this Software without prior written
32 # authorization.
33 # -----------------------------------------------------------------------------
34 #
35 # Install manpages, substituting a reasonable section value since XFree86 4.x
36 # and derived imakes do not use constants...
37 #
38 # Parameters:
39 #       $1 = program to invoke as "install"
40 #       $2 = manpage to install
41 #       $3 = final installed-path
42 #       $4 = app-defaults directory
43 #
44
45 # override locale...
46 LANG=C;         export LANG
47 LANGUAGE=C;     export LANGUAGE
48 LC_ALL=C;       export LC_ALL
49 LC_CTYPE=C;     export LC_CTYPE
50 XTERM_LOCALE=C  export XTERM_LOCALE
51
52 # avoid interference by the "man" command.
53 for p in /bin /usr/bin
54 do
55 if test -f $p/cat ; then
56 MANPAGER=cat;   export MANPAGER
57 PAGER=cat;      export PAGER
58 break
59 fi
60 done
61
62 # get parameters
63 MINSTALL="$1"
64 OLD_FILE="$2"
65 END_FILE="$3"
66 APPS_DIR="$4"
67
68 suffix=`echo "$END_FILE" | sed -e 's%^.*\.%%'`
69 NEW_FILE=temp$$
70
71 MY_MANSECT=$suffix
72
73 # utmp and wtmp have different pathnames on different systems, but there
74 # are only a few common choices.  Note that they may not necessarily appear
75 # in the same directories.  Prefer utmpx/wtmpx to utmp/wtmp, since that's
76 # the way the configure script is designed.
77 UTMP_NAME=utmp
78 UTMP_PATH=/etc
79 for name in /etc /var/adm /var/run /var/log
80 do
81         if test -f $name/utmpx ; then
82                 UTMP_NAME=utmpx
83                 UTMP_PATH=$name
84                 break
85         elif test -f $name/utmp ; then
86                 UTMP_PATH=$name
87                 break
88         fi
89 done
90 UTMP_PATH=$UTMP_PATH/$UTMP_NAME
91
92 WTMP_NAME=wtmp
93 WTMP_PATH=/etc
94 for name in /etc /var/adm /var/run /var/log
95 do
96         if test -f $name/wtmpx ; then
97                 WTMP_NAME=wtmpx
98                 WTMP_PATH=$name
99                 break
100         elif test -f $name/wtmp ; then
101                 WTMP_PATH=$name
102                 break
103         fi
104 done
105 WTMP_PATH=$WTMP_PATH/$WTMP_NAME
106
107 # "X" is usually in the miscellaneous section, along with "undocumented".
108 # Use that to guess an appropriate section.
109 X_MANSECT=`man X 2>&1 | tr '\012' '\020' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
110 test -z "$X_MANSECT" && X_MANSECT=$suffix
111
112 sed     -e 's%__vendorversion__%"X Window System"%' \
113         -e s%__apploaddir__%$APPS_DIR% \
114         -e s%__mansuffix__%$MY_MANSECT%g \
115         -e s%__miscmansuffix__%$X_MANSECT%g \
116         -e s%fIutmp'\\%fI'$UTMP_NAME'\\%g' \
117         -e s%/etc/utmp%$UTMP_PATH%g \
118         -e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \
119         -e s%/etc/wtmp%$WTMP_PATH%g \
120         $OLD_FILE >$NEW_FILE
121
122 echo "$MINSTALL $OLD_FILE $END_FILE"
123 eval "$MINSTALL $NEW_FILE $END_FILE"
124
125 rm -f $NEW_FILE