summaryrefslogtreecommitdiff
blob: 9bc2b9b522fca5e1e57dddbdb590ce36fb785b0d (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
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-fps/duke3d-data/duke3d-data-1.0-r2.ebuild,v 1.2 2014/09/22 23:10:20 hasufell Exp $

EAPI=5

CDROM_OPTIONAL="yes"
inherit eutils cdrom games

GOG_FILE="gog_duke_nukem_3d_1.0.0.7.tar.gz"
DESCRIPTION="Duke Nukem 3D data files"
HOMEPAGE="http://www.3drealms.com/"
SRC_URI="gog? ( ${GOG_FILE} )"

LICENSE="DUKE3D gog? ( GOG-EULA )"
SLOT="0"
KEYWORDS="~amd64 ~hppa ~ppc ~x86"
IUSE="gog"
REQUIRED_USE="^^ ( cdinstall gog )"
RESTRICT="mirror bindist gog? ( fetch )"

RDEPEND="|| ( games-fps/eduke32 games-fps/duke3d )"

S=${WORKDIR}

pkg_nofetch() {
	einfo "Please download ${GOG_FILE} from your GOG.com account after buying Duke Nukem 3d"
	einfo "and put it into ${DISTDIR}."
}

src_unpack() {
	if use cdinstall ; then
		export CDROM_NAME_SET=(
			"Existing Install"
			"Duke Nukem 3D CD"
			"Duke Nukem 3D Atomic Edition CD"
			)
		cdrom_get_cds duke3d.grp:dvd/dn3dinst/duke3d.grp:atominst/duke3d.grp

		if [[ ${CDROM_SET} -ne 0
			&& ${CDROM_SET} -ne 1
			&& ${CDROM_SET} -ne 2 ]]
		then
			die "Error locating data files.";
		fi
	else
		unpack "${GOG_FILE}"
		cd "Duke Nukem 3D/data" || die

		# convert to lowercase
		find . -type f \
			-execdir sh -c 'echo "converting ${1} to lowercase"
			lower="`echo "${1}" | tr [:upper:] [:lower:]`"
			[ "${1}" = "${lower}" ] || mv "${1}" "${lower}"' - {} \;
	fi
}

src_install() {
	local DATAROOT

	insinto "${GAMES_DATADIR}"/duke3d

	if use cdinstall ; then
		case ${CDROM_SET} in
		0) DATAROOT="" ;;
		1) DATAROOT="dn3dinst/" ;;
		2) DATAROOT="atominst/" ;;
		esac

		# avoid double slash
		doins "${CDROM_ROOT}"/${DATAROOT}{duke3d.grp,duke.rts,game.con,user.con,demo?.dmo,defs.con}
	else
		doins "Duke Nukem 3D/data"/{duke3d.grp,duke.rts,game.con,user.con,demo?.dmo,defs.con}
	fi

	prepgamesdirs
}