blob: a3f37227453cbe818b700fd3adf0e44a8433a60d [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
51mkdir -p $DMGDIR/root
52
53
54# Configure and build Python
55pushd $BUILDROOT
56
Jack Jansena6872b82003-05-07 08:58:11 +000057# Ask the user whether s/he has edited Welcome.txt
58read -p "Have you updated $RESOURCEDIR/Welcome.txt (Y/n)? " welcome
59
60if [ "$welcome" = "n" -o "$welcome" = "N" ]; then
61 echo "Please do so and retry"
62 exit
63fi
64
Jack Jansen8806d472003-03-21 23:52:36 +000065# Check if we should build and install the docs, but only if it
66# doesn't appear to be done already. TODO: fix this path to be version independent
67if [ ! -e "build/temp.darwin-6.3-Power Macintosh-2.3/build-html/build-html idx" ]; then
68 read -p "Build the Python docs? (y/N)? " builddocs
69fi
70
71# If the filesystem is case-sensitive then "python" will be built, but
72# some parts of the install expect "python.exe which is what is built
73# on a case-insensitive filesystem. Make a link just in case it is
74# needed.
75if [ ! -e python.exe ]; then
76 ln -s python python.exe
77fi
78
79# Make a link to the waste dir so that lib can be found. This allows
80# the PythonIDE to be built
81if [ ! -e waste ]; then
82 ln -s $WASTEDIR waste
83fi
84
Jack Jansen7006fa12003-06-16 15:12:16 +000085$PYTHONSRC/configure -C --enable-framework LDFLAGS=-Wl,-x
Jack Jansen8806d472003-03-21 23:52:36 +000086make
Jack Jansen7006fa12003-06-16 15:12:16 +000087make DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT frameworkinstall
Jack Jansen8806d472003-03-21 23:52:36 +000088
89if [ "$builddocs" = "y" -o "$builddocs" = "Y" ]; then
90 ./python.exe $PYTHONSRC/Mac/OSX/setupDocs.py build
91 echo ""
92 read -p "When the help indexer is done press Enter..." ans
93 ./python.exe $PYTHONSRC/Mac/OSX/setupDocs.py install \
94 --prefix=$INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER
95fi
96
97popd
98
99
100
101# Make the Installer package:
102# First, remove the unix tools as their paths will be wrong. We'll recreate
103# them in the postinstall.
Jack Jansen57c914c2003-03-22 00:02:23 +0000104rm -rf $INSTALLROOT/usr
Jack Jansen8806d472003-03-21 23:52:36 +0000105
106# Next, remove the .pyc/.pyo files
Jack Jansen57c914c2003-03-22 00:02:23 +0000107python $PYTHONSRC/Mac/scripts/zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER
108python $PYTHONSRC/Mac/scripts/zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER/Mac/Tools
Jack Jansen8806d472003-03-21 23:52:36 +0000109
Jack Jansen8806d472003-03-21 23:52:36 +0000110# Finally, build the package...
111rm -rf MacPython-OSX.pkg
Jack Jansen57c914c2003-03-22 00:02:23 +0000112python $PYTHONSRC/Mac/scripts/buildpkg.py \
Jack Jansen8806d472003-03-21 23:52:36 +0000113 --Title=MacPython-OSX \
114 --Version=$PYVERSION-$BUILDNUM \
115 --Description="Python $PYVERSION for Mac OS X, framework based" \
116 --NeedsAuthorization="YES" \
117 --Relocatable="NO" \
118 --InstallOnly="YES" \
119 $INSTALLROOT \
120 $RESOURCEDIR
121
122## --RootVolumeOnly="YES" \
123
124# ...and then make a disk image containing the package.
125mv MacPython-OSX.pkg $DMGDIR/root
Jack Jansena6872b82003-05-07 08:58:11 +0000126cp $RESOURCEDIR/Welcome.txt $DMGDIR/root/README.txt
Jack Jansen57c914c2003-03-22 00:02:23 +0000127$PROGDIR/makedmg $DMGDIR/root $DMGDIR MacPython-OSX-$PYVERSION-$BUILDNUM
Jack Jansen8806d472003-03-21 23:52:36 +0000128
129echo Moving $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM to $DESTDIR
Jack Jansena6872b82003-05-07 08:58:11 +0000130if [ ! -e $DESTDIR ]; then
131 mkdir $DESTDIR
132fi
Jack Jansen8806d472003-03-21 23:52:36 +0000133mv $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM.dmg $DESTDIR
134
135
136# Cleanup build/install dirs
137if [ $DOCLEANUP = yes ]; then
138 echo "Cleaning up..."
Jack Jansen7006fa12003-06-16 15:12:16 +0000139 if [ $CLEANBUILD = yes ]; then
140 rm -rf $BUILDROOT
141 fi
Jack Jansen8806d472003-03-21 23:52:36 +0000142 rm -rf $INSTALLROOT
143 rm -rf $DMGDIR
144else
145 echo "Cleanup is disabled. You should remove these dirs when done:"
Jack Jansen7006fa12003-06-16 15:12:16 +0000146 if [ $CLEANBUILD = yes ]; then
147 echo " $BUILDROOT"
148 fi
Jack Jansen8806d472003-03-21 23:52:36 +0000149 echo " $INSTALLROOT"
150 echo " $DMGDIR"
151fi
Jack Jansen57c914c2003-03-22 00:02:23 +0000152echo "Your installer can be found in $DESTDIR"
Jack Jansen8806d472003-03-21 23:52:36 +0000153