1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 # [x] Base Install Required (+4 MB)
5 # [x] Scenarios (+7 MB)
6 # [x] Sounds and Graphics (+118 MB)
14 LANGPACKPREFIX="${PN}-lang"
15 LANGPACKBASE="http://babelize.org/download/"
16 LANGPACKPATHPREFIX="${LANGPACKBASE}/${LANGPACKPREFIX}"
19 inherit eutils unpacker cdrom games
21 DESCRIPTION="Heroes of Might and Magic III: The Restoration of Erathia"
22 HOMEPAGE="http://www.lokigames.com/products/heroes3/"
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 )"
35 # ${LANGPACKBASE}/${PN}-localize-${LANGPACKVERSION}.run
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"
44 DEPEND="=dev-util/xdelta-1*
45 games-util/loki_patch"
46 RDEPEND="!ppc? ( sys-libs/lib-compat-loki )"
50 dir=${GAMES_PREFIX_OPT}/${PN}
55 # strip-linguas en ${LANGS}
57 use nocd && fullinstall=1
58 use sounds && use videos && use maps && fullinstall=1
60 [[ ${fullinstall} -eq 1 ]] \
61 && ewarn "The full installation takes about 341 MB of space!"
63 # if [[ -n "${fullinstall}" ]]
69 # if [[ ${i} != "en" ]]
71 # let $((++langcount))
72 # if [[ $langcount = 2 ]]
74 # eerror "Heroes3 only supports one localization at once!"
75 # die "Localization is only supported when Heroes3 is in a single language!"
83 # if [[ ${i} != "en" ]]
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!"
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
100 # if [[ ${i} != "en" ]]
104 ## unpack_makeself ${PN}-localize-${LANGPACKVERSION}.run
105 # unpack ${LANGPACKPREFIX}-${i}.tar.gz
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}}
120 doins -r "${CDROM_ROOT}"/{data,maps,mp3}
124 doins -r "${CDROM_ROOT}"/maps
128 doins -r "${CDROM_ROOT}"/mp3
132 insinto "${dir}"/data
133 doins "${CDROM_ROOT}"/data/{*.lod,*.snd}
137 doins -r "${CDROM_ROOT}"/data/video
141 # if [[ -n "${fullinstall}" ]]
143 # for i in ${LINGUAS}
146 # if [[ ${i} != "en" ]]
148 # find "${S}/localize/${i}" -type f | while read xfile
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"
155 # if [[ $retval = 0 ]]
157 # mv -f "${Ddir}/${file}.xdp" "${Ddir}/${file}"
159 # rm -f "${Ddir}/${file}.xdp"
161 # eend $retval "File $file could not be localized/patched! Original english version untouched..."
168 tar zxf "${CDROM_ROOT}"/hiscore.tar.gz -C "${Ddir}" || die
171 loki_patch --verify patch.dat
172 loki_patch patch.dat "${Ddir}" >& /dev/null || die
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 '{}' \;
179 newicon "${CDROM_ROOT}"/icon.xpm heroes3.xpm
182 make_desktop_entry heroes3 "Heroes of Might and Magic III" "heroes3"
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
192 elog "Changing 'hiscore.dat' to be writeable for group 'games'."
193 fperms g+w "${dir}/data/hiscore.dat"
195 # in order to play campaign games, put this wrapper in place.
196 # it changes CWD to a user-writeable directory before executing heroes3.
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
206 elog "To play the game run:"