summaryrefslogtreecommitdiff
path: root/minstall.in
blob: a5b40dabf67a34de68b29f869c822a18f058e7e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
# $XTermId: minstall.in,v 1.6 2012/06/05 00:37:13 tom Exp $
# -----------------------------------------------------------------------------
# this file is part of xterm
#
# Copyright 2001-2011,2012 by Thomas E. Dickey
#
#                         All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
# -----------------------------------------------------------------------------
#
# Install manpages, substituting a reasonable section value since XFree86 4.x
# and derived imakes do not use constants...
#
# Parameters:
#	$1 = program to invoke as "install"
#	$2 = manpage to install
#	$3 = final installed-path
#	$4 = app-defaults directory
#	$5 = app-defaults class
#
# Other values correspond to definitions in xtermcfg.h, and cannot be directly
# modified using "make".  They are substituted directly into this script.
#

# override locale...
LANG=C;		export LANG
LANGUAGE=C;	export LANGUAGE
LC_ALL=C;	export LC_ALL
LC_CTYPE=C;	export LC_CTYPE
XTERM_LOCALE=C	export XTERM_LOCALE

# avoid interference by the "man" command.
for p in /bin /usr/bin
do
if test -f $p/cat ; then
MANPAGER=cat;   export MANPAGER
PAGER=cat;      export PAGER
break
fi
done

# get parameters
MINSTALL="$1"
OLD_FILE="$2"
END_FILE="$3"
APPS_DIR="$4"
APP_TYPE="$5"

suffix=`echo "$END_FILE" | sed -e 's%^.*\.%%'`
NEW_FILE=temp$$

MY_MANSECT=$suffix

# utmp and wtmp have different pathnames on different systems, but there
# are only a few common choices.  Note that they may not necessarily appear
# in the same directories.  Prefer utmpx/wtmpx to utmp/wtmp, since that's
# the way the configure script is designed.
UTMP_NAME=utmp
UTMP_PATH=/etc
for name in /etc /var/adm /var/run /var/log
do
	if test -f $name/utmpx ; then
		UTMP_NAME=utmpx
		UTMP_PATH=$name
		break
	elif test -f $name/utmp ; then
		UTMP_PATH=$name
		break
	fi
done
UTMP_PATH=$UTMP_PATH/$UTMP_NAME

WTMP_NAME=wtmp
WTMP_PATH=/etc
for name in /etc /var/adm /var/run /var/log
do
	if test -f $name/wtmpx ; then
		WTMP_NAME=wtmpx
		WTMP_PATH=$name
		break
	elif test -f $name/wtmp ; then
		WTMP_PATH=$name
		break
	fi
done
WTMP_PATH=$WTMP_PATH/$WTMP_NAME

# "X" is usually in the miscellaneous section, along with "undocumented".
# Use that to guess an appropriate section.
X_MANSECT=`man X 2>&1 | tr '\012' '\020' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
test -z "$X_MANSECT" && X_MANSECT=$suffix

sed	-e 's%__vendorversion__%"X Window System"%' \
	-e s%__default_termname__%@default_TERM@% \
	-e s%__default_termid__%@default_termid@% \
	-e s%__alt_sends_esc__%@alt_sends_esc@% \
	-e s%__meta_sends_esc__%@meta_sends_esc@% \
	-e s%__backarrow_key_is_del__%@backarrow_is_del@% \
	-e s%__backarrow_key_erase__%@backarrow_is_erase@% \
	-e s%__delete_is_del__%@delete_is_del@% \
	-e s%__default_class__%$APP_TYPE% \
	-e s%__apploaddir__%$APPS_DIR% \
	-e s%__mansuffix__%$MY_MANSECT%g \
	-e s%__miscmansuffix__%$X_MANSECT%g \
	-e s%fIutmp'\\%fI'$UTMP_NAME'\\%g' \
	-e s%/etc/utmp%$UTMP_PATH%g \
	-e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \
	-e s%/etc/wtmp%$WTMP_PATH%g \
	$OLD_FILE >$NEW_FILE

echo "$MINSTALL $OLD_FILE $END_FILE"
eval "$MINSTALL $NEW_FILE $END_FILE"

rm -f $NEW_FILE