xref: /petsc/systems/Apple/OSX/bin/makedmg (revision aa4892361ede034120d3ec9c0f1ae9a5e8669e5d)
1e6363104SBarry Smith#!/bin/sh
2e6363104SBarry Smith#
3409736cdSBarry Smith# This script makes a Apple Mac OS X dmg from the PETSc framework and docset, see ./makeall
4e6363104SBarry Smith#
5e6363104SBarry Smith# Make sure that "Enable access for assistive devices" is checked in System Preferences>>Universal Access. It is required for the AppleScript to work.
63923b477SBarry Smith#
703fab7d9SBarry Smithhdiutil detach /Volumes/PETSc
803fab7d9SBarry Smith#
9*aa489236SBarry Smithecho "Creating ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg from ${PETSC_DIR}/${PETSC_ARCH}/PETSc-OSX and ${PETSC_DIR}/${PETSC_ARCH}/PETSc.docset"
10e6363104SBarry Smithrm -rf pack.temp.dmg tempsource ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg
11e6363104SBarry Smithmkdir tempsource
12*aa489236SBarry Smithcp -r ${PETSC_DIR}/${PETSC_ARCH}/PETSc-OSX ${PETSC_DIR}/${PETSC_ARCH}/PETSc.docset tempsource
13*aa489236SBarry Smithcp -r  ${PETSC_DIR}/systems/Apple/OSX/examples tempsource/PETSc-OSX.examples
1403fab7d9SBarry Smith
1503fab7d9SBarry Smith# copy the PETSc source for the examples into the example directories and modify the include to point to them
1603fab7d9SBarry Smith# in the PETSc tree the examples point to the original source elsewhere in the PETSc tree
17*aa489236SBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-OSX.examples/PETSc\ command\ line\ example/PETSc\ command\ line\ example
18*aa489236SBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-OSX.examples/PETSc\ command\ line\ example/PETSc\ command\ line\ example/main.c
19*aa489236SBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-OSX.examples/PETSc\ cocoa\ example/PETSc\ cocoa\ example
20*aa489236SBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-OSX.examples/PETSc\ cocoa\ example/PETSc\ cocoa\ example/AppDelegate.m
215c3bfe30SBarry Smith
22e6363104SBarry Smithlet size=`du  -c tempsource | tail -1 | cut -f1`
23e6363104SBarry Smithlet size=2*$size
24e6363104SBarry Smith
25e6363104SBarry Smithhdiutil create -srcfolder tempsource -volname PETSc -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
26e6363104SBarry Smithsleep 5
27e6363104SBarry Smithdevice=`hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | head -1 | cut -f1`
28e6363104SBarry Smithecho Created device $device
291263af9aSBarry Smithsleep 5
30e6363104SBarry Smithecho '
31e6363104SBarry Smith   tell application "Finder"
32e6363104SBarry Smith     tell disk "PETSc"
33e6363104SBarry Smith           open
34e6363104SBarry Smith           set current view of container window to icon view
35e6363104SBarry Smith           set toolbar visible of container window to false
36e6363104SBarry Smith           set statusbar visible of container window to false
37*aa489236SBarry Smith           make new alias file at container window to POSIX file "/Library/Frameworks" with properties {name:"Copy in PETSc-OSX"}
38a211788bSBarry Smith           make new alias file at container window to POSIX file "/Applications/Xcode.app/Contents/Developer/Documentation/DocSets" with properties {name:"Copy in PETSc.docset"}
39*aa489236SBarry Smith           make new alias file at container window to (path to home folder) with properties {name:"Copy in PETSc-OSX.examples"}
40e6363104SBarry Smith           eject
41e6363104SBarry Smith     end tell
42e6363104SBarry Smith   end tell
43e6363104SBarry Smith' | osascript
44e6363104SBarry Smithsleep 8
45e6363104SBarry Smithsync
46e6363104SBarry Smithsync
47b0fb1394SBarry Smithecho 'Completed osascript'
48e6363104SBarry Smith#hdiutil detach ${device}
49e6363104SBarry Smithhdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg
50e6363104SBarry Smithrm -rf pack.temp.dmg tempsource
515c3bfe30SBarry Smithsync
525c3bfe30SBarry Smithsleep 2
53a211788bSBarry Smithhdiutil detach /Volumes/PETSc
541263af9aSBarry Smith
551263af9aSBarry Smith#           set the bounds of container window to {400, 100, 885, 630}
561263af9aSBarry Smith#           set theViewOptions to the icon view options of container window
571263af9aSBarry Smith#           set icon size of theViewOptions to 72
581263af9aSBarry Smith#           set arrangement of theViewOptions to not arranged
59