dev-python/distlib: keyworded 0.3.0 for ia64, bug #700918
[gentoo.git] / games-action / descent2-data / descent2-data-1.2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 CDROM_OPTIONAL="yes"
7 inherit cdrom estack eutils
8
9 # Not possible to apply official 1.2 patch under Linux. A Gentoo user
10 # created Xdelta patches and the DXX-Rebirth project kindly hosted them.
11 MY_PATCH="http://www.dxx-rebirth.com/download/dxx/misc/d2xptch12.tgz"
12
13 # For GOG install
14 MY_EXE="setup_descent_2_1.1_(16596).exe"
15
16 DESCRIPTION="Data files for Descent 2"
17 HOMEPAGE="http://www.interplay.com/games/descent.php"
18 SRC_URI="cdinstall? ( ${MY_PATCH} )
19         !cdinstall? ( ${MY_EXE} )"
20 LICENSE="descent-data"
21 SLOT="0"
22 KEYWORDS="~amd64 ~x86"
23 IUSE="doc videos"
24 RESTRICT="bindist !cdinstall? ( fetch )"
25
26 # <d2x-0.2.5-r3 may include the data.
27 RDEPEND="!<games-action/d2x-0.2.5-r3
28         !games-action/descent2-demodata"
29
30 DEPEND="cdinstall? (
31                 app-arch/unarj
32                 dev-util/xdelta:3
33         )
34         !cdinstall? (
35                 app-arch/innoextract
36         )"
37
38 S="${WORKDIR}"
39
40 pkg_nofetch() {
41         elog "You must place a copy of, or symlink to, the GOG setup package in your"
42         elog "distfiles directory."
43         echo
44         elog "If you wish to install from CD-ROM instead, please enable the cdinstall flag."
45 }
46
47 src_unpack() {
48         if use cdinstall; then
49                 default
50                 cdrom_get_cds d2data/descent2.sow:descent2.hog
51
52                 case ${CDROM_SET} in
53                         0)
54                                 einfo "Found Descent 2 CD"
55                                 unarj e "${CDROM_ABSMATCH}" || die ;;
56                         1)
57                                 einfo "Found Descent 2 installation"
58                                 cd "${CDROM_ABSMATCH%/*}" || die ;;
59                 esac
60         else
61                 einfo "Unpacking ${MY_EXE}. This will take a while..."
62                 innoextract -e -s -p1 -L -I app -d gog "${DISTDIR}/${MY_EXE}" || die
63                 cd "${WORKDIR}/gog/app" || die
64         fi
65
66         eshopts_push -s globstar nocaseglob nullglob
67
68         # Strip directories
69         # Lowercase
70         # d2{-2plyr,chaos}.* into data/missions
71         # *.dem into data/demos
72         # Documentation into doc
73         # Remainder into data
74         # Exclude Vertigo files
75
76         tar c \
77                 --mode=u+w \
78                 --ignore-case \
79                 --xform='s:.*/::xg' \
80                 --xform='s:.*:\L\0:x' \
81                 --xform='s:^d2(-2plyr|chaos)\.:data/missions/\0:x' \
82                 --xform='s:.*\.dem$:data/demos/\0:x' \
83                 --xform='s:.*\.(pdf|txt)$:doc/\0:x' \
84                 --xform='s:^[^/]+$:data/\0:x' \
85                 --exclude='d2x*' \
86                 --exclude='hoard.ham' \
87                 --exclude='panic.*' \
88                 --exclude="$(use doc || echo '*.pdf')" \
89                 --exclude="$(use videos || echo '*.mvl')" \
90                 *.{txt,pdf} *-h.mvl **/*.{ham,hog,mn2,pig,s11,s22} \
91                 | tar x -C "${WORKDIR}"
92
93         assert "tar failed"
94         eshopts_pop
95 }
96
97 src_prepare() {
98         # Patch to 1.2 if necessary
99         if use cdinstall; then
100                 if [[ $(md5sum data/descent2.ham) != 7f30c3d7d4087b8584b49012a53ce022* ]]; then
101                         local i
102                         for i in *.xdelta; do
103                                 xdelta3 -d -s data/"${i%.*}" "${i}" data/"${i%.*}".new || die
104                                 mv data/"${i%.*}"{.new,} || die
105                         done
106                 fi
107         fi
108
109         default
110 }
111
112 src_install() {
113         insinto /usr/share/games/d2x
114         doins -r data/*
115         [[ -d doc ]] && dodoc doc/*
116 }
117
118 pkg_postinst() {
119         elog "A client is needed to run the game, e.g. games-action/dxx-rebirth."
120         echo
121 }