summaryrefslogtreecommitdiff
path: root/emulators/compat_netbsd/INSTALL.emulaout
blob: 3cde42f75b5b4983a3ddbb3212f89cbda6a12c57 (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
# $NetBSD: INSTALL.emulaout,v 1.1 2007/08/21 22:49:25 jlam Exp $

# Generate a +ROOT_ACTIONS script that runs certain actions that require
# superuser privileges.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+ROOT_ACTIONS)
	${CAT} > ./+ROOT_ACTIONS << 'EOF'
#!@SH@
#
# +ROOT_ACTIONS - run actions requiring superuser privileges
#
# Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir]
#
# This script runs certain actions that require superuser privileges.
# If such privileges are not available, then simply output a message
# asking the user to run this script with the appropriate elevated
# privileges.
#

CAT="@CAT@"
CHMOD="@CHMOD@"
CP="@CP@"
DIRNAME="@DIRNAME@"
ECHO="@ECHO@"
ID="@ID@"
LN="@LN@"
MKDIR="@MKDIR@"
PWD_CMD="@PWD_CMD@"
RM="@RM@"
SH="@SH@"
TEST="@TEST@"

SELF=$0
ACTION=$1

CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${2-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_PREFIX=@PREFIX@}

EMULDIR="${PKG_PREFIX}/@EMULSUBDIR@"
OPSYS_EMULDIR="@OPSYS_EMULDIR@"

ROOT_ACTIONS_COOKIE="./+ROOT_ACTIONS_done"
EUID=`${ID} -u`

exitcode=0
case $ACTION,$EUID in
ADD,0)
	${ECHO} "" > ${ROOT_ACTIONS_COOKIE}
	${CHMOD} g+w ${ROOT_ACTIONS_COOKIE}

	# Create the appropriate symlink so that the kernel will
	# find the installed files.
	#
	OPSYS_EMULDIR_PWD=`cd ${OPSYS_EMULDIR} 2>/dev/null && ${PWD_CMD}`
	EMULDIR_PWD=`cd ${EMULDIR} 2>/dev/null && ${PWD_CMD}`

	if ${TEST} "${OPSYS_EMULDIR_PWD}" != "${EMULDIR_PWD}"; then
		if ${TEST} -e ${OPSYS_EMULDIR} -o -L ${OPSYS_EMULDIR}; then
			${CAT} << EOM
==============================================================================
The following symbolic link must be created for ${PKGNAME}
to work properly:

	${EMULDIR} -> ${OPSYS_EMULDIR}

==============================================================================
EOM
		else
			${ECHO} "${PKGNAME}: creating symlink ${EMULDIR} -> ${OPSYS_EMULDIR}"
			( ${MKDIR} -p `${DIRNAME} ${OPSYS_EMULDIR}` && 
			  ${LN} -fs ${EMULDIR} ${OPSYS_EMULDIR} ) || ${TRUE}
		fi
	fi
	if ${TEST} -d ${OPSYS_EMULDIR}; then
		${ECHO} "${PKGNAME}: creating a.out runtime link editor directory cache."
		@LDCONFIG_ADD_CMD@
	fi
	;;

REMOVE,0)
	if ${TEST} -d ${OPSYS_EMULDIR}; then
		${ECHO} "${PKGNAME}: creating a.out runtime link editor directory cache."
		@LDCONFIG_REMOVE_CMD@
	fi
	${RM} -f ${ROOT_ACTIONS_COOKIE}
	;;

ADD,*)
	if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then
		${CAT} << EOM
==============================================================================
Please run the following command with superuser privileges to complete
the installation of ${PKGNAME}:

    cd ${PKG_METADATA_DIR} && ${SELF} ADD

==============================================================================
EOM
	fi
	;;

REMOVE,*)
	if ${TEST} -d ${OPSYS_EMULDIR}; then
		${CAT} << EOM
==============================================================================
Please run the following command with superuser privileges to rebuild
the a.out runtime link editor directory cache after the removal of
${PKGNAME}:

    @LDCONFIG_REMOVE_CMD@

==============================================================================
EOM
	fi
	${RM} -f ${ROOT_ACTIONS_COOKIE}
	;;
esac
exit $exitcode

EOF
	${CHMOD} +x ./+ROOT_ACTIONS
	;;
esac

case "${STAGE}" in
POST-INSTALL)
	# Run any actions that require root privileges.
	${TEST} ! -x ./+ROOT_ACTIONS ||
		./+ROOT_ACTIONS ADD ${PKG_METADATA_DIR}
	;;
esac