xref: /petsc/systems/Apple/OSX/bin/makedmg (revision feff33ee0b5b037fa8f9f294dede656a2f85cc47)
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#
9d9dc08c3SBarry Smithecho "Creating ${PETSC_DIR}/PETSc-OSX.dmg from frameworks in ${PETSC_DIR}/arch-osx-release and debug/PETSc-OSX and ${PETSC_DIR}/PETSc.docset"
10d9dc08c3SBarry Smithecho "  and examples in ${PETSC_DIR}/systems/Apple/OSX/examples"
11d9dc08c3SBarry Smith
12d9dc08c3SBarry Smithrm -rf pack.temp.dmg tempsource ${PETSC_DIR}/PETSc-OSX.dmg
13e6363104SBarry Smithmkdir tempsource
14d9dc08c3SBarry Smithcp -r ${PETSC_DIR}/arch-osx-release/PETSc-OSX tempsource
15d9dc08c3SBarry Smithcp -r ${PETSC_DIR}/arch-osx-debug/PETSc-OSX tempsource
16d9dc08c3SBarry Smithcp -r ${PETSC_DIR}/PETSc.docset tempsource
17aa489236SBarry Smithcp -r  ${PETSC_DIR}/systems/Apple/OSX/examples tempsource/PETSc-OSX.examples
1803fab7d9SBarry Smith
1903fab7d9SBarry Smith# copy the PETSc source for the examples into the example directories and modify the include to point to them
2003fab7d9SBarry Smith# in the PETSc tree the examples point to the original source elsewhere in the PETSc tree
21aa489236SBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-OSX.examples/PETSc\ command\ line\ example/PETSc\ command\ line\ example
22aa489236SBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-OSX.examples/PETSc\ command\ line\ example/PETSc\ command\ line\ example/main.c
23aa489236SBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-OSX.examples/PETSc\ cocoa\ example/PETSc\ cocoa\ example
24aa489236SBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-OSX.examples/PETSc\ cocoa\ example/PETSc\ cocoa\ example/AppDelegate.m
255c3bfe30SBarry Smith
26e6363104SBarry Smithlet size=`du  -c tempsource | tail -1 | cut -f1`
27e6363104SBarry Smithlet size=2*$size
28e6363104SBarry Smith
29e6363104SBarry Smithhdiutil create -srcfolder tempsource -volname PETSc -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
30e6363104SBarry Smithsleep 5
31e6363104SBarry Smithdevice=`hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | head -1 | cut -f1`
32e6363104SBarry Smithecho Created device $device
331263af9aSBarry Smithsleep 5
34*feff33eeSBarry Smithecho "
35*feff33eeSBarry Smith   tell application \"Finder\"
36*feff33eeSBarry Smith     tell disk \"PETSc\"
37e6363104SBarry Smith           open
38e6363104SBarry Smith           set current view of container window to icon view
39e6363104SBarry Smith           set toolbar visible of container window to false
40e6363104SBarry Smith           set statusbar visible of container window to false
41*feff33eeSBarry Smith           make new alias file at container window to POSIX file \"/Library/Frameworks\" with properties {name:\"Copy in PETSc-OSX\"}
42*feff33eeSBarry Smith           make new alias file at container window to POSIX file \"${HOME}/Library/Developer/Shared/Documentation/DocSets\" with properties {name:\"Copy in PETSc.docset\"}
43*feff33eeSBarry Smith           make new alias file at container window to (path to home folder) with properties {name:\"Copy in PETSc-OSX.examples\"}
44e6363104SBarry Smith           eject
45e6363104SBarry Smith     end tell
46e6363104SBarry Smith   end tell
47*feff33eeSBarry Smith" | osascript
48e6363104SBarry Smithsleep 8
49e6363104SBarry Smithsync
50e6363104SBarry Smithsync
51b0fb1394SBarry Smithecho 'Completed osascript'
52e6363104SBarry Smith#hdiutil detach ${device}
53d9dc08c3SBarry Smithhdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o ${PETSC_DIR}/PETSc-OSX.dmg
54e6363104SBarry Smithrm -rf pack.temp.dmg tempsource
555c3bfe30SBarry Smithsync
565c3bfe30SBarry Smithsleep 2
57a211788bSBarry Smithhdiutil detach /Volumes/PETSc
581263af9aSBarry Smith
591263af9aSBarry Smith#           set the bounds of container window to {400, 100, 885, 630}
601263af9aSBarry Smith#           set theViewOptions to the icon view options of container window
611263af9aSBarry Smith#           set icon size of theViewOptions to 72
621263af9aSBarry Smith#           set arrangement of theViewOptions to not arranged
63