wxWidgets/wxPython/distrib/mac/_buildPython
Robin Dunn 2eb31f8b19 More build/distrib tweaks
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16473 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-08-12 21:30:02 +00:00

163 lines
3.8 KiB
Bash
Executable File

#!/bin/sh -e
#
# Create a MachoPython package from the currently installed verison
# and put it on a disk image
#
PYVER=2.2
curDir=`pwd`
progDir="`dirname \"$0\"`"
defDstPath="/projects/wx/wxPython/dist"
pkgName="MachoPython"
version=2.2.1-4
dmgRoot="dmg-root"
pkgRoot="pkg-root"
sitePkgDir="$pkgRoot/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/site-packages"
pythonExec="python$PYVER"
makePkgExec="./makepkg"
makeDmgExec="./makedmg"
usage() {
echo `basename $0`: ERROR: $* 1>&2
echo usage: `basename $0` '[-d dir]' 1>&2
exit 1
}
quotemeta() {
# probably not quite correct, but seems to work
echo "$1" | sed -e 's/\([^a-zA-z0-9.,--;_/]\)/\\\1/g'
}
msg()
{
echo "---------------------------------------------"
echo $@
}
msgdo() {
echo "--> " $@
$@
}
user=$1
shift
dstPath=
while :; do
case "$1" in
-d) shift; dstPath="$1";;
-*) usage "bad argument $1";;
*) break;;
esac
shift
done
#-----------------------------------
msg check and prepare build directories
if ! test "$dstPath"; then
dstPath=$defDstPath
fi
if ! test -d "$dstPath"; then
msgdo mkdir -p -m 775 "$dstPath"
msgdo chown ${user}:staff "$dstPath"
fi
temp="tmp$$"
if test -e "$dstPath/$temp"; then
msgdo rm -rf "$dstPath/$temp"
fi
msgdo mkdir -m 775 "$dstPath/$temp"
if test -e "$dstPath/$temp/$pkgRoot"; then
msgdo rm -rf "$dstPath/$temp/$pkgRoot"
fi
msgdo mkdir -m 1775 "$dstPath/$temp/$pkgRoot"
msgdo chown root:admin "$dstPath/$temp/$pkgRoot"
if test -e "$dstPath/$temp/$dmgRoot"; then
msgdo rm -rf "$dstPath/$temp/$dmgRoot"
fi
msgdo mkdir -p -m 775 "$dstPath/$temp/$dmgRoot"
msgdo chown $user:staff "$dstPath/$temp/$dmgRoot"
#-----------------------------------
msg Copying files to package build dir
for d in Applications/Python.app Library/Frameworks/Python.framework; do
msgdo mkdir -p -m 755 $dstPath/$temp/$pkgRoot/$d
msgdo cp -pR /$d/* $dstPath/$temp/$pkgRoot/$d
done
msgdo mkdir -p -m 755 $dstPath/$temp/$pkgRoot/usr/local/bin
msgdo cd $dstPath/$temp/$pkgRoot/usr/local/bin
for f in pydoc python python$PYVER; do
msgdo ln -s ../../../Library/Frameworks/Python.framework/Versions/Current/bin/$f .
done
cat > pythonw <<EOF
#!/bin/sh
exec /Applications/Python.app/Contents/MacOS/python \$@
EOF
chmod +x pythonw
cd $curDir
#-----------------------------------
msg Removing locally installed extension modules
msgdo cd $dstPath/$temp/$sitePkgDir
for f in *; do
if [ $f != README ]; then
msgdo rm -r $f
fi
done
for f in Numeric numarray; do
rm -r $dstPath/$temp/$pkgRoot/Library/Frameworks/Python.framework/Versions/$PYVER/include/python$PYVER/$f
done
cd $curDir
#-----------------------------------
msg Adjusting ownership and permission
for d in Applications Library; do
msgdo chown -R root:admin "$dstPath/$temp/$pkgRoot/$d"
msgdo chmod -R g+w "$dstPath/$temp/$pkgRoot/$d"
done
msgdo chown -R root:wheel "$dstPath/$temp/$pkgRoot/usr"
#-----------------------------------
msg making installer package
msgdo cp -pR "$progDir/resourcesPython" "$dstPath/$temp/"
msgdo mv "$dstPath/$temp/resourcesPython" "$dstPath/$temp/resources"
msgdo cp $progDir/$pkgName.info $progDir/$pkgName-$version.info
msgdo cd "$progDir"
msgdo "$makePkgExec" $dstPath/$temp/$pkgRoot $pkgName-$version.info -d $dstPath/$temp/$dmgRoot -r $dstPath/$temp/resources
msgdo chown -R ${user}:staff $dstPath/$temp/$dmgRoot/$pkgName-$version.pkg
cd $curDir
#-----------------------------------
msg making disk image
msgdo cd "$progDir"
msgdo "$makeDmgExec" $dstPath/$temp/$dmgRoot $dstPath/$temp $pkgName-$version
dmgName="$pkgName-$version"
msgdo mv "$dstPath/$temp/$pkgName-$version.dmg" "$dstPath/$dmgName.dmg"
msgdo chown ${user}:staff "$dstPath/$dmgName.dmg"
cd $curDir
#-----------------------------------
msg cleaning up
msgdo rm $progDir/$pkgName-$version.info
msgdo rm -rf "$dstPath/$temp"