/[gentoo-x86]/eclass/games.eclass
Gentoo

Contents of /eclass/games.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.148 - (show annotations) (download)
Wed May 30 06:35:43 2012 UTC (2 years, 2 months ago) by slyfox
Branch: MAIN
Changes since 1.147: +3 -3 lines
Allow EAPI=4.

1 # Copyright 1999-2012 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.147 2011/12/27 17:55:12 fauli 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 if [[ ${___ECLASS_ONCE_GAMES} != "recur -_+^+_- spank" ]] ; then
12 ___ECLASS_ONCE_GAMES="recur -_+^+_- spank"
13
14 inherit base multilib toolchain-funcs eutils user
15
16 case ${EAPI:-0} in
17 0|1) EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst pkg_postinst ;;
18 2|3|4) EXPORT_FUNCTIONS pkg_setup src_configure src_compile pkg_preinst pkg_postinst ;;
19 *) die "no support for EAPI=${EAPI} yet" ;;
20 esac
21
22 DESCRIPTION="Based on the ${ECLASS} eclass"
23
24 export GAMES_PREFIX=${GAMES_PREFIX:-/usr/games}
25 export GAMES_PREFIX_OPT=${GAMES_PREFIX_OPT:-/opt}
26 export GAMES_DATADIR=${GAMES_DATADIR:-/usr/share/games}
27 export GAMES_DATADIR_BASE=${GAMES_DATADIR_BASE:-/usr/share} # some packages auto append 'games'
28 export GAMES_SYSCONFDIR=${GAMES_SYSCONFDIR:-/etc/games}
29 export GAMES_STATEDIR=${GAMES_STATEDIR:-/var/games}
30 export GAMES_LOGDIR=${GAMES_LOGDIR:-/var/log/games}
31 export GAMES_BINDIR=${GAMES_BINDIR:-${GAMES_PREFIX}/bin}
32 export GAMES_ENVD="90games"
33 # if you want to use a different user/group than games.games,
34 # just add these two variables to your environment (aka /etc/profile)
35 export GAMES_USER=${GAMES_USER:-root}
36 export GAMES_USER_DED=${GAMES_USER_DED:-games}
37 export GAMES_GROUP=${GAMES_GROUP:-games}
38
39 games_get_libdir() {
40 echo ${GAMES_PREFIX}/$(get_libdir)
41 }
42
43 egamesconf() {
44 econf \
45 --prefix="${GAMES_PREFIX}" \
46 --libdir="$(games_get_libdir)" \
47 --datadir="${GAMES_DATADIR}" \
48 --sysconfdir="${GAMES_SYSCONFDIR}" \
49 --localstatedir="${GAMES_STATEDIR}" \
50 "$@"
51 }
52
53 gameswrapper() {
54 # dont want to pollute calling env
55 (
56 into "${GAMES_PREFIX}"
57 cmd=$1
58 shift
59 ${cmd} "$@"
60 )
61 }
62
63 dogamesbin() { gameswrapper ${FUNCNAME/games} "$@"; }
64 dogamessbin() { gameswrapper ${FUNCNAME/games} "$@"; }
65 dogameslib() { gameswrapper ${FUNCNAME/games} "$@"; }
66 dogameslib.a() { gameswrapper ${FUNCNAME/games} "$@"; }
67 dogameslib.so() { gameswrapper ${FUNCNAME/games} "$@"; }
68 newgamesbin() { gameswrapper ${FUNCNAME/games} "$@"; }
69 newgamessbin() { gameswrapper ${FUNCNAME/games} "$@"; }
70
71 games_make_wrapper() { gameswrapper ${FUNCNAME/games_} "$@"; }
72
73 gamesowners() { chown ${GAMES_USER}:${GAMES_GROUP} "$@"; }
74 gamesperms() { chmod u+rw,g+r-w,o-rwx "$@"; }
75 prepgamesdirs() {
76 local dir f mode
77 for dir in \
78 "${GAMES_PREFIX}" "${GAMES_PREFIX_OPT}" "${GAMES_DATADIR}" \
79 "${GAMES_SYSCONFDIR}" "${GAMES_STATEDIR}" "$(games_get_libdir)" \
80 "${GAMES_BINDIR}" "$@"
81 do
82 [[ ! -d ${D}/${dir} ]] && continue
83 (
84 gamesowners -R "${D}/${dir}"
85 find "${D}/${dir}" -type d -print0 | xargs -0 chmod 750
86 mode=o-rwx,g+r,g-w
87 [[ ${dir} = ${GAMES_STATEDIR} ]] && mode=o-rwx,g+r
88 find "${D}/${dir}" -type f -print0 | xargs -0 chmod $mode
89
90 # common trees should not be games owned #264872
91 if [[ ${dir} == "${GAMES_PREFIX_OPT}" ]] ; then
92 fowners root:root "${dir}"
93 fperms 755 "${dir}"
94 for d in $(get_libdir) bin ; do
95 fowners root:root "${dir}/${d}"
96 fperms 755 "${dir}/${d}"
97 done
98 fi
99 ) &>/dev/null
100
101 f=$(find "${D}/${dir}" -perm +4000 -a -uid 0 2>/dev/null)
102 if [[ -n ${f} ]] ; then
103 eerror "A game was detected that is setuid root!"
104 eerror "${f}"
105 die "refusing to merge a setuid root game"
106 fi
107 done
108 [[ -d ${D}/${GAMES_BINDIR} ]] || return 0
109 find "${D}/${GAMES_BINDIR}" -maxdepth 1 -type f -exec chmod 750 '{}' \;
110 }
111
112 gamesenv() {
113 local d libdirs
114
115 for d in $(get_all_libdirs) ; do
116 libdirs="${libdirs}:${GAMES_PREFIX}/${d}"
117 done
118
119 # Wish we could use doevnd here, but we dont want the env
120 # file to be tracked in the CONTENTS of every game
121 cat <<-EOF > "${ROOT}"/etc/env.d/${GAMES_ENVD}
122 LDPATH="${libdirs:1}"
123 PATH="${GAMES_BINDIR}"
124 EOF
125 }
126
127 games_pkg_setup() {
128 tc-export CC CXX
129
130 enewgroup "${GAMES_GROUP}" 35
131 [[ ${GAMES_USER} != "root" ]] \
132 && enewuser "${GAMES_USER}" 35 -1 "${GAMES_PREFIX}" "${GAMES_GROUP}"
133 [[ ${GAMES_USER_DED} != "root" ]] \
134 && enewuser "${GAMES_USER_DED}" 36 /bin/bash "${GAMES_PREFIX}" "${GAMES_GROUP}"
135
136 # Dear portage team, we are so sorry. Lots of love, games team.
137 # See Bug #61680
138 [[ ${USERLAND} != "GNU" ]] && return 0
139 [[ $(egetshell "${GAMES_USER_DED}") == "/bin/false" ]] \
140 && usermod -s /bin/bash "${GAMES_USER_DED}"
141 }
142
143 games_src_configure() {
144 [[ -x ./configure ]] && egamesconf
145 }
146
147 games_src_compile() {
148 case ${EAPI:-0} in
149 0|1) games_src_configure ;;
150 esac
151 base_src_make
152 }
153
154 games_pkg_preinst() {
155 local f
156
157 while read f ; do
158 if [[ -e ${ROOT}/${GAMES_STATEDIR}/${f} ]] ; then
159 cp -p \
160 "${ROOT}/${GAMES_STATEDIR}/${f}" \
161 "${D}/${GAMES_STATEDIR}/${f}" \
162 || die "cp failed"
163 # make the date match the rest of the install
164 touch "${D}/${GAMES_STATEDIR}/${f}"
165 fi
166 done < <(find "${D}/${GAMES_STATEDIR}" -type f -printf '%P\n' 2>/dev/null)
167 }
168
169 # pkg_postinst function ... create env.d entry and warn about games group
170 games_pkg_postinst() {
171 gamesenv
172 if [[ -z "${GAMES_SHOW_WARNING}" ]] ; then
173 ewarn "Remember, in order to play games, you have to"
174 ewarn "be in the '${GAMES_GROUP}' group."
175 echo
176 case ${CHOST} in
177 *-darwin*) ewarn "Just run 'niutil -appendprop / /groups/games users <USER>'";;
178 *-freebsd*|*-dragonfly*) ewarn "Just run 'pw groupmod ${GAMES_GROUP} -m <USER>'";;
179 *) ewarn "Just run 'gpasswd -a <USER> ${GAMES_GROUP}', then have <USER> re-login.";;
180 esac
181 echo
182 einfo "For more info about Gentoo gaming in general, see our website:"
183 einfo " http://games.gentoo.org/"
184 echo
185 fi
186 }
187
188 # Unpack .uz2 files for UT2003/UT2004
189 # $1: directory or file to unpack
190 games_ut_unpack() {
191 local ut_unpack="$1"
192 local f=
193
194 if [[ -z ${ut_unpack} ]] ; then
195 die "You must provide an argument to games_ut_unpack"
196 fi
197 if [[ -f ${ut_unpack} ]] ; then
198 uz2unpack "${ut_unpack}" "${ut_unpack%.uz2}" \
199 || die "uncompressing file ${ut_unpack}"
200 fi
201 if [[ -d ${ut_unpack} ]] ; then
202 while read f ; do
203 uz2unpack "${ut_unpack}/${f}" "${ut_unpack}/${f%.uz2}" \
204 || die "uncompressing file ${f}"
205 rm -f "${ut_unpack}/${f}" || die "deleting compressed file ${f}"
206 done < <(find "${ut_unpack}" -maxdepth 1 -name '*.uz2' -printf '%f\n' 2>/dev/null)
207 fi
208 }
209
210 # Unpacks .umod/.ut2mod/.ut4mod files for UT/UT2003/UT2004
211 # Usage: games_umod_unpack $1
212 # oh, and don't forget to set 'dir' and 'Ddir'
213 games_umod_unpack() {
214 local umod=$1
215 mkdir -p "${Ddir}"/System
216 cp "${dir}"/System/{ucc-bin,{Manifest,Def{ault,User}}.ini,{Engine,Core,zlib,ogg,vorbis}.so,{Engine,Core}.int} "${Ddir}"/System
217 cd "${Ddir}"/System
218 UT_DATA_PATH=${Ddir}/System ./ucc-bin umodunpack -x "${S}/${umod}" -nohomedir &> /dev/null \
219 || die "uncompressing file ${umod}"
220 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 \
221 || die "Removing temporary files"
222 }
223
224 fi

  ViewVC Help
Powered by ViewVC 1.1.20