xref: /petsc/systems/Apple/OSX/bin/makedmg (revision fce0c873789145caee477924bfa4ad26b4cd6ea4)
1#!/bin/sh
2#
3# This script makes a Apple Mac OS X dmg from the PETSc framework and docset, see ./makeall
4#
5# Make sure that "Enable access for assistive devices" is checked in System Preferences>>Universal Access. It is required for the AppleScript to work.
6#
7hdiutil detach /Volumes/PETSc
8#
9echo "Creating ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg from ${PETSC_DIR}/${PETSC_ARCH}/PETSc.framework and ${PETSC_DIR}/${PETSC_ARCH}/PETSc.docset"
10rm -rf pack.temp.dmg tempsource ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg
11mkdir tempsource
12cp -r ${PETSC_DIR}/${PETSC_ARCH}/PETSc.framework ${PETSC_DIR}/${PETSC_ARCH}/PETSc.docset tempsource
13cp -r  ${PETSC_DIR}/systems/Apple/OSX/examples tempsource/PETSc.examples
14
15# copy the PETSc source for the examples into the example directories and modify the include to point to them
16# in the PETSc tree the examples point to the original source elsewhere in the PETSc tree
17cp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc.examples/PETSc\ command\ line\ example/PETSc\ command\ line\ example
18sed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc.examples/PETSc\ command\ line\ example/PETSc\ command\ line\ example/main.c
19cp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc.examples/PETSc\ cocoa\ example/PETSc\ cocoa\ example
20sed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc.examples/PETSc\ cocoa\ example/PETSc\ cocoa\ example/AppDelegate.m
21
22let size=`du  -c tempsource | tail -1 | cut -f1`
23let size=2*$size
24
25hdiutil create -srcfolder tempsource -volname PETSc -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
26sleep 5
27device=`hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | head -1 | cut -f1`
28echo Created device $device
29sleep 5
30echo '
31   tell application "Finder"
32     tell disk "PETSc"
33           open
34           set current view of container window to icon view
35           set toolbar visible of container window to false
36           set statusbar visible of container window to false
37           make new alias file at container window to POSIX file "/Library/Frameworks" with properties {name:"Copy in PETSc.frameworks"}
38           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           make new alias file at container window to (path to home folder) with properties {name:"Copy in PETSc.examples"}
40           eject
41     end tell
42   end tell
43' | osascript
44sleep 8
45sync
46sync
47echo 'Completed osascript'
48#hdiutil detach ${device}
49hdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg
50rm -rf pack.temp.dmg tempsource
51sync
52sleep 2
53hdiutil detach /Volumes/PETSc
54
55#           set the bounds of container window to {400, 100, 885, 630}
56#           set theViewOptions to the icon view options of container window
57#           set icon size of theViewOptions to 72
58#           set arrangement of theViewOptions to not arranged
59