]> Pileus Git - ~andy/sunrise/blob - games-strategy/moo2/moo2-1.40.24.ebuild
games-strategy/moo2: Fixed typo in license.
[~andy/sunrise] / games-strategy / moo2 / moo2-1.40.24.ebuild
1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=1
6
7 inherit eutils games
8
9 OFFICIAL_PATCH="moo2v131.zip"
10 LB_PATCH="Moo2v140b24.zip"
11
12 DESCRIPTION="A classic 4X turn-based space strategy game"
13 HOMEPAGE="http://lordbrazen.blogspot.com"
14 SRC_URI="ftp://ftp.infogrames.net/patches/moo2/${OFFICIAL_PATCH}
15         lordbrazen? ( http://www.spheriumnorth.com/blog-images/${LB_PATCH} )"
16
17 LICENSE="GPL-2 Hasbro-EULA"
18 SLOT="0"
19 KEYWORDS="~amd64 ~x86"
20 IUSE="nocd lordbrazen"
21
22 DEPEND="|| ( media-gfx/graphicsmagick media-gfx/imagemagick )"
23 RDEPEND="games-emulation/dosbox"
24
25 destDir="${GAMES_PREFIX_OPT}/${PN}"
26 fullGameName="Master of Orion II: Battle at Antares"
27 unsupportedMsg="
28 Unfortunately, several differing versions of the Master of Orion II: Battle at
29 Antares CD-ROM have been released and this ebuild does not have specific
30 support yours and may fail. Please help out!  Visit
31 http://bugs.gentoo.org/show_bug.cgi?id=341859 and post the result of this
32 ebuild along with a full directory listing of your CD-ROM, the contents of the
33 the README.TXT file and any other info you think might be helpful.
34 "
35
36 pkg_setup() {
37         games_pkg_setup
38         cdrom_get_cds ORION95.EXE
39
40         # Workaround to bug #342269
41         test -e "${CDROM_ROOT}/ORION95.EXE" ||
42                 die "CD_ROOT does not point to the ${fullGameName} CD"
43
44         # Try to determine Which version of the CD-ROM we have.  These tests are
45         # far from perfect, but will work on the two currently known versions.
46         if [[ -e "${CDROM_ROOT}/Patch13.lbx" ]]; then
47                 # Hasboro v1.31 minus DOS support
48                 cdVersion=H1.31
49         elif [[ -e "${CDROM_ROOT}/INSTALL.EXE" ]]; then
50                 # Original MicroProse v1.2
51                 cdVersion=M1.2
52         else
53                 # There may be others out there
54                 cdVersion=unknown
55                 ewarn "${unsupportedMsg}"
56         fi
57 }
58
59 src_unpack() {
60         local srcIcon
61
62         sed "s:__MOO2DIR__:${destDir}:g" "${FILESDIR}/${PVR}/moo2" > moo2 ||
63                 die "sed failed"
64
65         mkdir -p patches docs || die
66         pushd patches || die
67
68         # First, unpack the MicroProse official 1.31 patch
69         unpack ${OFFICIAL_PATCH} || die
70
71         # Add unofficial patch if use flag set, although it has to be run in dosbox,
72         # so it will actually run the first time the user lanuches the game.
73         if use lordbrazen; then
74                 unpack ${LB_PATCH} || die
75         fi
76         popd
77
78         # Move docs out of install dir
79         # Readme.txt from 1.31 patch
80         mv patches/Readme.txt docs/MicroProse-1.31-Readme.txt || die "mv failed"
81
82         # Docs in unofficial patch
83         if use lordbrazen; then
84                 mv patches/{MOO2v140_readme.txt,ChangeLog.txt} docs || die "mv failed"
85         fi
86
87         # Find an icon and convert it to png
88         pushd "${CDROM_ROOT}"
89
90         # Original MicroProse icon
91         if [ -e ORION2.ICO ]; then
92                 srcIcon=ORION2.ICO
93
94         # The only icon file on the Hasboro CD
95         elif [ -e SIMTEX.ICO ]; then
96                 srcIcon=SIMTEX.ICO
97
98         # Can we find any icon?
99         else
100                 srcIcon="$(ls -1 *.ICO *.ico 2>/dev/null | awk '{print $1}')"
101                 test -s "$srcIcon" || die "Can't find an icon on your CD-ROM to use."
102         fi
103
104         convert "${srcIcon}" "${WORKDIR}/${PN}.png" || die "convert failed"
105 }
106
107 src_install() {
108         local cdDir
109
110         # Main launch script
111         dogamesbin "${WORKDIR}/moo2" || die
112
113         # Supporting Bash function libs & default config file
114         insinto "${destDir}"
115         doins "${FILESDIR}/${PVR}/"{moo2rc,utils.sh,backup.sh} || die
116
117         # Copy CD or create symlink.  Having either a "cdfiles" directory or a
118         # "cdlink" symlink in addition to a "cd" symlink that points to one of them
119         # is really kinda stupid, but it's a work-around for problems that occur
120         # when remerging and changing the nocd option without unmerging first.  If
121         # you remove this mechanism, retest!  (portage may fix it one day)
122         if use nocd; then
123                 cdDir=cdfiles
124
125                 # Copy the CD to disk
126                 insinto "${destDir}/cdfiles"
127                 pushd "${CDROM_ROOT}" || die
128                 ebegin "Copying CD-ROM files to disk"
129                 # ebuild complains about directx drivers, so omit them
130                 doins -r $(ls -1 | egrep -v 'DIRECTX') || die
131                 eend
132                 popd
133         else
134                 cdDir=cdlink
135
136                 # Create symlink to the CD.  If the user has more than one CD-ROM drive
137                 # or mount point, this can break later, but they can just re-install or
138                 # fix it themselves.
139                 dosym "${CDROM_ROOT}" "${destDir}/cdlink" || die
140         fi
141
142         # Create universal symlink for CD
143         dosym "${destDir}/${cdDir}" "${destDir}/cd" || die
144
145         # Simulate DOS INSTALL.EXE.
146         insinto "${destDir}/MPS/ORION2"
147
148         # If USE=nocd, we use symlinks instead of copying files to save space.  Hard
149         # links would work better, but dohard doesn't appear to work if the target
150         # does not already exist outside of the sandbox. (bug in dohard or intended
151         # functionality?)
152         if use nocd; then
153                 for f in $(cat "${FILESDIR}/installList.txt"); do
154                         dosym "${destDir}/cd/${f}" "${destDir}/MPS/ORION2/$f" || die
155                 done
156         else
157                 pushd "${CDROM_ROOT}" || die
158                 # This step can be slow
159                 ebegin "Simulating DOS INSTALL.EXE program"
160                 doins $(cat "${FILESDIR}/installList.txt") || die
161                 eend
162                 popd
163         fi
164
165         # Install patches.
166         doins patches/* || die
167
168         # Install pre-configured .INI files (hardware is simulated, so it's all the
169         # same)
170         doins "${FILESDIR}/"*.INI || die
171
172         # Icons & menu entries
173         doicon "${WORKDIR}/${PN}.png" || die
174         make_desktop_entry "${PN}" "${fullGameName}" || die
175
176         # Documentation
177         dodoc "${WORKDIR}/docs/"* || die
178
179         # FAQ covering both official and unofficial patched versions.
180         dodoc "${FILESDIR}/${PVR}/FAQ.html" || die
181
182         # README.TXT on all CD-ROMs
183         dodoc "${CDROM_ROOT}/README.TXT" || die
184
185         # Manual on Hasboro CD-ROM
186         if [[ $cdVersion == H1.31 ]]; then
187                 dodoc "${CDROM_ROOT}/Manual/MOO2manual.pdf" || die
188         fi
189
190         prepgamesdirs
191 }
192
193 pkg_postinst() {
194         elog "\
195 A user-level install will be performed the 1st time you run the game. To
196 change your startup options, edit your ~/.moo2/moo2rc file. See
197 file:///usr/share/doc/${PF}/FAQ.html for command-line options.
198 To change your dosbox environment, see the dosbox man page and edit
199 ~/.moo2/dosboxrc.
200 "
201         games_pkg_postinst
202 }