/[gentoo-alt]/trunk/prefix/eclass/games.eclass
Gentoo

Contents of /trunk/prefix/eclass/games.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 7434 byte(s)
Initial eclass import from gentoo-x86
1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/games.eclass,v 1.109 2005/12/07 23:11:45 vapier Exp $
4 #
5 # devlist: {vapier,wolf31o2,mr_bones_}@gentoo.org -> games@gentoo.org
6 #
7 # This is the games eclass for standardizing the install of games ...
8 # you better have a *good* reason why you're *not* using games.eclass
9 # in a games ebuild
10
11 inherit eutils gnuconfig
12
13
14 EXPORT_FUNCTIONS pkg_preinst pkg_postinst src_compile pkg_setup
15
16 DESCRIPTION="Based on the ${ECLASS} eclass"
17
18 export GAMES_PREFIX=${GAMES_PREFIX:-/usr/games}
19 export GAMES_PREFIX_OPT=${GAMES_PREFIX_OPT:-/opt}
20 export GAMES_DATADIR=${GAMES_DATADIR:-/usr/share/games}
21 export GAMES_DATADIR_BASE=${GAMES_DATADIR_BASE:-/usr/share} # some packages auto append 'games'
22 export GAMES_SYSCONFDIR=${GAMES_SYSCONFDIR:-/etc/games}
23 export GAMES_STATEDIR=${GAMES_STATEDIR:-/var/games}
24 export GAMES_LOGDIR=${GAMES_LOGDIR:-/var/log/games}
25 export GAMES_LIBDIR=${GAMES_LIBDIR:-/usr/games/lib}
26 export GAMES_BINDIR=${GAMES_BINDIR:-/usr/games/bin}
27 export GAMES_ENVD="90games"
28 # if you want to use a different user/group than games.games,
29 # just add these two variables to your environment (aka /etc/profile)
30 export GAMES_USER=${GAMES_USER:-root}
31 export GAMES_USER_DED=${GAMES_USER_DED:-games}
32 export GAMES_GROUP=${GAMES_GROUP:-games}
33
34 egamesconf() {
35 local myconf
36 if [[ -x ./configure ]] ; then
37 gnuconfig_update
38 [[ -n ${CTARGET} ]] && myconf="${myconf} --target=${CTARGET}"
39 echo \
40 ./configure \
41 --prefix="${GAMES_PREFIX}" \
42 --build=${CBUILD:-${CHOST}} \
43 --host=${CHOST} \
44 --mandir=/usr/share/man \
45 --infodir=/usr/share/info \
46 --datadir="${GAMES_DATADIR}" \
47 --sysconfdir="${GAMES_SYSCONFDIR}" \
48 --localstatedir="${GAMES_STATEDIR}" \
49 ${myconf} \
50 "$@" \
51 ${EXTRA_ECONF}
52 ./configure \
53 --prefix="${GAMES_PREFIX}" \
54 --build=${CBUILD:-${CHOST}} \
55 --host=${CHOST} \
56 --mandir=/usr/share/man \
57 --infodir=/usr/share/info \
58 --datadir="${GAMES_DATADIR}" \
59 --sysconfdir="${GAMES_SYSCONFDIR}" \
60 --localstatedir="${GAMES_STATEDIR}" \
61 ${myconf} \
62 "$@" \
63 ${EXTRA_ECONF} \
64 || die "egamesconf failed"
65 else
66 die "no configure script found"
67 fi
68 }
69
70 egamesinstall() {
71 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
72 make \
73 prefix="${D}${GAMES_PREFIX}" \
74 mandir="${D}/usr/share/man" \
75 infodir="${D}/usr/share/info" \
76 datadir="${D}${GAMES_DATADIR}" \
77 sysconfdir="${D}${GAMES_SYSCONFDIR}" \
78 localstatedir="${D}${GAMES_STATEDIR}" \
79 "$@" install || die "einstall failed"
80 else
81 die "no Makefile found"
82 fi
83 }
84
85 gameswrapper() {
86 local oldtree=${DESTTREE}
87 into "${GAMES_PREFIX}"
88 local cmd=$1; shift
89 ${cmd} "$@"
90 local ret=$?
91 into "${oldtree}"
92 return ${ret}
93 }
94
95 dogamesbin() { gameswrapper ${FUNCNAME/games} "$@"; }
96 dogamessbin() { gameswrapper ${FUNCNAME/games} "$@"; }
97 dogameslib() { gameswrapper ${FUNCNAME/games} "$@"; }
98 dogameslib.a() { gameswrapper ${FUNCNAME/games} "$@"; }
99 dogameslib.so() { gameswrapper ${FUNCNAME/games} "$@"; }
100 newgamesbin() { gameswrapper ${FUNCNAME/games} "$@"; }
101 newgamessbin() { gameswrapper ${FUNCNAME/games} "$@"; }
102
103 games_make_wrapper() { gameswrapper ${FUNCNAME/games_} "$@"; }
104
105 gamesowners() { chown ${GAMES_USER}:${GAMES_GROUP} "$@"; }
106 gamesperms() { chmod u+rw,g+r-w,o-rwx "$@"; }
107 prepgamesdirs() {
108 local dir f
109 for dir in \
110 "${GAMES_PREFIX}" "${GAMES_PREFIX_OPT}" "${GAMES_DATADIR}" \
111 "${GAMES_SYSCONFDIR}" "${GAMES_STATEDIR}" "${GAMES_LIBDIR}" \
112 "${GAMES_BINDIR}" "$@"
113 do
114 [[ ! -d ${D}/${dir} ]] && continue
115 (
116 gamesowners -R "${D}/${dir}"
117 find "${D}/${dir}" -type d -print0 | xargs --null chmod 750
118 find "${D}/${dir}" -type f -print0 | xargs --null chmod o-rwx,g+r
119 ) &>/dev/null
120 f=$(find "${D}/${dir}" -perm +4000 -a -uid 0 2>/dev/null)
121 if [[ -n ${f} ]] ; then
122 eerror "A game was detected that is setuid root!"
123 eerror "${f}"
124 die "refusing to merge a setuid root game"
125 fi
126 done
127 [[ -d ${D}/${GAMES_BINDIR} ]] || return 0
128 find "${D}/${GAMES_BINDIR}" -maxdepth 1 -type f -exec chmod 750 '{}' \;
129 }
130
131 gamesenv() {
132 cat << EOF > "${ROOT}"/etc/env.d/${GAMES_ENVD}
133 LDPATH="${GAMES_LIBDIR}"
134 PATH="${GAMES_BINDIR}"
135 EOF
136 }
137
138 games_pkg_setup() {
139 [[ ${GAMES_CHECK_LICENSE} == "yes" ]] && check_license ${LICENSE}
140
141 enewgroup "${GAMES_GROUP}" 35
142 [[ ${GAMES_USER} != "root" ]] \
143 && enewuser "${GAMES_USER}" 35 -1 /usr/games "${GAMES_GROUP}"
144 [[ ${GAMES_USER_DED} != "root" ]] \
145 && enewuser "${GAMES_USER_DED}" 36 /bin/bash /usr/games "${GAMES_GROUP}"
146
147 # Make sure SDL was built in a certain way
148 if [[ -n ${GAMES_USE_SDL} ]] ; then
149 if built_with_use -o media-libs/libsdl ${GAMES_USE_SDL} ; then
150 eerror "You built libsdl with wrong USE flags."
151 eerror "Make sure you rebuild it like this:"
152 eerror "USE='-${GAMES_USE_SDL// / -}'"
153 die "your libsdl sucks"
154 fi
155 fi
156
157 # Dear portage team, we are so sorry. Lots of love, games team.
158 # See Bug #61680
159 [[ ${USERLAND} != "GNU" ]] && return 0
160 [[ $(getent passwd "${GAMES_USER_DED}" | cut -f7 -d:) == "/bin/false" ]] \
161 && usermod -s /bin/bash "${GAMES_USER_DED}"
162 }
163
164 games_src_compile() {
165 [[ -x ./configure ]] && { egamesconf || die "egamesconf failed"; }
166 [ -e [Mm]akefile ] && { emake || die "emake failed"; }
167 }
168
169 games_pkg_preinst() {
170 local f
171
172 for f in $(find "${D}/${GAMES_STATEDIR}" -type f -printf '%P ' 2>/dev/null) ; do
173 if [[ -e ${ROOT}/${GAMES_STATEDIR}/${f} ]] ; then
174 cp -p \
175 "${ROOT}/${GAMES_STATEDIR}/${f}" \
176 "${D}/${GAMES_STATEDIR}/${f}" \
177 || die "cp failed"
178 # make the date match the rest of the install
179 touch "${D}/${GAMES_STATEDIR}/${f}"
180 fi
181 done
182 }
183
184 # pkg_postinst function ... create env.d entry and warn about games group
185 games_pkg_postinst() {
186 gamesenv
187 ewarn "Remember, in order to play games, you have to"
188 ewarn "be in the '${GAMES_GROUP}' group."
189 echo
190 case ${USERLAND} in
191 GNU) einfo "Just run 'gpasswd -a <USER> ${GAMES_GROUP}'";;
192 DARWIN) einfo "Just run 'niutil -appendprop / /groups/games users <USER>'";;
193 esac
194 echo
195 einfo "For more info about Gentoo gaming in general, see our website:"
196 einfo " http://games.gentoo.org/"
197 echo
198 }
199
200 # Unpack .uz(2) files for UT/UT2003/UT2004
201 # $1: directory or file to unpack
202 games_ut_unpack() {
203 local ut_unpack="$1"
204 local f=
205
206 if [[ -z ${ut_unpack} ]] ; then
207 die "You must provide an argument to games_ut_unpack"
208 fi
209 if [[ -f ${ut_unpack} ]] ; then
210 uz2unpack "${ut_unpack}" "${ut_unpack/.uz2/}" &>/dev/null \
211 || die "uncompressing file ${ut_unpack}"
212 fi
213 if [[ -d ${ut_unpack} ]] ; then
214 for f in $(find "${ut_unpack}" -name '*.uz*' -printf '%f ') ; do
215 uz2unpack "${ut_unpack}/${f}" "${ut_unpack}/${f/.uz2}" &>/dev/null \
216 || die "uncompressing file ${f}"
217 rm -f "${ut_unpack}/${f}" || die "deleting compressed file ${f}"
218 done
219 fi
220 }
221
222 # Unpacks .umod/.ut2mod/.ut4mod files for UT/UT2003/UT2004
223 # Usage: games_umod_unpack $1
224 games_umod_unpack() {
225 local umod=$1
226 mkdir -p "${Ddir}/System"
227 cp "${dir}"/System/{ucc-bin,{Manifest,Def{ault,User}}.ini,{Engine,Core,zlib,ogg,vorbis}.so,{Engine,Core}.int} ${Ddir}/System
228 export UT_DATA_PATH="${Ddir}/System"
229 cd "${UT_DATA_PATH}"
230 ./ucc-bin umodunpack -x "${S}/${umod}" -nohomedir &> /dev/null \
231 || die "uncompressing file ${umod}"
232 rm -f "${Ddir}"/System/{ucc-bin,{Manifest,Def{ault,User},User,UT200{3,4}}.ini,{Engine,Core,zlib,ogg,vorbis}.so,{Engine,Core}.int,ucc.log} &>/dev/null \
233 || die "Removing temporary files"
234 }

  ViewVC Help
Powered by ViewVC 1.1.20