summaryrefslogtreecommitdiffstats
path: root/Mac/OSX/Dist/build
blob: 603012e405b1b733e9ae8dc68767fa92abd78920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/sh -e
#----------------------------------------------------------------------
# Build MacPython 2.4 and make an Installer package of it

# TODO:  Parameterize the versions, builddirs, etc...

# Script configs
PYVERSION=2.4.1
PYVER=2.4
BUILDNUM=1
DOCLEANUP=no

PROGDIR="`dirname \"$0\"`"
case x$PROGDIR in
x|x.) PROGDIR=`pwd` ;;
x/*) ;;
*) echo "Please run with a full pathname"
   exit 1
   ;;
esac

if [ ! -e /usr/bin/python ]; then
	echo "No /usr/bin/python; this script expects to be run on 10.3 only"
	exit 1
fi
vers=`/usr/bin/python -V 2>&1`
if [ "$vers" != "Python 2.3" ]; then
    echo "/usr/bin/python is not version 2.3; this script expects to be run on 10.3 only"
    exit 1
fi

TMPDIR=/tmp/_py
#TMPDIR=/projects/_py

INSTALLROOT=$TMPDIR/install
DMGDIR=$TMPDIR/dmg
RESOURCEDIR=$PROGDIR/resources
DESTDIR=$TMPDIR/dist
PYTHONSRC=$PROGDIR/../../..
WASTEDIR=$PYTHONSRC/../waste

# Check that the Apple Python 2.3 Makefile fixes have been applied on this
# machine
if python $PYTHONSRCDIR/Mac/OSX/fixapplepython23.py -n; then
    :
else
    echo
    echo This installer will also install a fix to Apple-installed 2.3
    echo to make building extensions work in the face of other Pythons.
    echo But this system needs to have that fix to be able to put it in the installer.
    echo
    echo Please run $PYTHONSRCDIR/Mac/OSX/fixapplepython23.py to install the fix.
    exit
fi

case x$1 in
x)
	BUILDROOT=$TMPDIR/build
	;;
*)
	BUILDROOT=$1
	;;
esac

# Setup
if [ -e $BUILDROOT ]; then
	echo Using existing build directory $BUILDROOT
	CLEANBUILD=no
else
	echo Creating clean build directory $BUILDROOT
	CLEANBUILD=yes
	mkdir -p $BUILDROOT
fi
rm -rf $DMGDIR
if [ ! -e $TMPDIR ]; then
	mkdir $TMPDIR
fi
chgrp admin $TMPDIR
mkdir -p $DMGDIR/root


# Configure and build Python
pushd $BUILDROOT

# Ask the user whether s/he has edited Welcome.txt
read -p "Have you updated $RESOURCEDIR/Welcome.txt (Y/n)? " welcome

if [ "$welcome" = "n" -o "$welcome" = "N" ]; then
	echo "Please do so and retry"
	exit
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 -C --enable-framework LDFLAGS=-Wl,-x
make
make DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT frameworkinstall
make DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT frameworkinstallextras

# Install the Makefile fixes
config=System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config
(cd / ; tar cf - $config/Makefile $config/PantherPythonFix) | (cd $INSTALLROOT; tar xf -)

# Unfortunately all the ...MODE arguments above still don't do the trick.
# Cop out, and recursively set everything group-writeable.
chmod -R ug+w $INSTALLROOT

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 -rf $INSTALLROOT/usr

# Next, remove the .pyc/.pyo files
python $PYTHONSRC/Mac/scripts/zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER
python $PYTHONSRC/Mac/scripts/zappycfiles.py $INSTALLROOT/Library/Frameworks/Python.framework/Versions/$PYVER/Mac/Tools

# Finally, build the package...
rm -rf MacPython-OSX.pkg
python $PYTHONSRC/Mac/scripts/buildpkg.py \
    --Title=MacPython-OSX \
    --Version=$PYVERSION-$BUILDNUM \
    --Description="Python $PYVERSION for Mac OS X 10.3, framework based" \
    --NeedsAuthorization="YES" \
    --Relocatable="NO" \
    --InstallOnly="YES" \
    --UseUserMask="NO" \
    $INSTALLROOT \
    $RESOURCEDIR

#    --RootVolumeOnly="YES" \

# ...and then make a disk image containing the package.
mv MacPython-OSX.pkg $DMGDIR/root
cp $RESOURCEDIR/ReadMe.txt $DMGDIR/root/ReadMe.txt
$PROGDIR/makedmg $DMGDIR/root $DMGDIR MacPython-OSX-$PYVERSION-$BUILDNUM

echo Moving $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM to $DESTDIR
if [ ! -e $DESTDIR ]; then
    mkdir $DESTDIR
fi
mv $DMGDIR/MacPython-OSX-$PYVERSION-$BUILDNUM.dmg $DESTDIR


# Cleanup build/install dirs
if [ $DOCLEANUP = yes ]; then
    echo "Cleaning up..."
    if [ $CLEANBUILD = yes ]; then
    	rm -rf $BUILDROOT
    fi
    rm -rf $INSTALLROOT
    rm -rf $DMGDIR
else
    echo "Cleanup is disabled.  You should remove these dirs when done:"
    if [ $CLEANBUILD = yes ]; then
    	echo "          $BUILDROOT"
    fi
    echo "          $INSTALLROOT"
    echo "          $DMGDIR"
fi
echo "Your installer can be found in $DESTDIR"