summaryrefslogtreecommitdiff
blob: 972db97f6013000f147803b00b6493b6c4006791 (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
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=6

inherit eutils unpacker

GOG_PATCH_PV="2.0.1.2"

DESCRIPTION="2D Action-RPG with a rich cyberpunk world"
HOMEPAGE="http://en.dreadlocks.cz/games/dex/"
SRC_URI="
	gog? (
		gog_${PN}_${PV}.sh
		patch_${PN}_${GOG_PATCH_PV}.sh
	)
"

RESTRICT="fetch strip"
LICENSE="EULA"

SLOT="0"
KEYWORDS="amd64 x86"
IUSE="+gog"

DEPEND="
	app-arch/unzip
	dev-util/xdelta3
"
RDEPEND="
	dev-libs/glib
	media-libs/mesa
	virtual/libc
	x11-libs/gdk-pixbuf
	x11-libs/gtk+
	x11-libs/libX11
	x11-libs/libXcursor
	x11-libs/libXrandr
"

S="${WORKDIR}"

pkg_nofetch() {
	einfo ""
	einfo "Please open ${HOMEPAGE}, choose a place to buy it,"
	einfo "then download \"${SRC_URI}\", and move/link it to \"${DISTDIR}\""
	einfo ""
	einfo "P.S.: I've only gog version. So, if you have Humble Store version"
	einfo "and want this ebuild to also cover it — please contact me."
}

src_unpack() {
	for f in ${A[@]}; do
		unzip -qn "${DISTDIR}/${f}"
	done
}

src_prepare() {
	rm -r meta scripts
	default
	while read Line # -- patch files
	do
		Line2=$(echo $Line | cut -d " " -f 2-)
		xdelta3 -v -d -s "${Line2}" patch/"${Line2}".delta patch/"${Line2}".tmp || die "ERROR (patching): File version mismatch, quitting"
	done < patch/files_to_patch.list

	while read Line # -- move patched files to the right place
	do
		Line2=$(echo $Line | cut -d " " -f 2-)
		chmod $(stat -c%a "${Line2}") patch/"${Line2}".tmp
		mv -vf patch/"${Line2}".tmp "${Line2}"
	done < patch/files_to_patch.list

	while read Line # -- remove patch files
	do
		Line2=$(echo $Line | cut -d " " -f 2-)
		rm -vfr "patch/${Line2}".delta
	done < patch/files_to_patch.list
}

src_install() {
	local dir="/opt/${PN}" arch="x86" exe modexe;

#	use amd64 && arch="x86_64";
	exe="${PN^}.x86"; # fixme when gog'll release x86_64 version
	cfgexe="GamepadConfigTool.x86" #.${arch}";

	insinto "${dir}";
	exeinto "${dir}";

	cd data/noarch;

	doins -r game/*
	doexe "game/${exe}" "game/${cfgexe}" "support/gog-system-report.sh"

	touch "${D}/${dir}/controller.config"
	fperms 666 "${dir}/controller.config" # so, gamepad config tool will be able to save content to it, even if runs under unpriv. user

	make_wrapper "${PN}" "./${exe}" "${dir}"
	make_wrapper "${PN}-gog-system-report" "./gog-system-report.sh" "${dir}"
	make_wrapper "${PN}-gc" "./${cfgexe}" "${dir}"
	newicon "support/icon.png" "${PN}.png"
	make_desktop_entry "${PN}" "${PN^}: Play" "${PN}"
	make_desktop_entry "${PN}-gc" "${PN^}: Gamepad Configuration tool" "${PN}"
}

pkg_postinst() {
	einfo 'If game badly detects your gamepad (i.e. some keys is not working),'
	einfo 'you can run `dex-gc` tool (Gamepad Configuration tool)'
	einfo 'It will calibrate your gamepad and save configuration so Dex game'
	einfo 'will be able to load it and work normally with your gamepad'
}