xref: /petsc/systems/Apple/iOS/bin/makedmg (revision c20d77252dee0f9c80fc6f8b1a6f948e11175edb)
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#
9d9dc08c3SBarry Smithecho "Creating ${PETSC_DIR}/PETSc-iOS.dmg from frameworks in ${PETSC_DIR}/arch-ios-simulator/PETSc-iOS and ${PETSC_DIR}/PETSc.docset"
10d9dc08c3SBarry Smithecho "  and examples in ${PETSC_DIR}/systems/Apple/iOS/examples"
11d9dc08c3SBarry Smith
12d9dc08c3SBarry Smithrm -rf pack.temp.dmg tempsource ${PETSC_DIR}/PETSc-iOS.dmg
1370d20fabSBarry Smithmkdir tempsource
14d9dc08c3SBarry Smithcp -r ${PETSC_DIR}/arch-ios-simulator/PETSc-iOS tempsource
15d9dc08c3SBarry 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
20*c4762a1bSJed Browncp ${PETSC_DIR}/src/snes/tutorials/ex19.c tempsource/PETSc-iOS.examples/Basic/Classes
21*c4762a1bSJed Browncp ${PETSC_DIR}/src/snes/tutorials/ex48.c tempsource/PETSc-iOS.examples/Basic/Classes
22*c4762a1bSJed Brownsed -i "" s?../../../../../../src/snes/tutorials/??g tempsource/PETSc-iOS.examples/Basic/Classes/iphoneViewController.m
23*c4762a1bSJed Browncp ${PETSC_DIR}/src/snes/tutorials/ex19.c tempsource/PETSc-iOS.examples/testopengl/Classes
24*c4762a1bSJed Browncp ${PETSC_DIR}/src/snes/tutorials/ex48.c tempsource/PETSc-iOS.examples/testopengl/Classes
25*c4762a1bSJed Browncp ${PETSC_DIR}/src/sys/classes/draw/tests/ex3.c tempsource/PETSc-iOS.examples/testopengl/Classes
26*c4762a1bSJed Browncp ${PETSC_DIR}/src/sys/classes/draw/tests/ex4.c tempsource/PETSc-iOS.examples/testopengl/Classes
27*c4762a1bSJed Brownsed -i "" s?../../../../../../src/snes/tutorials/??g tempsource/PETSc-iOS.examples/testopengl/Classes/iphoneViewController.m
28*c4762a1bSJed Brownsed -i "" s?../../../../../../src/sys/classes/draw/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
39279f676cSBarry Smithecho "
40279f676cSBarry Smith   tell application \"Finder\"
41279f676cSBarry 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
46279f676cSBarry Smith           make new alias file at container window to POSIX file \"/Library/Frameworks\" with properties {name:\"Copy in PETSc-iOS\"}
47279f676cSBarry Smith           make new alias file at container window to POSIX file \"${HOME}/Library/Developer/Shared/Documentation/DocSets\" with properties {name:\"Copy in PETSc.docset\"}
48279f676cSBarry 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
52279f676cSBarry Smith" | osascript
5370d20fabSBarry Smithsleep 8
5470d20fabSBarry Smithsync
5570d20fabSBarry Smithsync
5670d20fabSBarry Smithecho 'Completed osascript'
5770d20fabSBarry Smith#hdiutil detach ${device}
58d9dc08c3SBarry 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