2010-05-12 23:28:50 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Slackware build script for python3
|
2012-11-20 19:03:52 +01:00
|
|
|
|
2017-01-07 18:48:57 +01:00
|
|
|
# Copyright 2012-2017 Audrius Kažukauskas <audrius@neutrino.lt>
|
2012-11-20 19:03:52 +01:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use of this script, with or without modification, is
|
|
|
|
# permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of this script must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
|
|
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2010-05-12 23:28:50 +02:00
|
|
|
|
|
|
|
PRGNAM=python3
|
2017-01-07 18:48:57 +01:00
|
|
|
SRCNAM=Python
|
2017-12-20 12:07:44 +01:00
|
|
|
VERSION=${VERSION:-3.6.4}
|
2017-01-07 18:48:57 +01:00
|
|
|
BRANCH_VERSION=$(echo $VERSION | cut -f 1,2 -d . )
|
2017-03-22 21:23:17 +01:00
|
|
|
BUILD=${BUILD:-1}
|
2010-05-12 23:28:50 +02:00
|
|
|
TAG=${TAG:-_SBo}
|
|
|
|
|
2010-06-04 07:03:33 +02:00
|
|
|
if [ -z "$ARCH" ]; then
|
|
|
|
case "$( uname -m )" in
|
2016-12-28 15:46:00 +01:00
|
|
|
i?86) ARCH=i586 ;;
|
2010-06-04 07:03:33 +02:00
|
|
|
arm*) ARCH=arm ;;
|
|
|
|
*) ARCH=$( uname -m ) ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2010-05-12 23:28:50 +02:00
|
|
|
CWD=$(pwd)
|
|
|
|
TMP=${TMP:-/tmp/SBo}
|
|
|
|
PKG=$TMP/package-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
|
2010-05-13 00:25:24 +02:00
|
|
|
# Don't set any SLKCFLAGS here, or OPT="$SLKCFLAGS" before the ./configure.
|
|
|
|
# Python gets the compile options right without any help.
|
2016-12-28 15:46:00 +01:00
|
|
|
if [ "$ARCH" = "i586" ]; then
|
2010-05-13 00:25:24 +02:00
|
|
|
LIBDIRSUFFIX=""
|
2010-05-12 23:28:50 +02:00
|
|
|
elif [ "$ARCH" = "i686" ]; then
|
2010-05-13 00:25:24 +02:00
|
|
|
LIBDIRSUFFIX=""
|
|
|
|
elif [ "$ARCH" = "x86_64" ]; then
|
|
|
|
LIBDIRSUFFIX="64"
|
2010-06-04 07:03:33 +02:00
|
|
|
else
|
|
|
|
LIBDIRSUFFIX=""
|
2010-05-12 23:28:50 +02:00
|
|
|
fi
|
|
|
|
|
2017-11-02 15:25:44 +01:00
|
|
|
set -e
|
2010-05-13 00:25:24 +02:00
|
|
|
|
2015-10-25 19:43:53 +01:00
|
|
|
# Location for Python site-packages.
|
2017-01-07 18:48:57 +01:00
|
|
|
SITEPK=$PKG/usr/lib${LIBDIRSUFFIX}/python${BRANCH_VERSION}/site-packages
|
2015-10-25 19:43:53 +01:00
|
|
|
# Same as above without $PKG.
|
2017-01-07 18:48:57 +01:00
|
|
|
TOOLSDIR=/usr/lib${LIBDIRSUFFIX}/python${BRANCH_VERSION}/site-packages
|
2010-05-12 23:28:50 +02:00
|
|
|
|
|
|
|
rm -rf $PKG
|
|
|
|
mkdir -p $TMP $PKG $OUTPUT
|
|
|
|
cd $TMP
|
2017-01-07 18:48:57 +01:00
|
|
|
rm -rf $SRCNAM-$VERSION
|
|
|
|
tar xvf $CWD/$SRCNAM-$VERSION.tar.xz
|
|
|
|
cd $SRCNAM-$VERSION
|
2010-06-12 13:07:37 +02:00
|
|
|
|
2013-12-31 00:47:24 +01:00
|
|
|
patch -p1 -i $CWD/patches/python3.readline.set_pre_input_hook.diff
|
2015-10-25 19:43:53 +01:00
|
|
|
# We don't want a large libpython*.a.
|
2013-12-31 00:47:24 +01:00
|
|
|
patch -p1 -i $CWD/patches/python3.no-static-library.diff
|
2010-06-12 13:07:37 +02:00
|
|
|
|
|
|
|
if [ "$ARCH" = "x86_64" ]; then
|
2015-10-25 19:43:53 +01:00
|
|
|
# Install to lib64 instead of lib.
|
2013-12-31 00:47:24 +01:00
|
|
|
patch -p1 -i $CWD/patches/python3.x86_64.diff
|
2010-06-12 13:07:37 +02:00
|
|
|
fi
|
|
|
|
|
2013-02-11 01:32:01 +01:00
|
|
|
# Fix python3 path in cgi.py.
|
|
|
|
sed -i '1s|^#.*/usr/local/bin/python|#!/usr/bin/python3|' Lib/cgi.py
|
|
|
|
|
2016-12-28 15:46:00 +01:00
|
|
|
# If system we're building on already has Python3 with pip in site-packages,
|
|
|
|
# ignore it and install pip anyway.
|
2015-03-01 21:20:28 +01:00
|
|
|
sed -i 's|\("install",\)|\1 "--ignore-installed",|' Lib/ensurepip/__init__.py
|
|
|
|
|
2010-05-12 23:28:50 +02:00
|
|
|
chown -R root:root .
|
2013-11-25 12:23:31 +01:00
|
|
|
find -L . \
|
|
|
|
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
|
|
|
|
-o -perm 511 \) -exec chmod 755 {} \; -o \
|
|
|
|
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
|
2014-10-09 21:26:44 +02:00
|
|
|
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
|
2010-05-12 23:28:50 +02:00
|
|
|
|
|
|
|
./configure \
|
|
|
|
--prefix=/usr \
|
2010-05-13 00:25:24 +02:00
|
|
|
--libdir=/usr/lib${LIBDIRSUFFIX} \
|
2010-05-12 23:28:50 +02:00
|
|
|
--mandir=/usr/man \
|
2010-05-13 00:25:24 +02:00
|
|
|
--docdir=/usr/doc/$PRGNAM-$VERSION \
|
2010-05-12 23:28:50 +02:00
|
|
|
--with-threads \
|
|
|
|
--enable-ipv6 \
|
2010-05-13 00:25:24 +02:00
|
|
|
--enable-shared \
|
2013-02-11 01:32:01 +01:00
|
|
|
--with-system-expat \
|
|
|
|
--with-system-ffi \
|
2017-11-02 15:25:44 +01:00
|
|
|
--enable-loadable-sqlite-extensions \
|
2010-05-13 00:25:24 +02:00
|
|
|
--build=$ARCH-slackware-linux
|
2010-05-12 23:28:50 +02:00
|
|
|
|
2010-06-12 13:07:37 +02:00
|
|
|
make
|
2014-04-13 17:46:28 +02:00
|
|
|
make install DESTDIR=$PKG
|
|
|
|
|
2015-03-01 21:20:28 +01:00
|
|
|
# Restore original ensurepip behaviour.
|
2016-12-28 15:46:00 +01:00
|
|
|
sed -i 's| "--ignore-installed",||' \
|
2017-01-07 18:48:57 +01:00
|
|
|
$PKG/usr/lib${LIBDIRSUFFIX}/python${BRANCH_VERSION}/ensurepip/__init__.py
|
2015-03-01 21:20:28 +01:00
|
|
|
|
2014-04-13 17:46:28 +02:00
|
|
|
# Remove to avoid overwriting a copy from Python2.
|
|
|
|
rm -f $PKG/usr/bin/2to3
|
2010-05-12 23:28:50 +02:00
|
|
|
|
2015-10-25 19:43:53 +01:00
|
|
|
# We'll install the python-tools under site-packages.
|
2010-05-12 23:28:50 +02:00
|
|
|
mkdir -p $SITEPK
|
2010-05-13 00:25:24 +02:00
|
|
|
cp -a Tools/* $SITEPK
|
|
|
|
|
2015-01-06 20:47:01 +01:00
|
|
|
# Remove DOS batch/exe files.
|
|
|
|
find $PKG \( -name '*.exe' -o -name '*.bat' \) -exec rm -f '{}' \;
|
|
|
|
|
|
|
|
# Fix permissions on dynamic libraries.
|
|
|
|
find $PKG -type f -perm 555 -exec chmod 755 '{}' \;
|
2014-04-13 17:46:28 +02:00
|
|
|
|
2015-10-25 19:43:53 +01:00
|
|
|
# Install docs.
|
2014-04-13 17:46:28 +02:00
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
2017-03-22 21:23:17 +01:00
|
|
|
cp -a README.rst LICENSE Misc $PKG/usr/doc/$PRGNAM-$VERSION
|
2014-04-13 17:46:28 +02:00
|
|
|
mv $SITEPK/README $PKG/usr/doc/$PRGNAM-$VERSION/README.python-tools
|
|
|
|
( cd $PKG/usr/doc/$PRGNAM-$VERSION ; ln -sf $TOOLSDIR Tools )
|
2014-05-29 01:24:38 +02:00
|
|
|
if [ -e "$CWD/python-$VERSION-docs-html.tar.bz2" ]; then
|
|
|
|
tar xf $CWD/python-$VERSION-docs-html.tar.bz2
|
|
|
|
mv python-$VERSION-docs-html $PKG/usr/doc/$PRGNAM-$VERSION/html
|
|
|
|
chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION/html
|
|
|
|
fi
|
2010-06-12 13:07:37 +02:00
|
|
|
|
2017-01-07 18:48:57 +01:00
|
|
|
# Fix possible incorrect permissions.
|
|
|
|
( cd $PKG
|
|
|
|
find . -type d -exec chmod 755 "{}" \;
|
|
|
|
find . -perm 640 -exec chmod 644 "{}" \;
|
|
|
|
find . -perm 750 -exec chmod 755 "{}" \;
|
|
|
|
)
|
|
|
|
|
2015-03-01 21:20:28 +01:00
|
|
|
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
|
2010-05-19 08:33:58 +02:00
|
|
|
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
|
2010-05-12 23:28:50 +02:00
|
|
|
|
2010-06-12 13:07:37 +02:00
|
|
|
find $PKG/usr/man -type f -exec gzip -9 {} \;
|
|
|
|
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
|
2010-05-13 00:25:24 +02:00
|
|
|
|
2010-05-12 23:28:50 +02:00
|
|
|
mkdir -p $PKG/install
|
|
|
|
cat $CWD/slack-desc > $PKG/install/slack-desc
|
|
|
|
|
|
|
|
cd $PKG
|
2010-05-13 00:25:24 +02:00
|
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
|