xref: /petsc/systems/Apple/iOS/bin/makedmg (revision 70d20fab0f7095dec0e4fad98077378e4133fa8d)
1#!/bin/sh
2#
3# This script makes a Apple Mac OSX dmg from the PETSc iOS 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 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 ${PETSC_DIR}/${PETSC_ARCH}/PETSc.docset tempsource
13cp -r  ${PETSC_DIR}/systems/Apple/iOS/examples tempsource/PETSc-iOS.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-iOS.examples/Basic/Classes
18cp ${PETSC_DIR}/src/snes/examples/tutorials/ex48.c tempsource/PETSc-iOS.examples/Basic/Classes
19sed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-iOS.examples/Basic/Classes/iphoneViewController.m
20cp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-iOS.examples/testopengl/Classes
21cp ${PETSC_DIR}/src/snes/examples/tutorials/ex48.c tempsource/PETSc-iOS.examples/testopengl/Classes
22cp ${PETSC_DIR}/src/sys/classes/draw/examples/tests/ex3.c tempsource/PETSc-iOS.examples/testopengl/Classes
23cp ${PETSC_DIR}/src/sys/classes/draw/examples/tests/ex4.c tempsource/PETSc-iOS.examples/testopengl/Classes
24sed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-iOS.examples/testopengl/Classes/iphoneViewController.m
25sed -i "" s?../../../../../../src/sys/classes/draw/examples/tests/??g tempsource/PETSc-iOS.examples/testopengl/Classes/iphoneViewController.m
26
27
28let size=`du  -c tempsource | tail -1 | cut -f1`
29let size=2*$size
30
31hdiutil create -srcfolder tempsource -volname PETSc -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
32sleep 5
33device=`hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | head -1 | cut -f1`
34echo Created device $device
35sleep 5
36echo '
37   tell application "Finder"
38     tell disk "PETSc"
39           open
40           set current view of container window to icon view
41           set toolbar visible of container window to false
42           set statusbar visible of container window to false
43           make new alias file at container window to POSIX file "/Library/Frameworks" with properties {name:"Copy in PETSc"}
44           make new alias file at container window to POSIX file "/Applications/Xcode.app/Contents/Developer/Documentation/DocSets" with properties {name:"Copy in PETSc.docset"}
45           make new alias file at container window to (path to home folder) with properties {name:"Copy in PETSc-iOS.examples"}
46           eject
47     end tell
48   end tell
49' | osascript
50sleep 8
51sync
52sync
53echo 'Completed osascript'
54#hdiutil detach ${device}
55hdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg
56rm -rf pack.temp.dmg tempsource
57sync
58sleep 2
59hdiutil detach /Volumes/PETSc
60
61#           set the bounds of container window to {400, 100, 885, 630}
62#           set theViewOptions to the icon view options of container window
63#           set icon size of theViewOptions to 72
64#           set arrangement of theViewOptions to not arranged
65