summaryrefslogtreecommitdiff
blob: a00eb14c5f4fe6243e90eeea042d613a89e66ef5 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=2

inherit games check-reqs git-2

MY_PN="${PN%-data}"
DESCRIPTION="Xonotic data files"
HOMEPAGE="http://www.xonotic.org/"
BASE_URI="git://git.xonotic.org/${MY_PN}/${MY_PN}"
EGIT_REPO_URI="${BASE_URI}.git"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS=""
IUSE="+client +convert low +maps +zip"

RDEPEND=""
DEPEND="
	~games-util/fteqcc-xonotic-9999
	convert? (
		media-gfx/imagemagick[jpeg,png]
		low? ( media-sound/vorbis-tools )
	)
	zip? ( app-arch/p7zip )
"
PDEPEND="maps? ( ~games-fps/xonotic-maps-9999 )"

pkg_setup() {
	games_pkg_setup

	if use convert; then
		ewarn "cached-converter.sh will use \"xonotic-cached-converter\" subdirectory of your DISTDIR"
		echo
	fi

	if use !client; then
		ewarn "You have disabled client USE flag, only files for server will be installed."
		ewarn "This feature is experimental, if anything goes wrong, contact the maintainer."
		echo
	fi

	ewarn "You need 1,5 Gb diskspace for distfiles."
	if use !client; then
		CHECKREQS_DISK_BUILD="3000"
		CHECKREQS_DISK_USR="320"
	else
		if use zip; then
			CHECKREQS_DISK_BUILD="3850"
			CHECKREQS_DISK_USR="1830"
		else
			CHECKREQS_DISK_BUILD="7020"
			CHECKREQS_DISK_USR="3520"
		fi
	fi
	check_reqs
}

git_pk3_unpack() {
	unset EGIT_MASTER EGIT_BRANCH EGIT_COMMIT EGIT_PROJECT EGIT_DIR
	EGIT_REPO_URI="${BASE_URI}-${1}.pk3dir.git" \
	EGIT_SOURCEDIR="${S}/data/${MY_PN}-${1}.pk3dir" \
	git-2_src_unpack
}

src_unpack() {
	# root
	git-2_src_unpack

	# Data
	git_pk3_unpack data
	git_pk3_unpack maps
	# needed only for client
	if use client; then
		git_pk3_unpack music
		git_pk3_unpack nexcompat
	else
		rm -rf "${S}"/data/font-*.pk3dir || die "rm failed"
	fi
}

src_prepare() {
	# Data
	if use !client; then
		pushd data
		rm -rf \
			xonotic-data.pk3dir/gfx \
			xonotic-data.pk3dir/particles \
			xonotic-data.pk3dir/sound/cyberparcour01/rocket.txt \
			xonotic-data.pk3dir/textures \
			xonotic-maps.pk3dir/textures \
			|| die "rm failed"
		rm -f \
			$(find -type f -name '*.jpg') \
			$(find -type f -name '*.png' ! -name 'sky??.png') \
			$(find -type f -name '*.svg') \
			$(find -type f -name '*.tga') \
			$(find -type f -name '*.wav') \
			$(find -type f -name '*.ogg') \
			$(find -type f -name '*.mp3') \
			$(find -type f -name '*.ase') \
			$(find -type f -name '*.map') \
			$(find -type f -name '*.zym') \
			$(find -type f -name '*.obj') \
			$(find -type f -name '*.blend') \
			|| die "rm failed"
		find -type d \
			-exec rmdir '{}' &>/dev/null \;
		sed -i \
			-e '/^qc-recursive:/s/menu.dat//' \
			xonotic-data.pk3dir/Makefile || die "sed failed"
		popd
	fi
}

src_compile() {
	# Data
	cd data
	pushd xonotic-data.pk3dir
	emake \
		FTEQCC="/usr/bin/fteqcc-xonotic" \
		FTEQCCFLAGS_WATERMARK='' \
		|| die "emake data.pk3 failed"
	popd

	rm -rf \
		$(find -name '.git*') \
		$(find -type d -name '.svn') \
		$(find -type d -name 'qcsrc') \
		$(find -type f -name '*.sh') \
		$(find -type f -name '*.pl') \
		$(find -type f -name 'Makefile') \
		|| die "rm failed"

	if use convert; then
		# Used git.eclass,v 1.50 as example
		: ${CACHE_STORE_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/xonotic-cached-converter"}
		# initial download, we have to create master maps storage directory and play
		# nicely with sandbox
		if [[ ! -d ${CACHE_STORE_DIR} ]] ; then
			addwrite "${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}" # git.eclass was used, DISTDIR sure exists
			mkdir -p "${CACHE_STORE_DIR}" \
				|| die "can't mkdir ${CACHE_STORE_DIR}."
			export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
		fi
		# allow writing into CACHE_STORE_DIR
		addwrite "${CACHE_STORE_DIR}"

		if use low; then
			export jpeg_qual_rgb=80
			export jpeg_qual_a=97
			export do_ogg=true
			export ogg_qual=1
		else
			export jpeg_qual_rgb=97
			export jpeg_qual_a=99
			export do_ogg=false
		fi

		for i in data music maps nexcompat; do
			find xonotic-${i}.pk3dir -type f -print0 |
				git_src_repo="${S}"/data/xonotic-${i}.pk3dir \
				CACHEDIR="${CACHE_STORE_DIR}" \
				do_jpeg=true                 \
				do_dds=false                 \
				del_src=true                 \
				xargs -0 "${S}"/misc/tools/cached-converter.sh
		done
	fi

	if use zip; then
		for d in *.pk3dir; do
			pushd "${d}"
			7za a -tzip "../${d%dir}" . || die "zip failed"
			popd
			rm -rf "${d}" || die "rm failed"
		done
	fi
}

src_install() {
	# Data
	insinto "${GAMES_DATADIR}/${MY_PN}"
	doins -r data || die "doins data failed"

	prepgamesdirs
}