summaryrefslogtreecommitdiff
blob: 1a13c057b33b612f237a05912b6d98255d8b67b6 (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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-strategy/x2/x2-1.4.05.ebuild,v 1.2 2008/02/29 19:40:07 carlo Exp $

inherit eutils games

MY_PV="1.4.04-${PV}"
MY_UPD="http://updatefiles.linuxgamepublishing.com/${PN}"

DESCRIPTION="Open-ended space opera with trading, building & fighting"
HOMEPAGE="http://www.linuxgamepublishing.com/info.php?id=x2"
# Patches are in http://updatefiles.linuxgamepublishing.com/x2/
SRC_URI="${MY_UPD}/${PN}-1.4-1.4.01-x86.run
	${MY_UPD}/${PN}-1.4.01-1.4.02-x86.run
	${MY_UPD}/${PN}-1.4.02-1.4.03-x86.run
	${MY_UPD}/${PN}-1.4.03-1.4.04-x86.run
	${MY_UPD}/${PN}-${MY_PV}-x86.run"

LICENSE="as-is"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="bonusscripts dynamic langpacks linguas_de modkit"
RESTRICT="strip"

RDEPEND="media-libs/alsa-lib
	sys-libs/glibc
	x86? (
		media-libs/libsdl
		media-libs/openal
		sys-libs/zlib
		x11-libs/gtk+
		x11-libs/libX11
		x11-libs/libXau
		x11-libs/libXdmcp
		x11-libs/libXext
		x11-libs/libXi )
	amd64? (
		app-emulation/emul-linux-x86-gtklibs
		app-emulation/emul-linux-x86-sdl )"
DEPEND=""

S=${WORKDIR}

unpackit() {
	unpack "./cd/${1}.tar.gz"
}

src_unpack() {
	cdrom_get_cds bin/Linux/x86/${PN}
	ln -sfn "${CDROM_ROOT}"/data cd

	unpackit data
	use bonusscripts && unpackit bonusscripts
	use linguas_de && unpackit german
	use langpacks && unpackit langpacks
	use modkit && unpackit modkit

	rm -f cd

	cp -rf "${CDROM_ROOT}"/bin/Linux/x86/* . || die "cp exes"
	cp -f "${CDROM_ROOT}"/{READ*,icon*} . || die "cp READ*"

	# Apply the patches
	local p
	for p in 1.4-1.4.01 1.4.01-1.4.02 1.4.02-1.4.03 1.4.03-1.4.04 \
		"${MY_PV}" ; do
		einfo "Applying patch ${p}"
		mkdir patch
		cd patch
		unpack_makeself "${PN}-${p}-x86.run"
		bin/Linux/x86/loki_patch patch.dat "${S}" \
			|| die "loki_patch ${p}"
		cp -f README.txt "${S}/ChangeLog" || die "cp README.txt"
		cd "${S}"
		rm -rf patch
	done

	# These files do not get installed
	[[ -e modkit ]] && rm -f modkit/x2*.debug
}

src_install() {
	local dir=${GAMES_PREFIX_OPT}/${PN}

	# Whether to use static (default) or dynamic binaries
	local dyn
	use dynamic && dyn=".dynamic"

	insinto "${dir}"
	doins -r * || die "doins -r"
	keepdir "${dir}"/Database

	exeinto "${dir}"
	doexe x2{,.dynamic} || die "doexe x2"

	if use modkit ; then
		exeinto "${dir}"/modkit
		doexe modkit/x2{build,tool}{,.dynamic} || die "doexe modkit"
		local f
		for f in build tool ; do
			games_make_wrapper "x2${f}" "${dir}/modkit/x2${f}${dyn}"
		done
	fi

	games_make_wrapper ${PN} "./${PN}${dyn}" "${dir}"
	newicon "${CDROM_ROOT}"/icon.xpm ${PN}.xpm || die "newicon"
	make_desktop_entry ${PN} "X2 - The Threat" ${PN}

	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst

	if use dynamic ; then
		elog "Please try without the 'dynamic' USE flag, before reporting bugs."
	fi
}