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