blob: c830eae53a28459a352f3cc6548566ef42d3a507 [file] [log] [blame]
Jack Jansen8806d472003-03-21 23:52:36 +00001#!/bin/sh -e
2#----------------------------------------------------------------------
3# Build MacPython 2.3 and make an Installer package of it
4
5# TODO: Parameterize the versions, builddirs, etc...
6
7# Script configs
Jack Jansena6872b82003-05-07 08:58:11 +00008PYVERSION=2.3b1
Jack Jansen8806d472003-03-21 23:52:36 +00009PYVER=2.3
Jack Jansena6872b82003-05-07 08:58:11 +000010BUILDNUM=1
Jack Jansen8806d472003-03-21 23:52:36 +000011DOCLEANUP=no
12
13PROGDIR="`dirname \"$0\"`"
Jack Jansen57c914c2003-03-22 00:02:23 +000014case x$PROGDIR in
15x|x.) PROGDIR=`pwd` ;;
16x/*) ;;
17*) echo "Please run with a full pathname"
18 exit 1
19 ;;
20esac
21
Jack Jansen8806d472003-03-21 23:52:36 +000022TMPDIR=/tmp/_py
23#TMPDIR=/projects/_py
24
Jack Jansen8806d472003-03-21 23:52:36 +000025INSTALLROOT=$TMPDIR/install
26DMGDIR=$TMPDIR/dmg
27RESOURCEDIR=$PROGDIR/resources
Jack Jansen57c914c2003-03-22 00:02:23 +000028DESTDIR=$TMPDIR/dist
29PYTHONSRC=$PROGDIR/../../..
30WASTEDIR=$PYTHONSRC/../waste
Jack Jansen8806d472003-03-21 23:52:36 +000031
Jack Jansen7006fa12003-06-16 15:12:16 +000032case x$1 in
33x)
34 BUILDROOT=$TMPDIR/build
35 ;;
36*)
37 BUILDROOT=$1
38 ;;
39esac
40
Jack Jansen8806d472003-03-21 23:52:36 +000041# Setup
Jack Jansen7006fa12003-06-16 15:12:16 +000042if [ -e $BUILDROOT ]; then
43 echo Using existing build directory $BUILDROOT
44 CLEANBUILD=no
45else
46 echo Creating clean build directory $BUILDROOT
47 CLEANBUILD=yes
48 mkdir -p $BUILDROOT
49fi
Jack Jansen8806d472003-03-21 23:52:36 +000050rm -rf $DMGDIR
Jack Jansen53e54fd2003-06-17 14:36:54 +000051mkdir $TMPDIR
52chgrp admin $TMPDIR
Jack Jansen8806d472003-03-21 23:52:36 +000053mkdir -p $DMGDIR/root
54
55
56# Configure and build Python
57pushd $BUILDROOT
58
Jack Jansena6872b82003-05-07 08:58:11 +000059# Ask the user whether s/he has edited Welcome.txt
60read -p "Have you updated $RESOURCEDIR/Welcome.txt (Y/n)? " welcome
61
62if [ "$welcome" = "n" -o "$welcome" = "N" ]; then
63 echo "Please do so and retry"
64 exit
65fi
66
Jack Jansen8806d472003-03-21 23:52:36 +000067# Check if we should build and install the docs, but only if it
68# doesn't appear to be done already. TODO: fix this path to be version independent
69if [ ! -e "build/temp.darwin-6.3-Power Macintosh-2.3/build-html/build-html idx" ]; then
70 read -p "Build the Python docs? (y/N)? " builddocs
71fi
72
73# If the filesystem is case-sensitive then "python" will be built, but
74# some parts of the install expect "python.exe which is what is built
75# on a case-insensitive filesystem. Make a link just in case it is
76# needed.
77if [ ! -e python.exe ]; then
78 ln -s python python.exe
79fi
80
81# Make a link to the waste dir so that lib can be found. This allows
82# the PythonIDE to be built
83if [ ! -e waste ]; then
84 ln -s $WASTEDIR waste
85fi
86
Jack Jansen7006fa12003-06-16 15:12:16 +000087$PYTHONSRC/configure -C --enable-framework LDFLAGS=-Wl,-x
Jack Jansen8806d472003-03-21 23:52:36 +000088make
Jack Jansen7006fa12003-06-16 15:12:16 +000089make DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT frameworkinstall
Jack Jansen8806d472003-03-21 23:52:36 +000090
91if [ "$builddocs" = "y" -o "$builddocs" = "Y" ]; then
92 ./python.exe $PYTHONSRC/Mac/OSX/setupDocs.py build
93 echo ""
94 read -p "When the help indexer is done press Enter..." ans
95 ./python.exe $PYTHONSRC/Mac/OSX/setupDocs.py install \
96 --prefix=$INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER
97fi
98
99popd
100
101
102
103# Make the Installer package:
104# First, remove the unix tools as their paths will be wrong. We'll recreate
105# them in the postinstall.
Jack Jansen57c914c2003-03-22 00:02:23 +0000106rm -rf $INSTALLROOT/usr
Jack Jansen8806d472003-03-21 23:52:36 +0000107
108# Next, remove the .pyc/.pyo files
Jack Jansen57c914c2003-03-22 00:02:23 +0000109python $PYTHONSRC/Mac/scripts/zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER
110python $PYTHONSRC/Mac/scripts/zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER/Mac/Tools
Jack Jansen8806d472003-03-21 23:52:36 +0000111
Jack Jansen8806d472003-03-21 23:52:36 +0000112# Finally, build the package...
113rm -rf MacPython-OSX.pkg
Jack Jansen57c914c2003-03-22 00:02:23 +0000114python $PYTHONSRC/Mac/scripts/buildpkg.py \
Jack Jansen8806d472003-03-21 23:52:36 +0000115 --Title=MacPython-OSX \
116 --Version=$PYVERSION-$BUILDNUM \
117 --Description="Python $PYVERSION for Mac OS X, framework based" \
118 --NeedsAuthorization="YES" \
119 --Relocatable="NO" \
120 --InstallOnly="YES" \
121 $INSTALLROOT \
122 $RESOURCEDIR
123
124## --RootVolumeOnly="YES" \
125
126# ...and then make a disk image containing the package.
127mv MacPython-OSX.pkg $DMGDIR/root
Jack Jansena6872b82003-05-07 08:58:11 +0000128cp $RESOURCEDIR/Welcome.txt $DMGDIR/root/README.txt
Jack Jansen57c914c2003-03-22 00:02:23 +0000129$PROGDIR/makedmg $DMGDIR/root $DMGDIR MacPython-OSX-$PYVERSION-$BUILDNUM
Jack Jansen8806d472003-03-21 23:52:36 +0000130
131echo Moving $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM to $DESTDIR
Jack Jansena6872b82003-05-07 08:58:11 +0000132if [ ! -e $DESTDIR ]; then
133 mkdir $DESTDIR
134fi
Jack Jansen8806d472003-03-21 23:52:36 +0000135mv $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM.dmg $DESTDIR
136
137
138# Cleanup build/install dirs
139if [ $DOCLEANUP = yes ]; then
140 echo "Cleaning up..."
Jack Jansen7006fa12003-06-16 15:12:16 +0000141 if [ $CLEANBUILD = yes ]; then
142 rm -rf $BUILDROOT
143 fi
Jack Jansen8806d472003-03-21 23:52:36 +0000144 rm -rf $INSTALLROOT
145 rm -rf $DMGDIR
146else
147 echo "Cleanup is disabled. You should remove these dirs when done:"
Jack Jansen7006fa12003-06-16 15:12:16 +0000148 if [ $CLEANBUILD = yes ]; then
149 echo " $BUILDROOT"
150 fi
Jack Jansen8806d472003-03-21 23:52:36 +0000151 echo " $INSTALLROOT"
152 echo " $DMGDIR"
153fi
Jack Jansen57c914c2003-03-22 00:02:23 +0000154echo "Your installer can be found in $DESTDIR"
Jack Jansen8806d472003-03-21 23:52:36 +0000155