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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/games.eclass,v 1.59 2004/01/26 23:40:07 vapier Exp $
#
# devlist: {vapier,wolf31o2,msterret}@gentoo.org
#
# This is the games ebuild for standardizing the install of games ...
# you better have a *good* reason why you're *not* using games.eclass
# in an ebuild in app-games
inherit eutils
ECLASS=games
INHERITED="$INHERITED $ECLASS"
EXPORT_FUNCTIONS pkg_postinst src_compile pkg_setup
DESCRIPTION="Based on the ${ECLASS} eclass"
IUSE="dedicated"
export GAMES_PREFIX="/usr/games"
export GAMES_PREFIX_OPT="/opt"
export GAMES_DATADIR="/usr/share/games"
export GAMES_DATADIR_BASE="/usr/share" # some packages auto append 'games'
export GAMES_SYSCONFDIR="/etc/games"
export GAMES_STATEDIR="/var/games"
export GAMES_LOGDIR="/var/log/games"
export GAMES_LIBDIR="/usr/games/lib"
export GAMES_BINDIR="/usr/games/bin"
export GAMES_ENVD="90games"
# if you want to use a different user/group than games.games,
# just add these two variables to your environment (aka /etc/profile)
export GAMES_USER="${GAMES_USER:-games}"
export GAMES_USER_DED="${GAMES_USER_DED:-games-ded}"
export GAMES_GROUP="${GAMES_GROUP:-games}"
egamesconf() {
if [ -x ./configure ] ; then
./configure \
--prefix=${GAMES_PREFIX} \
--host=${CHOST} \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--datadir=${GAMES_DATADIR} \
--sysconfdir=${GAMES_SYSCONFDIR} \
--localstatedir=${GAMES_STATEDIR} \
"$@" || die "egamesconf failed"
else
die "no configure script found"
fi
}
egamesinstall() {
if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
make prefix=${D}${GAMES_PREFIX} \
mandir=${D}/usr/share/man \
infodir=${D}/usr/share/info \
datadir=${D}${GAMES_DATADIR} \
sysconfdir=${D}${GAMES_SYSCONFDIR} \
localstatedir=${D}${GAMES_STATEDIR} \
"$@" install || die "einstall failed"
else
die "no Makefile found"
fi
}
gameswrapper() {
local oldtree=${DESTTREE}
into ${GAMES_PREFIX}
local cmd=$1; shift
${cmd} "$@"
local ret=$?
into ${oldtree}
return ${ret}
}
dogamesbin() { gameswrapper ${FUNCNAME/games} "$@"; }
dogamessbin() { gameswrapper ${FUNCNAME/games} "$@"; }
dogameslib() { gameswrapper ${FUNCNAME/games} "$@"; }
dogameslib.a() { gameswrapper ${FUNCNAME/games} "$@"; }
dogameslib.so() { gameswrapper ${FUNCNAME/games} "$@"; }
newgamesbin() { gameswrapper ${FUNCNAME/games} "$@"; }
newgamessbin() { gameswrapper ${FUNCNAME/games} "$@"; }
gamesowners() { chown ${GAMES_USER}:${GAMES_GROUP} "$@"; }
gamesperms() { chmod u+rw,g+r-w,o-rwx "$@"; }
prepgamesdirs() {
local dir=""
for dir in ${GAMES_PREFIX} ${GAMES_PREFIX_OPT} ${GAMES_DATADIR} ${GAMES_SYSCONFDIR} \
${GAMES_STATEDIR} ${GAMES_LIBDIR} ${GAMES_BINDIR} "$@" ; do
(
gamesowners -R ${D}/${dir}
find ${D}/${dir} -type d -print0 | xargs --null chmod 750
find ${D}/${dir} -type f -print0 | xargs --null chmod o-rwx,g+r
) >& /dev/null
done
local f=""
for f in `find ${D}/${GAMES_STATEDIR} -type f -printf '%P ' 2>/dev/null` ; do
if [ -e "${ROOT}/${GAMES_STATEDIR}/${f}" ] ; then
cp -p "${ROOT}/${GAMES_STATEDIR}/${f}" "${D}/${GAMES_STATEDIR}/${f}"
touch "${D}/${GAMES_STATEDIR}/${f}"
fi
done
chmod 750 ${D}/${GAMES_BINDIR}/* >& /dev/null
}
gamesenv() {
cat << EOF > /etc/env.d/${GAMES_ENVD}
LDPATH="${GAMES_LIBDIR}"
PATH="${GAMES_BINDIR}"
EOF
}
games_pkg_setup() {
enewgroup ${GAMES_GROUP} 35
enewuser ${GAMES_USER} 35 /bin/false /usr/games ${GAMES_GROUP}
enewuser ${GAMES_USER_DED} 36 /bin/bash /usr/games ${GAMES_GROUP}
}
games_src_compile() {
[ -x ./configure ] && { egamesconf || die "egamesconf failed"; }
[ -e [Mm]akefile ] && { emake || die "emake failed"; }
}
# pkg_postinst function ... create env.d entry and warn about games group
games_pkg_postinst() {
gamesenv
ewarn "Remember, in order to play games, you have to"
ewarn "be in the '${GAMES_GROUP}' group."
echo
einfo "See the usermod(8) manpage for more information."
echo
}
# some games require cdrom's to install datafiles ...
# $1: directory or file to check for on cdrom
# after function call, cdrom should be in ${GAMES_CD}
games_get_cd() {
export GAMES_CD=${GAMES_CDROM}
if [ -z "${GAMES_CD}" ] ; then
local dir="$(dirname $1)"
local file="$(basename $1)"
local mline=""
for mline in `mount | egrep -e '(iso|cdrom)' | awk '{print $3}'` ; do
[ -d "${mline}/${dir}" ] || continue
find ${mline}/${dir} -iname ${file} -maxdepth 1 -printf '' && GAMES_CD=${mline}
done
fi
[ ! -z "${GAMES_CD}" ] && einfo "Using ${GAMES_CD} as the data source"
}
# Pass a description of the cd to the function
games_verify_cd() {
if [ -z "${GAMES_CD}" ] ; then
echo
eerror "You must mount the $* CD first!"
echo
ewarn "If you do not have the CD, but have the data files"
ewarn "mounted somewhere on your filesystem, just export"
ewarn "the variable GAMES_CDROM so that it points to the"
ewarn "directory containing the files."
echo
die "You must provide the $* data before running the install"
fi
}
# Unpack .uz(2) files for UT/UT2003
# $1: directory or file to unpack
games_ut_unpack() {
local ut_unpack="$1"
export UT_DATA_PATH="${Ddir}/System"
cd "${UT_DATA_PATH}"
LD_LIBRARY_PATH=.:${UT2003_DATA_PATH}:${LD_LIBRARY_PATH}
if [ -z "${ut_unpack}" ]; then
die "You must provide an argument to games_ut_unpack"
fi
if [ -f "${ut_unpack}" ]; then
./ucc-bin decompress ${ut_unpack} --nohomedir || die "uncompressing file ${ut_unpack}"
fi
if [ -d "${ut_unpack}" ]; then
for f in `find ${ut_unpack} -name '*.uz*' -printf '%f '` ; do
./ucc-bin decompress ${ut_unpack}/${f} --nohomedir || die "uncompressing file ${f}"
#mv System/${f:0:${#f}-3} ${ut_unpack} || die "moving file ${f}
rm ${ut_unpack}/${f} || die "deleting compressed file ${f}"
done
#for f in `find ${ut_unpack} -name '*.uz' -printf '%f '` ; do
# ./ucc-bin decompress ${ut_unpack}/${f} --nohomedir || die "uncompressing file ${f}"
# mv System/${f:0:${#f}-4} ${ut_unpack} || die "moving file ${f}"
# rm ${ut_unpack}/${f} || die "deleting compressed file ${f}"
#done
fi
}
# make a wrapper script ...
games_make_wrapper() {
local wrapper=$1 ; shift
local bin=$1 ; shift
local chdir=$1 ; shift
local tmpwrapper="`mymktemp ${T}`"
cat << EOF > ${tmpwrapper}
#!/bin/sh
cd "${chdir}"
exec ${bin} "\$@"
EOF
newgamesbin ${tmpwrapper} ${wrapper}
}
|