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

Contents of /eclass/games.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.157 - (show annotations) (download)
Wed Mar 12 18:54:12 2014 UTC (9 months, 1 week ago) by hasufell
Branch: MAIN
Changes since 1.156: +7 -20 lines
fix games.eclass to use games-misc/games-envd

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

  ViewVC Help
Powered by ViewVC 1.1.20