xref: /petsc/systems/Apple/iOS/bin/makedmg (revision 895187527d7cad663c5a9c3d9403ca4d70bd63a6)
170d20fabSBarry Smith#!/bin/sh
270d20fabSBarry Smith#
370d20fabSBarry Smith# This script makes a Apple Mac OSX dmg from the PETSc iOS framework and docset, see ./makeall
470d20fabSBarry Smith#
570d20fabSBarry Smith# Make sure that "Enable access for assistive devices" is checked in System Preferences>>Universal Access. It is required for the AppleScript to work.
670d20fabSBarry Smith#
770d20fabSBarry Smithhdiutil detach /Volumes/PETSc
870d20fabSBarry Smith#
970d20fabSBarry Smithecho "Creating ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg from ${PETSC_DIR}/${PETSC_ARCH}/PETSc and ${PETSC_DIR}/${PETSC_ARCH}/PETSc.docset"
1070d20fabSBarry Smithrm -rf pack.temp.dmg tempsource ${PETSC_DIR}/${PETSC_ARCH}/PETSc.dmg
1170d20fabSBarry Smithmkdir tempsource
12*89518752SBarry Smithcp -r ${PETSC_DIR}/${PETSC_ARCH}/PETSc-iOS ${PETSC_DIR}/${PETSC_ARCH}/PETSc.docset tempsource
1370d20fabSBarry Smithcp -r  ${PETSC_DIR}/systems/Apple/iOS/examples tempsource/PETSc-iOS.examples
1470d20fabSBarry Smith
1570d20fabSBarry Smith# copy the PETSc source for the examples into the example directories and modify the include to point to them
1670d20fabSBarry Smith# in the PETSc tree the examples point to the original source elsewhere in the PETSc tree
1770d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-iOS.examples/Basic/Classes
1870d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex48.c tempsource/PETSc-iOS.examples/Basic/Classes
1970d20fabSBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-iOS.examples/Basic/Classes/iphoneViewController.m
2070d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-iOS.examples/testopengl/Classes
2170d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex48.c tempsource/PETSc-iOS.examples/testopengl/Classes
2270d20fabSBarry Smithcp ${PETSC_DIR}/src/sys/classes/draw/examples/tests/ex3.c tempsource/PETSc-iOS.examples/testopengl/Classes
2370d20fabSBarry Smithcp ${PETSC_DIR}/src/sys/classes/draw/examples/tests/ex4.c tempsource/PETSc-iOS.examples/testopengl/Classes
2470d20fabSBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-iOS.examples/testopengl/Classes/iphoneViewController.m
2570d20fabSBarry Smithsed -i "" s?../../../../../../src/sys/classes/draw/examples/tests/??g tempsource/PETSc-iOS.examples/testopengl/Classes/iphoneViewController.m
2670d20fabSBarry Smith
2770d20fabSBarry Smith
2870d20fabSBarry Smithlet size=`du  -c tempsource | tail -1 | cut -f1`
2970d20fabSBarry Smithlet size=2*$size
3070d20fabSBarry Smith
3170d20fabSBarry Smithhdiutil create -srcfolder tempsource -volname PETSc -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
3270d20fabSBarry Smithsleep 5
3370d20fabSBarry Smithdevice=`hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | head -1 | cut -f1`
3470d20fabSBarry Smithecho Created device $device
3570d20fabSBarry Smithsleep 5
3670d20fabSBarry Smithecho '
3770d20fabSBarry Smith   tell application "Finder"
3870d20fabSBarry Smith     tell disk "PETSc"
3970d20fabSBarry Smith           open
4070d20fabSBarry Smith           set current view of container window to icon view
4170d20fabSBarry Smith           set toolbar visible of container window to false
4270d20fabSBarry Smith           set statusbar visible of container window to false
43*89518752SBarry Smith           make new alias file at container window to POSIX file "/Library/Frameworks" with properties {name:"Copy in PETSc-iOS"}
4470d20fabSBarry 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"}
4570d20fabSBarry Smith           make new alias file at container window to (path to home folder) with properties {name:"Copy in PETSc-iOS.examples"}
4670d20fabSBarry Smith           eject
4770d20fabSBarry Smith     end tell
4870d20fabSBarry Smith   end tell
4970d20fabSBarry Smith' | osascript
5070d20fabSBarry Smithsleep 8
5170d20fabSBarry Smithsync
5270d20fabSBarry Smithsync
5370d20fabSBarry Smithecho 'Completed osascript'
5470d20fabSBarry Smith#hdiutil detach ${device}
55*89518752SBarry Smithhdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o ${PETSC_DIR}/${PETSC_ARCH}/PETSc-iOS.dmg
5670d20fabSBarry Smithrm -rf pack.temp.dmg tempsource
5770d20fabSBarry Smithsync
5870d20fabSBarry Smithsleep 2
5970d20fabSBarry Smithhdiutil detach /Volumes/PETSc
6070d20fabSBarry Smith
6170d20fabSBarry Smith#           set the bounds of container window to {400, 100, 885, 630}
6270d20fabSBarry Smith#           set theViewOptions to the icon view options of container window
6370d20fabSBarry Smith#           set icon size of theViewOptions to 72
6470d20fabSBarry Smith#           set arrangement of theViewOptions to not arranged
65