source: trunk/dports/emulators/minivmac-devel/Portfile @ 58968

Last change on this file since 58968 was 58968, checked in by ryandesign@…, 11 years ago

minivmac, minivmac-devel: copy the source (3.0.x) or output (3.1.x) disk image in pre-configure, not in extract, so that if configure fails and is reattempted without cleaning the port, we're not also dealing with a possibly corrupted disk image because it wasn't unmounted cleanly from the emulator

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.3 KB
Line 
1# $Id: Portfile 58968 2009-10-07 22:36:45Z ryandesign@macports.org $
2
3PortSystem              1.0
4
5name                    minivmac-devel
6conflicts               minivmac
7set my_name             minivmac
8version                 3.1.2
9revision                1
10categories              emulators aqua
11maintainers             ryandesign
12license                 GPLv2
13homepage                http://minivmac.sourceforge.net/
14use_zip                 yes
15platforms               macosx
16universal_variant       no
17use_parallel_build      yes
18dist_subdir             ${my_name}
19
20description \
21    a Mac 128K, Mac 512K, Mac 512KE, Mac Plus and Mac SE emulator
22
23long_description \
24    Mini vMac is a Macintosh emulator. It emulates the earliest Macs, \
25    from the original Mac 128K (built 1984-85) to the Mac SE (1987-1990). \
26    The default is to emulate a Mac Plus (1986-1990)\; this is also \
27    the best-tested and therefore recommended emulation.
28
29master_sites \
30    sourceforge:${my_name}:minivmac \
31    http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/:apple
32
33distname                                    ${my_name}-${version}
34set my_src                                  ${distname}.src
35set my_src_distfile                         ${my_src}.zip
36set my_bootstrap_distfile                   ${my_name}-3.1.2-umch.bin.tgz
37set my_blanks                               blanks
38set my_blanks_distfile                      ${my_blanks}-0.2.0.zip
39set my_clipin                               clipin-1.1.0
40set my_clipin_distfile                      ${my_clipin}.zip
41set my_icons                                icnsosx-1.0.0
42set my_icons_distfile                       ${my_icons}.zip
43set my_system_disk_container                System_7.0.1.smi
44set my_system_disk_container_distfile       ${my_system_disk_container}.bin
45
46distfiles \
47    ${my_src_distfile}:minivmac \
48    ${my_bootstrap_distfile}:minivmac \
49    ${my_icons_distfile}:minivmac \
50    ${my_clipin_distfile}:minivmac \
51    ${my_blanks_distfile}:minivmac \
52    ${my_system_disk_container_distfile}:apple
53
54extract.only \
55    ${my_src_distfile} \
56    ${my_icons_distfile} \
57    ${my_blanks_distfile} \
58    ${my_clipin_distfile}
59
60checksums \
61    ${my_src_distfile} \
62        md5     e02e2e762c5f9df3451efb71733d75c4 \
63        sha1    b395715983ba651b96ef941e27b0f5e18f624aea \
64        rmd160  186d2672bf3d67f9bf61b0960a157fa36a616f4c \
65    ${my_bootstrap_distfile} \
66        md5     53239cda5f1827fcc00d9254ee1ee9e0 \
67        sha1    d6c16c541d72241cabafcbb94eec7c198e8b1670 \
68        rmd160  f3925e194c59f704f6fac391609ccc72dd12c718 \
69    ${my_icons_distfile} \
70        md5     2af006506de7549be14f94317918d59a \
71        sha1    4ef79bb56b988fedfeb82a8b6cafd8066f5bbab2 \
72        rmd160  cef6d7d7578464538d0042b0d98379ae7f18fab7 \
73    ${my_clipin_distfile} \
74        md5     e094de97d1c6c214a80fb74895124c3e \
75        sha1    725f622ad6681c77e7f9f4a64d05ac1d6a103beb \
76        rmd160  5699b56c8db62b2568c8de88b6d419180b1fb73d \
77    ${my_blanks_distfile} \
78        md5     b16321d0d78048d5ec9b635f4f86b19c \
79        sha1    9b8d7e77bd05633709907f8806d976279d7a20b7 \
80        rmd160  a0784c17c5a5ca2e159762fb836c1c800762b213 \
81    ${my_system_disk_container_distfile} \
82        md5     8a4776350b15b5a516cdf7dd18e27290 \
83        sha1    d4c8b8653de9c7a9b2594dd6126ec7120e3e2e9e \
84        rmd160  89fc3780c9c5d575a8da4068dc810c1f56c70211
85
86depends_extract \
87    port:macutil \
88    port:bsdiff \
89    bin:expect:expect
90
91set my_app_dir          "${applications_dir}/Mini vMac"
92set my_rom_dir          "~/Library/Preferences/Gryphel/mnvm_rom"
93set my_bootstrap_app    "Mini vMac.app"
94set my_rom_file         vMac.ROM
95set my_base_options     "-maintainer MacPorts -homepage http://www.macports.org/ -cl -eol unx -nex"
96set my_archs            {}
97
98options my_variations
99my_variations           {128K}      {-m 128K} \
100                        {512K}      {-m 128K -mem 512K} \
101                        {512Ke}     {-m 512Ke} \
102                        {Plus}      {-m Plus -im 1} \
103                        {SE}        {-m SE} \
104                        {SE FDHD}   {-m SEFDHD} \
105                        {Classic}   {-m Classic}
106
107variant unsupported description {Also build unfinished Macintosh II and IIx emulators} {
108    my_variations-append \
109                        {II}        {-m II -mem 8M -hres 800 -vres 600 -depth 3} \
110                        {IIx}       {-m IIx -mem 8M -hres 800 -vres 600 -depth 3}
111}
112
113# The universal variant is disabled until MacPorts 1.8.2 is released.
114if {0} {
115# To build the bootstrap, use "sudo port install bootstrap=yes".
116# The variant is hidden because it is useful only to the port maintainer.
117if {[tbool bootstrap]} {
118    variant bootstrap conflicts unsupported requires universal description {Build the bootstrap version of Mini vMac} {
119        my_variations   {Bootstrap} {-m Plus -sound 0 -bg 1 -speed a}
120    }
121    default_variants +bootstrap
122}
123
124variant universal {
125    configure.universal_args
126    configure.universal_archs ppc i386
127    set my_archs ${configure.universal_archs}
128}
129}
130if {![variant_exists universal] || ![variant_isset universal]} {
131    switch ${os.arch} {
132        powerpc {
133            configure.build_arch ppc
134        }
135        default {
136            configure.build_arch ${os.arch}
137        }
138    }
139    set my_archs ${configure.build_arch}
140}
141
142pre-fetch {
143    set my_real_rom_dir [exec osascript ${filespath}/readalias.applescript [file normalize ${my_rom_dir}]]
144    if {![file exists ${my_real_rom_dir}/${my_rom_file}] && ![file exists ${my_app_dir}/${my_rom_file}]} {
145        ui_msg "****************************************************************"
146        ui_msg "To build Mini vMac, you will need a ROM file from a Macintosh"
147        ui_msg "Plus or 512Ke. And to run it, you need a ROM file from the type"
148        ui_msg "of Mac you want to emulate. ROM files are not included with this"
149        ui_msg "package because they are copyrighted Apple software."
150        ui_msg "To create a ROM file, download the CopyRoms program from"
151        ui_msg "${homepage}extras/copyroms.html"
152        ui_msg "and transfer it to a real physical early Macintosh that you own."
153        ui_msg "Run the CopyRoms program there, then transfer the ROM file back"
154        ui_msg "to this Mac and put it in ${my_rom_dir}"
155        ui_msg "(which can be an alias or symlink if desired) or"
156        ui_msg "${my_app_dir}."
157        ui_msg "****************************************************************"
158        return -code error "${my_rom_file} not found"
159    }
160}
161
162worksrcdir              stuff
163extract.mkdir           yes
164
165post-extract {
166    # Decode the system disk container image.
167    my_system "sh ${filespath}/demacbinary.sh ${distpath}/${my_system_disk_container_distfile} ${worksrcpath}"
168   
169    # Copy the Disk Tools image from the container image. The binary patchfile applied with bspatch
170    # places an alias of the output disk at System Folder:Preferences:Gryphel:Build:output.
171    set my_system_disk_container_mount [my_attach_disk_image ${worksrcpath}/${my_system_disk_container}]
172    my_system "bspatch '${my_system_disk_container_mount}/Disk Tools.image' '${worksrcpath}/Disk Tools.dsk' '${filespath}/Disk Tools.dsk.bsdiff'"
173    my_detach_disk_image ${my_system_disk_container_mount}
174   
175    # Get a large empty disk image to store the output.
176    my_system "unzip -q ${worksrcpath}/${my_blanks}/hfs24M.zip -d ${worksrcpath}"
177   
178    # Extract the bootstrap version of Mini vMac.
179    my_system "tar -x -z -C ${worksrcpath} -f ${distpath}/${my_bootstrap_distfile}"
180   
181    # Make the data directory, where Mini vMac looks for the files it needs.
182    set my_mnvm_dat "${worksrcpath}/${my_bootstrap_app}/Contents/mnvm_dat"
183    file mkdir ${my_mnvm_dat}
184   
185    # Symlink the ROM file into the data directory.
186    ln -s ${my_app_dir}/${my_rom_file} ${my_mnvm_dat}
187   
188    # Symlink the disk images into the data directory with sequentially-numbered
189    # names so Mini vMac will find them and automatically mount them.
190    ln -s "${worksrcpath}/Disk Tools.dsk" "${my_mnvm_dat}/disk1.dsk"
191    ln -s ${worksrcpath}/${my_src}/${my_src}.dsk "${my_mnvm_dat}/disk2.dsk"
192    ln -s ${worksrcpath}/${my_clipin}/${my_clipin}.dsk "${my_mnvm_dat}/disk3.dsk"
193    ln -s ${worksrcpath}/output.img "${my_mnvm_dat}/disk4.dsk"
194}
195
196pre-configure {
197    # Copy the large blank disk image to store the output.
198    # Use the .img extension so that we can mount it on Mac OS X later.
199    copy -force ${worksrcpath}/hfs24M.DSK ${worksrcpath}/output.img
200   
201    # Unrestrict the permissions on the output disk image so the Build program
202    # can write its output to it.
203    file attributes ${worksrcpath}/output.img -permissions 0777
204   
205    # Build up the combined configure args for all variations.
206    set i 0
207    foreach my_arch ${my_archs} {
208        set my_target [my_arch_to_target ${my_arch}]
209        foreach {my_machine my_variation_options} ${my_variations} {
210            if {${i} > 0} {
211                configure.args-append {\;}
212            }
213            configure.args-append \
214                ${my_base_options} \
215                -t ${my_target} \
216                ${my_variation_options} \
217                -n ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
218            incr i
219        }
220    }
221   
222    # Launch Mini vMac so the configure script can talk to it.
223    my_system "open '${worksrcpath}/${my_bootstrap_app}'"
224}
225
226configure.cmd           osascript
227configure.pre_args      ${filespath}/configure.applescript
228
229build.dir               ${workpath}/variations
230
231post-configure {
232    file mkdir ${build.dir}
233    set my_variation_dirs ""
234    set my_output_disk_mount [my_attach_disk_image ${worksrcpath}/output.img]
235    foreach my_arch ${my_archs} {
236        file mkdir ${build.dir}/${my_arch}
237        set my_target [my_arch_to_target ${my_arch}]
238        foreach {my_machine unused} ${my_variations} {
239            set my_src_dir ${my_output_disk_mount}/${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
240            if {[file isdirectory ${my_src_dir}]} {
241                set my_variation_dir ${my_arch}/${my_machine}
242                set my_variation_dirs "${my_variation_dirs} [strsed ${my_variation_dir} {g/ /\\\\ /}]"
243               
244                # Get the configured source code.
245                file copy ${my_src_dir} ${build.dir}/${my_variation_dir}
246               
247                # Use the right compiler.
248                reinplace "s|gcc|${configure.cc}|g" ${build.dir}/${my_variation_dir}/Makefile
249               
250                # Remove references to SDKs -- the 10.4u SDK is not installed by default on 10.6
251                # and even if you install it manually it does not work here.
252                reinplace -E {s|-isysroot /Developer/SDKs/[^ ]+||g} ${build.dir}/${my_variation_dir}/Makefile
253            }
254        }
255    }
256    my_detach_disk_image ${my_output_disk_mount}
257   
258    # Set up the global Makefile.
259    xinstall ${filespath}/Makefile.in ${build.dir}/Makefile
260    reinplace "s|@SUBDIRS@|${my_variation_dirs}|" ${build.dir}/Makefile
261   
262    # If no variation directoriess were produced by configuration, either the flags we
263    # passed in were bad, or the automation script got out of sync with the emulator;
264    # if the latter, the delays in configure.applescript may need to be adjusted.
265    if {"" == ${my_variation_dirs}} {
266        return -code error "configuration failed!"
267    }
268}
269
270set my_share_dir        ${prefix}/share/${my_name}
271
272post-build {
273    set i 0
274    foreach my_arch ${my_archs} {
275        set my_target [my_arch_to_target ${my_arch}]
276        foreach {my_machine unused} ${my_variations} {
277            if {[variant_exists universal] && [variant_isset universal]} {
278                reinplace "s|${my_target}|umch|" ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Info.plist
279            }
280            if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
281                # To save space, keep only a single copy of the Resources directory.
282                set my_resources_dir ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Resources
283                if {0 == ${i}} {
284                    move ${my_resources_dir} ${build.dir}
285                } else {
286                    delete ${my_resources_dir}
287                }
288                ln -s ${my_share_dir}/Resources ${my_resources_dir}
289            }
290            incr i
291        }
292    }
293   
294    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
295        # Install the prettier icons.
296        eval xinstall -m 644 [glob ${worksrcpath}/${my_icons}/icons/*.icns] ${build.dir}/Resources
297    }
298}
299
300destroot {
301    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
302        # Install the global Resources directory.
303        xinstall -d ${destroot}${my_share_dir}
304        copy ${build.dir}/Resources ${destroot}${my_share_dir}
305    }
306   
307    # Install the programs.
308    foreach my_arch ${my_archs} {
309        if {[variant_exists universal] && [variant_isset universal]} {
310            set my_dest ${workpath}/pre-dest/${my_arch}
311        } else {
312            set my_dest ${destroot}
313        }
314        xinstall -d ${my_dest}${my_app_dir}
315        foreach {my_machine unused} ${my_variations} {
316            copy ${build.dir}/${my_arch}/${my_machine}/minivmac.app \
317                "${my_dest}${my_app_dir}/Mini vMac ${my_machine}.app"
318        }
319    }
320    if {[variant_exists universal] && [variant_isset universal]} {
321        merge ${workpath}/pre-dest
322    }
323}
324
325# Converts normal arch names into Mini vMac target names.
326proc my_arch_to_target {arch} {
327    switch ${arch} {
328        i386 {
329            return imch
330        }
331        ppc {
332            return mach
333        }
334        default {
335            return -code error "unsupported architecture ${arch}"
336        }
337    }
338}
339
340# Mounts a disk image.
341proc my_attach_disk_image {disk_image} {
342    global my_name filespath
343    set mountpoint [mkdtemp "/tmp/${my_name}.XXXXXXXX"]
344    # Use this expect script instead of using hdiutil directly, because the
345    # system disk image has a license agreement we must agree to.
346    my_system "expect ${filespath}/attach.exp '${disk_image}' '${mountpoint}'"
347    return ${mountpoint}
348}
349
350# Unmounts a disk image.
351proc my_detach_disk_image {mountpoint} {
352    my_system "hdiutil detach ${mountpoint} -force"
353    file delete -force ${mountpoint}
354}
355
356proc my_system {cmd} {
357     ui_debug ${cmd}
358     system ${cmd}
359}
360
361livecheck.type          regex
362livecheck.url           ${homepage}beta/index.html
363livecheck.regex         ${my_name}-(\[0-9.\]+)\\.src
Note: See TracBrowser for help on using the repository browser.