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

Contents of /eclass/games.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.154 - (show annotations) (download)
Mon Apr 8 07:36:25 2013 UTC (2 years ago) by mr_bones_
Branch: MAIN
Changes since 1.153: +12 -1 lines
Add support for verbose build in <EAPI5

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

  ViewVC Help
Powered by ViewVC 1.1.20