xref: /petsc/systems/Apple/iOS/bin/makedmg (revision d9dc08c3c4ad86f608e3e00539e955e6b7ec9a29)
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#
9*d9dc08c3SBarry Smithecho "Creating ${PETSC_DIR}/PETSc-iOS.dmg from frameworks in ${PETSC_DIR}/arch-ios-simulator/PETSc-iOS and ${PETSC_DIR}/PETSc.docset"
10*d9dc08c3SBarry Smithecho "  and examples in ${PETSC_DIR}/systems/Apple/iOS/examples"
11*d9dc08c3SBarry Smith
12*d9dc08c3SBarry Smithrm -rf pack.temp.dmg tempsource ${PETSC_DIR}/PETSc-iOS.dmg
1370d20fabSBarry Smithmkdir tempsource
14*d9dc08c3SBarry Smithcp -r ${PETSC_DIR}/arch-ios-simulator/PETSc-iOS tempsource
15*d9dc08c3SBarry Smithcp -r ${PETSC_DIR}/PETSc.docset tempsource
1670d20fabSBarry Smithcp -r  ${PETSC_DIR}/systems/Apple/iOS/examples tempsource/PETSc-iOS.examples
1770d20fabSBarry Smith
1870d20fabSBarry Smith# copy the PETSc source for the examples into the example directories and modify the include to point to them
1970d20fabSBarry Smith# in the PETSc tree the examples point to the original source elsewhere in the PETSc tree
2070d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-iOS.examples/Basic/Classes
2170d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex48.c tempsource/PETSc-iOS.examples/Basic/Classes
2270d20fabSBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-iOS.examples/Basic/Classes/iphoneViewController.m
2370d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex19.c tempsource/PETSc-iOS.examples/testopengl/Classes
2470d20fabSBarry Smithcp ${PETSC_DIR}/src/snes/examples/tutorials/ex48.c tempsource/PETSc-iOS.examples/testopengl/Classes
2570d20fabSBarry Smithcp ${PETSC_DIR}/src/sys/classes/draw/examples/tests/ex3.c tempsource/PETSc-iOS.examples/testopengl/Classes
2670d20fabSBarry Smithcp ${PETSC_DIR}/src/sys/classes/draw/examples/tests/ex4.c tempsource/PETSc-iOS.examples/testopengl/Classes
2770d20fabSBarry Smithsed -i "" s?../../../../../../src/snes/examples/tutorials/??g tempsource/PETSc-iOS.examples/testopengl/Classes/iphoneViewController.m
2870d20fabSBarry Smithsed -i "" s?../../../../../../src/sys/classes/draw/examples/tests/??g tempsource/PETSc-iOS.examples/testopengl/Classes/iphoneViewController.m
2970d20fabSBarry Smith
3070d20fabSBarry Smith
3170d20fabSBarry Smithlet size=`du  -c tempsource | tail -1 | cut -f1`
3270d20fabSBarry Smithlet size=2*$size
3370d20fabSBarry Smith
3470d20fabSBarry Smithhdiutil create -srcfolder tempsource -volname PETSc -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
3570d20fabSBarry Smithsleep 5
3670d20fabSBarry Smithdevice=`hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | head -1 | cut -f1`
3770d20fabSBarry Smithecho Created device $device
3870d20fabSBarry Smithsleep 5
3970d20fabSBarry Smithecho '
4070d20fabSBarry Smith   tell application "Finder"
4170d20fabSBarry Smith     tell disk "PETSc"
4270d20fabSBarry Smith           open
4370d20fabSBarry Smith           set current view of container window to icon view
4470d20fabSBarry Smith           set toolbar visible of container window to false
4570d20fabSBarry Smith           set statusbar visible of container window to false
4689518752SBarry Smith           make new alias file at container window to POSIX file "/Library/Frameworks" with properties {name:"Copy in PETSc-iOS"}
4770d20fabSBarry 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"}
4870d20fabSBarry Smith           make new alias file at container window to (path to home folder) with properties {name:"Copy in PETSc-iOS.examples"}
4970d20fabSBarry Smith           eject
5070d20fabSBarry Smith     end tell
5170d20fabSBarry Smith   end tell
5270d20fabSBarry Smith' | osascript
5370d20fabSBarry Smithsleep 8
5470d20fabSBarry Smithsync
5570d20fabSBarry Smithsync
5670d20fabSBarry Smithecho 'Completed osascript'
5770d20fabSBarry Smith#hdiutil detach ${device}
58*d9dc08c3SBarry Smithhdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o ${PETSC_DIR}/PETSc-iOS.dmg
5970d20fabSBarry Smithrm -rf pack.temp.dmg tempsource
6070d20fabSBarry Smithsync
6170d20fabSBarry Smithsleep 2
6270d20fabSBarry Smithhdiutil detach /Volumes/PETSc
6370d20fabSBarry Smith
6470d20fabSBarry Smith#           set the bounds of container window to {400, 100, 885, 630}
6570d20fabSBarry Smith#           set theViewOptions to the icon view options of container window
6670d20fabSBarry Smith#           set icon size of theViewOptions to 72
6770d20fabSBarry Smith#           set arrangement of theViewOptions to not arranged
68