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

Contents of /trunk/prefix/eclass/games-etmod.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: 3810 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-etmod.eclass,v 1.9 2005/07/11 15:08:06 swegener Exp $
4
5 inherit games
6
7
8 EXPORT_FUNCTIONS src_install pkg_postinst
9
10 DESCRIPTION="Enemy Territory - ${MOD_DESC}"
11
12 SLOT="0"
13 KEYWORDS="-* amd64 x86"
14 RESTRICT="strip"
15 IUSE="opengl dedicated"
16
17 DEPEND="app-arch/unzip"
18 RDEPEND="virtual/libc
19 games-fps/enemy-territory
20 amd64? ( app-emulation/emul-linux-x86-baselibs
21 opengl? ( app-emulation/emul-linux-x86-xlibs ) )
22 dedicated? ( app-misc/screen )
23 opengl? ( virtual/opengl )"
24
25 S=${WORKDIR}
26
27 games-etmod_src_install() {
28 [ -z "${MOD_NAME}" ] && die "what is the name of this etmod ?"
29
30 local bdir=${GAMES_PREFIX_OPT}/enemy-territory
31 local mdir=${bdir}/${MOD_NAME}
32 MOD_BINS=${MOD_BINS:-${MOD_NAME}}
33
34 if [ -d ${MOD_NAME} ] ; then
35 dodir ${bdir}
36 mv ${MOD_NAME} ${D}/${bdir}/
37 fi
38 if [ -d etmain ] ; then
39 dodir ${bdir}
40 mv etmain ${D}/${bdir}/
41 fi
42 if [ ! -z "`ls ${S}/* 2> /dev/null`" ] ; then
43 dodir ${mdir}
44 mv ${S}/* ${D}/${mdir}/
45 fi
46
47 if use dedicated; then
48 games-etmod_make_etded_exec
49 newgamesbin ${T}/et-${MOD_NAME}-ded.bin et-${MOD_BINS}-ded
50 fi
51 if use opengl; then
52 games-etmod_make_enemy-territory_exec
53 newgamesbin ${T}/et-${MOD_NAME}.bin et-${MOD_BINS}
54 fi
55
56 if use dedicated; then
57 games-etmod_make_init.d
58 newinitd ${T}/et-${MOD_NAME}-ded.init.d et-${MOD_BINS}-ded
59 games-etmod_make_conf.d
60 newconfd ${T}/et-${MOD_NAME}-ded.conf.d et-${MOD_BINS}-ded
61
62 dodir ${GAMES_SYSCONFDIR}/enemy-territory
63
64 dodir ${bdir}/etwolf-homedir
65 dosym ${bdir}/etwolf-homedir ${GAMES_PREFIX}/.wolfet
66 keepdir ${bdir}/etwolf-homedir
67 chmod g+rw ${D}/${mdir} ${D}/${bdir}/etwolf-homedir
68 chmod -R g+rw ${D}/${GAMES_SYSCONFDIR}/enemy-territory
69 fi
70 prepgamesdirs
71 }
72
73 games-etmod_pkg_postinst() {
74 local samplecfg=${FILESDIR}/server.cfg
75 local realcfg=${GAMES_PREFIX_OPT}/enemy-territory/${MOD_NAME}/server.cfg
76 if [ -e ${samplecfg} ] && [ ! -e ${realcfg} ] ; then
77 cp ${samplecfg} ${realcfg}
78 fi
79
80 use opengl && einfo "To play this mod: et-${MOD_BINS}"
81 if use dedicated; then
82 einfo "To launch a dedicated server: et-${MOD_BINS}-ded"
83 einfo "To launch server at startup: /etc/init.d/et-${MOD_NAME}-ded"
84 fi
85
86 games_pkg_postinst
87 }
88
89 games-etmod_make_etded_exec() {
90 cat << EOF > ${T}/et-${MOD_NAME}-ded.bin
91 #!/bin/sh
92 exec ${GAMES_BINDIR}/et-ded +set fs_game ${MOD_NAME} +set dedicated 1 +exec server.cfg \${@}
93 EOF
94 }
95
96 games-etmod_make_enemy-territory_exec() {
97 cat << EOF > ${T}/et-${MOD_NAME}.bin
98 #!/bin/sh
99 exec ${GAMES_BINDIR}/et +set fs_game ${MOD_NAME} \${@}
100 EOF
101 }
102
103 games-etmod_make_init.d() {
104 cat << EOF > ${T}/et-${MOD_NAME}-ded.init.d
105 #!/sbin/runscript
106 $(<${PORTDIR}/header.txt)
107
108 depend() {
109 need net
110 }
111
112 start() {
113 ebegin "Starting ${MOD_NAME} dedicated"
114 screen -A -m -d -S et-${MOD_BINS}-ded su - ${GAMES_USER_DED} -c "${GAMES_BINDIR}/et-${MOD_BINS}-ded \${${MOD_NAME}_OPTS}"
115 eend \$?
116 }
117
118 stop() {
119 ebegin "Stopping ${MOD_NAME} dedicated"
120 local pid=\`screen -list | grep et-${MOD_BINS}-ded | awk -F . '{print \$1}' | sed -e s/.//\`
121 if [ -z "\${pid}" ] ; then
122 eend 1 "Lost screen session"
123 else
124 pid=\`pstree -p \${pid} | sed -e 's:^.*etded\.x86::'\`
125 pid=\${pid:1:\${#pid}-2}
126 if [ -z "\${pid}" ] ; then
127 eend 1 "Lost etded session"
128 else
129 kill \${pid}
130 eend \$? "Could not kill etded"
131 fi
132 fi
133 }
134
135 status() {
136 screen -list | grep et-${MOD_BINS}-ded
137 }
138 EOF
139 }
140
141 games-etmod_make_conf.d() {
142 if [ -e ${FILESDIR}/${MOD_NAME}.conf.d ] ; then
143 cp ${FILESDIR}/${MOD_NAME}.conf.d ${T}/et-${MOD_NAME}-ded.conf.d
144 return 0
145 fi
146 cat << EOF > ${T}/et-${MOD_NAME}-ded.conf.d
147 $(<${PORTDIR}/header.txt)
148
149 # Any extra options you want to pass to the dedicated server
150 ${MOD_NAME}_OPTS="+set com_hunkmegs 64 +set com_zonemegs 32"
151 EOF
152 }

  ViewVC Help
Powered by ViewVC 1.1.20