games-strategy/wesnoth: Only keyword release versions
[gentoo.git] / games-strategy / heroes3 / heroes3-1.3.1a-r2.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 #       [x] Base Install Required (+4 MB)
5 #       [x] Scenarios (+7 MB)
6 #       [x] Sounds and Graphics (+118 MB)
7 #       [x] Music (+65 MB)
8 #       [x] Videos (+147 MB)
9 #       --------------------
10 #       Total 341 MB
11
12 EAPI=5
13 LANGS="de es pl"
14 LANGPACKPREFIX="${PN}-lang"
15 LANGPACKBASE="http://babelize.org/download/"
16 LANGPACKPATHPREFIX="${LANGPACKBASE}/${LANGPACKPREFIX}"
17 LANGPACKVERSION=1.0.4
18
19 inherit eutils unpacker cdrom games
20
21 DESCRIPTION="Heroes of Might and Magic III: The Restoration of Erathia"
22 HOMEPAGE="http://www.lokigames.com/products/heroes3/"
23
24 # Since I do not have a PPC machine to test with, I will leave the PPC stuff in
25 # here so someone else can stabilize loki_setupdb and loki_patch for PPC and
26 # then KEYWORD this appropriately.
27 SRC_URI="x86? ( mirror://lokigames/${PN}/${P}-cdrom-x86.run )
28         amd64? ( mirror://lokigames/${PN}/${P}-cdrom-x86.run )
29         ppc? ( mirror://lokigames/${PN}/${P}-ppc.run )"
30 # This is commented because the server is unreachable.
31 #       linguas_es? ( ${LANGPACKPATHPREFIX}-es.tar.gz )
32 #       linguas_de? ( ${LANGPACKPATHPREFIX}-de.tar.gz )
33 #       linguas_pl? ( ${LANGPACKPATHPREFIX}-pl.tar.gz )"
34
35 #               ${LANGPACKBASE}/${PN}-localize-${LANGPACKVERSION}.run
36
37 LICENSE="LOKI-EULA"
38 SLOT="0"
39 IUSE="nocd maps music sounds videos"
40 #linguas_en linguas_es linguas_pl linguas_de"
41 KEYWORDS="~amd64 ~x86"
42 RESTRICT="strip mirror bindist"
43
44 DEPEND="=dev-util/xdelta-1*
45         games-util/loki_patch"
46 RDEPEND="!ppc? ( sys-libs/lib-compat-loki )"
47
48 S=${WORKDIR}
49
50 dir=${GAMES_PREFIX_OPT}/${PN}
51 Ddir=${D}/${dir}
52
53 pkg_setup() {
54         games_pkg_setup
55 #       strip-linguas en ${LANGS}
56
57         use nocd && fullinstall=1
58         use sounds && use videos && use maps && fullinstall=1
59
60         [[ ${fullinstall} -eq 1 ]] \
61                 && ewarn "The full installation takes about 341 MB of space!"
62
63 #       if [[ -n "${fullinstall}" ]]
64 #       then
65 #               langcount=0
66 #               for i in ${LINGUAS}
67 #               do
68 #                       i="${i/_/-}"
69 #                       if [[ ${i} != "en" ]]
70 #                       then
71 #                               let $((++langcount))
72 #                               if [[ $langcount = 2 ]]
73 #                               then
74 #                                       eerror "Heroes3 only supports one localization at once!"
75 #                                       die "Localization is only supported when Heroes3 is in a single language!"
76 #                               fi
77 #                       fi
78 #               done
79 #       else
80 #               for i in ${LINGUAS}
81 #               do
82 #                       i="${i/_/-}"
83 #                       if [[ ${i} != "en" ]]
84 #                       then
85 #                               eerror "Full installation (nocd flag or data + video + maps flags) is needed for ${i} language!"
86 #                               die "Localization is only supported when Heroes3 is fully locally installed!"
87 #                       fi
88 #               done
89 #       fi
90 }
91
92 src_unpack() {
93         cdrom_get_cds hiscore.tar.gz
94         (use x86 || use amd64) && unpack_makeself ${P}-cdrom-x86.run
95         use ppc && unpack_makeself ${P}-ppc.run
96
97 #       for i in ${LINGUAS}
98 #       do
99 #               i="${i/_/-}"
100 #               if [[ ${i} != "en" ]]
101 #               then
102 #                       mkdir localize
103 #                       cd localize
104 ##                      unpack_makeself ${PN}-localize-${LANGPACKVERSION}.run
105 #                       unpack ${LANGPACKPREFIX}-${i}.tar.gz
106 #                       break
107 #               fi
108 #       done
109 }
110
111 src_install() {
112         exeinto "${dir}"
113         insinto "${dir}"
114         einfo "Copying files... this may take a while..."
115         doexe "${CDROM_ROOT}"/bin/x86/${PN}
116         doins "${CDROM_ROOT}"/{Heroes_III_Tutorial.pdf,README,icon.{bmp,xpm}}
117
118         if use nocd
119         then
120                 doins -r "${CDROM_ROOT}"/{data,maps,mp3}
121         else
122                 if use maps
123                 then
124                         doins -r "${CDROM_ROOT}"/maps
125                 fi
126                 if use music
127                 then
128                         doins -r "${CDROM_ROOT}"/mp3
129                 fi
130                 if use sounds
131                 then
132                         insinto "${dir}"/data
133                         doins "${CDROM_ROOT}"/data/{*.lod,*.snd}
134                 fi
135                 if use videos
136                 then
137                         doins -r "${CDROM_ROOT}"/data/video
138                 fi
139         fi
140
141 #       if [[ -n "${fullinstall}" ]]
142 #       then
143 #               for i in ${LINGUAS}
144 #               do
145 #                       i="${i/_/-}"
146 #                       if [[ ${i} != "en" ]]
147 #                       then
148 #                               find "${S}/localize/${i}" -type f | while read xfile
149 #                               do
150 #                                       local file=$(echo "${xfile}" | \
151 #                                               sed "s#^${S}/localize/${i}/##;s#\.xdelta\$##")
152 #                                       ebegin "Localizing ${file}"
153 #                                       xdelta patch "${xfile}" "${Ddir}/${file}" "${Ddir}/${file}.xdp"
154 #                                       local retval=$?
155 #                                       if [[ $retval = 0 ]]
156 #                                       then
157 #                                               mv -f  "${Ddir}/${file}.xdp" "${Ddir}/${file}"
158 #                                       else
159 #                                               rm -f "${Ddir}/${file}.xdp"
160 #                                       fi
161 #                                       eend $retval "File $file could not be localized/patched! Original english version untouched..."
162 #                               done
163 #                               break
164 #                       fi
165 #               done
166 #       fi
167
168         tar zxf "${CDROM_ROOT}"/hiscore.tar.gz -C "${Ddir}" || die
169
170         cd "${S}"
171         loki_patch --verify patch.dat
172         loki_patch patch.dat "${Ddir}" >& /dev/null || die
173
174         # now, since these files are coming off a cd, the times/sizes/md5sums wont
175         # be different ... that means portage will try to unmerge some files (!)
176         # we run touch on ${D} so as to make sure portage doesnt do any such thing
177         find "${Ddir}" -exec touch '{}' \;
178
179         newicon "${CDROM_ROOT}"/icon.xpm heroes3.xpm
180
181         prepgamesdirs
182         make_desktop_entry heroes3 "Heroes of Might and Magic III" "heroes3"
183
184         if ! use ppc
185         then
186                 einfo "Linking libs provided by 'sys-libs/lib-compat-loki' to '${dir}'."
187                 dosym /lib/loki_ld-linux.so.2 "${dir}"/ld-linux.so.2
188                 dosym /usr/lib/loki_libc.so.6 "${dir}"/libc.so.6
189                 dosym /usr/lib/loki_libnss_files.so.2 "${dir}"/libnss_files.so.2
190         fi
191
192         elog "Changing 'hiscore.dat' to be writeable for group 'games'."
193         fperms g+w "${dir}/data/hiscore.dat"
194
195         # in order to play campaign games, put this wrapper in place.
196         # it changes CWD to a user-writeable directory before executing heroes3.
197         # (fixes bug #93604)
198         einfo "Preparing wrapper."
199         cp "${FILESDIR}"/heroes3-wrapper.sh "${T}"/heroes3 || die
200         sed -i -e "s:GAMES_PREFIX_OPT:${GAMES_PREFIX_OPT}:" "${T}"/heroes3 || die
201         dogamesbin "${T}"/heroes3
202 }
203
204 pkg_postinst() {
205         games_pkg_postinst
206         elog "To play the game run:"
207         elog " heroes3"
208 }