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