auto-create disk image for p5 from dist.sh

This commit is contained in:
benfry
2005-01-30 22:14:11 +00:00
parent 52dc9b42e8
commit 0182bc6fce
3 changed files with 159 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ then
# old 4 char version.. osx only uses the two chars
#REVISION=`head -c 4 ../../todo.txt`
# a more useful version of head than what's included with osx
#REVISION=`head -c 4 ../../todo.txt | tail -c 2`
SHORT_REVISION=`head -c 4 ../../todo.txt | tail -c 2`
REVISION=`head -c 4 ../../todo.txt`
else
# can't get four bytes of head (osx doesn't support -c)
@@ -102,9 +102,18 @@ find processing -name "CVS" -exec rm -rf {} ';'
# zip it all up for release
#mv processing "Processing $REVISION"
mv processing "processing-$REVISION"
#mv processing "processing-$REVISION"
NICE_FOLDER="Processing $SHORT_REVISION"
DMG_NAME="processing-$REVISION"
mv processing "$NICE_FOLDER"
#stuff -f sitx processing-$REVISION
#WHERE=`pwd`
chmod +x mkdmg
#./mkdmg $WHERE/processing-$REVISION
#./mkdmg processing-$REVISION
./mkdmg "$NICE_FOLDER" "Processing"
mv "$NICE_FOLDER.dmg" "$DMG_NAME.dmg"
# if there is a command line tool to make a dmg from this dir.. hmm

144
build/macosx/mkdmg Executable file
View File

@@ -0,0 +1,144 @@
#!/bin/zsh
# from http://www.kernelthread.com/mac/apme/archive/
# (c) 1994-2005 Amit Singh
# with modifications for p5 build process by fry
PATH=/bin:/sbin:/usr/bin:/usr/sbin
SCRATCH=/tmp/.mkdmg.$$
# Output
#
croak()
{
echo -n "\n$1"
}
# Clean up
#
halt()
{
rm -rf $SCRATCH
# defaults write com.apple.finder ShowRemovableMediaOnDesktop 1
# chkerror
# FINDERPID=`ps -auxwww | grep Finder.app | grep -v grep | awk '{print $2}'`
# chkerror
# kill -HUP $FINDERPID 2>/dev/null >/dev/null
# chkerror
exit 1
}
# Check return status and bail out on error
#
chkerror()
{
if [ $? -ne 0 ]
then
halt
fi
}
main()
{
# Check if exactly one command line argument was specified
#
if [ $ARGC -ne 1 ]
then
echo "usage: mkdmg <file|directory>"
exit 1
fi
# Check if the specified file/directory exists
#
if [ ! -e $1 ]
then
echo "*** $1 does not exist."
exit 1
fi
# changed these around a bit [fry]
DEST=`pwd`
SRC=$DEST/$1
NAME=`basename $SRC`
NAME="$NAME"
VOLNAME=$2
# don't add 'archive' to the end of the name [fry]
#ARCH="$NAME Archive"
ARCH="$NAME"
echo -n "Using source $SRC"
# Change directory to a scratch location
#
cd /tmp
# Create a scratch directory
#
mkdir $SCRATCH
croak "Creating temporary directory $SCRATCH"
# Estimate how much space is needed to archive the file/folder
#
SIZE=`du -s -k $SRC | awk '{print $1}'`
chkerror
SIZE=`expr 5 + $SIZE / 1000`
chkerror
croak "Using $SIZE MB"
# Create a disk image, redirecting all output to /dev/null
#
hdiutil create "$SCRATCH/$ARCH.dmg" -volname "$VOLNAME" -megabytes $SIZE -type SPARSE -fs HFS+ 2>/dev/null >/dev/null
chkerror
croak "$SCRATCH/$ARCH.dmg created"
# Optionally disable display of removable media on Desktop
#
# defaults write com.apple.finder ShowRemovableMediaOnDesktop 0
# chkerror
# FINDERPID=`ps -auxwww | grep Finder.app | grep -v grep | awk '{print $2}'`
# chkerror
# kill -HUP $FINDERPID 2>/dev/null >/dev/null
# chkerror
#
# Mount sparse image
#
hdid $SCRATCH/$ARCH.dmg.sparseimage 2>/dev/null >/dev/null
chkerror
croak "$SCRATCH/$ARCH.dmg.sparseimage attached"
# Find out allocated device
#
DEV=`mount | grep "Volumes/$ARCH" | awk '{print $1}'`
croak "Device in use is $DEV"
# Use ditto to copy everything to the image, preserving resource forks
#
# copy the contents, don't make another folder inside [fry]
ditto -rsrcFork $SRC "/Volumes/$ARCH/$NAME" 2>/dev/null >/dev/null
#ditto -rsrcFork $SRC "/Volumes/$ARCH" 2>/dev/null >/dev/null
chkerror
croak "Copied $SRC to /Volumes/$ARCH/$NAME"
# Detach the disk image
hdiutil detach $DEV 2>/dev/null >/dev/null
chkerror
croak "$DEV detached"
# Compress the image (maximum compression)
hdiutil convert "$SCRATCH/$ARCH.dmg.sparseimage" -format UDZO -o "/tmp/$ARCH.dmg" -imagekey zlib-devel=9 2>/dev/null >/dev/null
chkerror
croak "Disk image successfully compressed"
#croak "/tmp/$ARCH.dmg is ready"
# move the folder to the destination place [fry]
mv /tmp/$ARCH.dmg $DEST/
echo
halt
}
main $1

View File

@@ -19,6 +19,8 @@ X resize box intrudes on the scroller for the console area
X need to set grow boxes intruding to false
X 1.3 version (deprecated): -Dcom.apple.mrj.application.growbox.intrudes=false
X 1.4 version: -Dapple.awt.showGrowBox=false
X add mkdmg script to macosx build process
X could significantly speed things up
X put 'play' on a SwingWorker thread
_ test this on a pc to see how it goes, especially with opengl
@@ -49,6 +51,8 @@ _ need to pay attention to when running from read-only drive
_ reported by brandenberg
_ "p5 will launch from the disk image, but will
_ not draw the sketch name bar doesn't appear"
_ includes preferences.txt option to write to p5 folder first
_ this can be altered by instructors and re-packaged
_ bring back "rename" ?
@@ -538,8 +542,6 @@ DISTRIBUTION / Mac OS X
1 _ right now, typing works, but no caret, no blue highlight
1 _ and on second find run, should instead select all the find string
1 _ so that typing will replace it directly
b _ add mkdmg script to macosx build process
b _ could significantly speed things up
b _ set nice background for disk image on macosx
1 _ test more to see if runtime exceptions are coming through
1 _ track down error in PdeCompiler for message parsing