diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-21 23:52:36 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-21 23:52:36 (GMT) |
commit | 8806d47aff795338346f24c610382bdcf618c46e (patch) | |
tree | 46bb3be26f1dcf85e37b83bbd494b91860662bc5 /Mac/OSX | |
parent | 5c83bb0f4a53f65fa70c3bbf5ddbfbe88d01bf25 (diff) | |
download | cpython-8806d47aff795338346f24c610382bdcf618c46e.zip cpython-8806d47aff795338346f24c610382bdcf618c46e.tar.gz cpython-8806d47aff795338346f24c610382bdcf618c46e.tar.bz2 |
Tools to build a disk image with a binary installer for MacPython-OSX,
donated by Robin Dunn and the rest of the wxPythonMac crew.
These are the versions from cvs.wxwindows.org as of 22-Mar-03, checked
in for reference.
Diffstat (limited to 'Mac/OSX')
-rw-r--r-- | Mac/OSX/Dist/README.txt | 3 | ||||
-rwxr-xr-x | Mac/OSX/Dist/build | 129 | ||||
-rwxr-xr-x | Mac/OSX/Dist/makedmg | 95 | ||||
-rw-r--r-- | Mac/OSX/Dist/resources/Welcome.txt | 6 | ||||
-rwxr-xr-x | Mac/OSX/Dist/resources/postflight | 67 |
5 files changed, 300 insertions, 0 deletions
diff --git a/Mac/OSX/Dist/README.txt b/Mac/OSX/Dist/README.txt new file mode 100644 index 0000000..89ecd2b --- /dev/null +++ b/Mac/OSX/Dist/README.txt @@ -0,0 +1,3 @@ +This is a set of build scripts and such for MacPython-OSX 2.3 that I +will use until there are standard distributions from Jack. + diff --git a/Mac/OSX/Dist/build b/Mac/OSX/Dist/build new file mode 100755 index 0000000..f684d43 --- /dev/null +++ b/Mac/OSX/Dist/build @@ -0,0 +1,129 @@ +#!/bin/sh -e +#---------------------------------------------------------------------- +# Build MacPython 2.3 and make an Installer package of it + +# TODO: Parameterize the versions, builddirs, etc... + +# Script configs +PYVERSION=2.3a2 +PYVER=2.3 +BUILDNUM=3 +DOCLEANUP=no + +PROGDIR="`dirname \"$0\"`" +TMPDIR=/tmp/_py +#TMPDIR=/projects/_py + +BUILDROOT=$TMPDIR/build +INSTALLROOT=$TMPDIR/install +DMGDIR=$TMPDIR/dmg +RESOURCEDIR=$PROGDIR/resources +DESTDIR=/projects/wx/wxPython/dist +PYTHONSRC=/projects/Python-$PYVERSION +WASTEDIR=/projects/waste + +# Setup +mkdir -p $BUILDROOT +mkdir -p $INSTALLROOT +rm -rf $DMGDIR +mkdir -p $DMGDIR/root + + +# Configure and build Python +pushd $BUILDROOT + +# Check if we should build and install the docs, but only if it +# doesn't appear to be done already. TODO: fix this path to be version independent +if [ ! -e "build/temp.darwin-6.3-Power Macintosh-2.3/build-html/build-html idx" ]; then + read -p "Build the Python docs? (y/N)? " builddocs +fi + +# If the filesystem is case-sensitive then "python" will be built, but +# some parts of the install expect "python.exe which is what is built +# on a case-insensitive filesystem. Make a link just in case it is +# needed. +if [ ! -e python.exe ]; then + ln -s python python.exe +fi + +# Make a link to the waste dir so that lib can be found. This allows +# the PythonIDE to be built +if [ ! -e waste ]; then + ln -s $WASTEDIR waste +fi + +$PYTHONSRC/configure --enable-framework=$INSTALLROOT/Library/Frameworks LDFLAGS=-Wl,-x +make +make frameworkinstall + +if [ "$builddocs" = "y" -o "$builddocs" = "Y" ]; then + ./python.exe $PYTHONSRC/Mac/OSX/setupDocs.py build + echo "" + read -p "When the help indexer is done press Enter..." ans + ./python.exe $PYTHONSRC/Mac/OSX/setupDocs.py install \ + --prefix=$INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER +fi + +popd + + + +# Make the Installer package: +# First, remove the unix tools as their paths will be wrong. We'll recreate +# them in the postinstall. +rm -r $INSTALLROOT/usr + +# Next, remove the .pyc/.pyo files +python $PROGDIR/../zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER + +# Make the welcome message +cat > $RESOURCEDIR/Welcome.txt <<EOF +Welcome! + +This program will install Python $PYVERSION for Mac OS X as a Framework. + +Build number: $BUILDNUM +Build date: `date` +EOF + + +# fix a bug in the IDLE install +IDLERES=$INSTALLROOT/Applications/MacPython-2.3/IDLE.app/Contents/Resources +mv $IDLERES/idlelib/idle $IDLERES + + +# Finally, build the package... +rm -rf MacPython-OSX.pkg +python $PROGDIR/../buildpkg.py \ + --Title=MacPython-OSX \ + --Version=$PYVERSION-$BUILDNUM \ + --Description="Python $PYVERSION for Mac OS X, framework based" \ + --NeedsAuthorization="YES" \ + --Relocatable="NO" \ + --InstallOnly="YES" \ + $INSTALLROOT \ + $RESOURCEDIR + +## --RootVolumeOnly="YES" \ + +# ...and then make a disk image containing the package. +mv MacPython-OSX.pkg $DMGDIR/root +$PROGDIR/../makedmg $DMGDIR/root $DMGDIR MacPython-OSX-$PYVERSION-$BUILDNUM + +echo Moving $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM to $DESTDIR +mv $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM.dmg $DESTDIR + + +# Cleanup build/install dirs +if [ $DOCLEANUP = yes ]; then + echo "Cleaning up..." + rm -rf $BUILDROOT + rm -rf $INSTALLROOT + rm -rf $DMGDIR +else + echo "Cleanup is disabled. You should remove these dirs when done:" + echo " $BUILDROOT" + echo " $INSTALLROOT" + echo " $DMGDIR" +fi + diff --git a/Mac/OSX/Dist/makedmg b/Mac/OSX/Dist/makedmg new file mode 100755 index 0000000..c89be80 --- /dev/null +++ b/Mac/OSX/Dist/makedmg @@ -0,0 +1,95 @@ +#!/usr/bin/perl -w +# +# make disk image from folder +# +# usage: makedmg src dst name +# +# (C)opyright 2002 Frank Vercruesse + + +$hdiUtilExec = "/usr/bin/hdiutil"; +$hdiDrvExec = "/usr/bin/hdid"; +$newfsExec = "/sbin/newfs_hfs"; +$duExec = "/usr/bin/du"; +$dittoExec = "/usr/bin/ditto"; + +if ( $#ARGV != 2 ) { + die "Wrong number of arguments.\nUsage: makedmg src dst name\n"; +} + +&make_dmg( $ARGV[0], $ARGV[1], $ARGV[2]); + + +sub make_dmg +{ + my $src = $_[0]; + my $dst = $_[1]; + my $name = $_[2]; + + # check dirs + if( not -d $dst && -d $src ) { + die "src and dst must be directories\n"; + } + + # calc disk image size + if( not open( MYPIPE, "$duExec -sk \"${src}\" |") ) { + die "couldn't open pipe\n"; + } + (my $dmgsize) = split( /\s+/, <MYPIPE>); + close( MYPIPE); + $dmgsize /= 1024; + $dmgsize = int($dmgsize + 4); + if( $dmgsize < 5 ) { + $dmgsize = 5 + } + + # create disk image + system "cd \"$dst\"; $hdiUtilExec create -megabytes $dmgsize -ov \"_${name}\""; + if( $? ) { die "couldn't create disk image\n"; } + + # format disk image + if( not open( MYPIPE, "cd \"$dst\"; $hdiDrvExec -nomount \"_${name}.dmg\" |") ) { + die "couldn't open pipe\n"; + } + (my $dev) = split( /\t/, <MYPIPE>); + $dev =~ s/^(.*\S)\s*$/$1/; + my( $part, $raw, $pname); + while( <MYPIPE> ) { + ($part,$pname) = split /\t/; + if( $pname =~ m/^Apple_HFS/ ) { + $part =~ s/^\s*(.*\S)\s*$/$1/; + $raw = $part; + $raw =~ s/^(\/dev\/)(.+)/$1r$2/; + last; + } + } + close( MYPIPE); + system "cd \"$dst\" ; $newfsExec -v \"$name\" $raw"; + if( $? ) { system "$hdiUtilExec eject $dev"; die "couldn't format disk image\n"; } + system "$hdiUtilExec eject $dev"; + if( $? ) { die "couldn't eject disk image\n"; } + + # copy files + if( not open( MYPIPE, "cd \"$dst\"; $hdiDrvExec \"_${name}.dmg\" |") ) { + die "couldn't open pipe\n"; + } + ($dev) = split( /\t/, <MYPIPE>); + $dev =~ s/^(.*\S)\s*$/$1/; + my $vname; + while( <MYPIPE> ) { + ($part,$pname,$vname) = split /\t/; + if( $pname =~ m/^Apple_HFS/ ) { + $vname =~ s/^(.*\S)\s*$/$1/; + last; + } + } + close( MYPIPE); + system "$dittoExec \"${src}\" \"${vname}\""; + if( $? ) { system "$hdiUtilExec eject $dev"; die "couldn't copy files\n"; } + system "$hdiUtilExec eject $dev"; + if( $? ) { die "couldn't eject disk image\n"; } + + # convert disk image + system "cd \"$dst\"; $hdiUtilExec convert \"_${name}.dmg\" -format UDCO -o \"${name}\""; + if( $? ) { die "couldn't convert disk image\n"; } +} diff --git a/Mac/OSX/Dist/resources/Welcome.txt b/Mac/OSX/Dist/resources/Welcome.txt new file mode 100644 index 0000000..9ecb080 --- /dev/null +++ b/Mac/OSX/Dist/resources/Welcome.txt @@ -0,0 +1,6 @@ +Welcome! + +This program will install Python 2.3a2 for Mac OS X as a Framework. + +Build number: 3 +Build date: Thu Mar 20 18:54:52 PST 2003 diff --git a/Mac/OSX/Dist/resources/postflight b/Mac/OSX/Dist/resources/postflight new file mode 100755 index 0000000..25c12c1 --- /dev/null +++ b/Mac/OSX/Dist/resources/postflight @@ -0,0 +1,67 @@ +#!/bin/sh +#---------------------------------------------------------------------- +# Create the unix tools and compile the .py files after Python has been +# installed. +#---------------------------------------------------------------------- + +PYVER=2.3 + +PKG=$1 +DEST=$2 + + +# if destination is / then use usr/local/bin, otherwise just bin +if [ "$DEST" = "/" ]; then + TOOLDIR=/usr/local/bin + DEST= +else + TOOLDIR=$DEST/bin +fi + +# Make sure the dir exists +mkdir -p $TOOLDIR + +# Make some links to the python executable +if [ -e $TOOLDIR/python$PYVER ]; then + rm $TOOLDIR/python$PYVER +fi +ln -fs $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python $TOOLDIR/python$PYVER + +if [ -e $TOOLDIR/python ]; then + rm $TOOLDIR/python +fi +ln -fs python$PYVER $TOOLDIR/python + + +# make the pythonw script +cat > $TOOLDIR/pythonw <<EOF +#!/bin/sh +exec "$DEST/Library/Frameworks/Python.framework/Versions/$PYVER/Resources/Python.app/Contents/MacOS/python" "\$@" +EOF +chmod +x $TOOLDIR/pythonw + + +# Compile the .py files in the Python library to .pyc's and then .pyo's +$TOOLDIR/python -Wi -tt \ + $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/compileall.py \ + -x badsyntax -x site-packages $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER + +$TOOLDIR/python -Wi -tt -O \ + $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/compileall.py \ + -x badsyntax -x site-packages $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER + + +# Make the site-packages and other dirs writable by the admin. +for d in $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/site-packages \ + $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/bin \ + $DEST/Applications/MacPython-$PYVER; do + chgrp -R admin $d + chmod -R g+w $d +done + + +# The link in the app bundles needs updated. +for app in BuildApplet IDLE PackageManager PythonIDE; do + ln -s $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/Resources/Python.app/Contents/MacOS/python \ + $DEST/Applications/MacPython-$PYVER/$app.app/Contents/MacOS +done |