aboutsummaryrefslogtreecommitdiff
path: root/patches/python/python.SlackBuild
blob: 6de51ff4a1e89cc34b196ea4ae43e293c78e3e57 (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
#!/bin/bash
#
# slackbuild script for python
# got it from ftp://ftp.slackware.com/pub/slackware/slackware-11.0/source/d/python/
# small changes by rhatto at riseup.net
#

if [ -s "slack-required" ]; then
  echo Recomended and required packages for building cairo are:
  cat slack-required | sed -e 's/^/\t/'
  if [ "$INTERACT" != "no" ]; then
    echo If you dont have those installed, press Ctrl-C. Otherwise, hit ENTER.
    read crap
  else
    echo Sleeping 3 seconds...
    sleep 3
  fi
fi

CWD="`pwd`"

if [ -f "/etc/slackbuildrc" ]; then
  source /etc/slackbuildrc
fi

if [ -f "~/.slackbuildrc" ]; then
  source ~/.slackbuildrc
fi

PACKAGE="python"
VERSION=${VERSION:=2.4.4}
ARCH=${ARCH:=i486}
BUILD=${BUILD:=1rha}
SRC_DIR=${SRC:=$CWD}
TMP=${TMP:=/tmp}
REPOS=${REPOS:=$TMP}

# -------  error codes for createpkg  --------------
ERROR_WGET=31;      ERROR_MAKE=32;      ERROR_INSTALL=33
ERROR_MD5=34;       ERROR_CONF=35;      ERROR_HELP=36
ERROR_TAR=37;       ERROR_MKPKG=38;     ERROR_GPG=39
ERROR_PATCH=40

RTOOL="wget"
PACKAGE_EXT="bz2"
SRC="Python-$VERSION.tar.$PACKAGE_EXT"
URL="http://www.python.org/ftp/python/$VERSION/$SRC"
HTML="html-2.4.4.tar.bz2"
HTML_URL="http://www.python.org/ftp/python/doc/$VERSION/$HTML"

SRC_DIR="$SRC_DIR/$PACKAGE"
mkdir -p $SRC_DIR

if [ "$RTOOL" == "wget" ]; then
  if [ ! -f "$SRC_DIR/$SRC" ]; then
    wget "$URL" -O "$SRC_DIR/$SRC" || exit $ERROR_WGET
  fi
  if [ ! -f "$SRC_DIR/$HTML" ]; then
    wget "$HTML_URL" -O "$SRC_DIR/$HTML" || exit $ERROR_WGET
  fi
fi

TMP=$TMP/$PACKAGE
PKG=$TMP/package-$PACKAGE
rm -rf $TMP
mkdir -p $PKG

# Location for Python site-packages:
SITEPK=$PKG/usr/lib/python2.4/site-packages
# same as above without $PKG
TOOLSDIR=/usr/lib/python2.4/site-packages

LIBDIR=/usr/lib

# Normally I don't trust -O3, but it is the Python default so
# I'll assume that in this case it has been well tested.
if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O3 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O3 -march=i486 -mtune=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O3"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O3"
  LIBDIR="/usr/lib64"
fi

cd $TMP
rm -rf Python-$VERSION
tar xjvf $SRC_DIR/Python-$VERSION.tar.bz2 || exit $ERROR_TAR
cd Python-$VERSION
chown -R root:root .
find . -type d -exec chmod 755 {} \;
find . -type f -perm 775 -exec chmod 755 {} \;
find . -type f -perm 664 -exec chmod 644 {} \;
find . -type d -name CVS -exec rm -r {} \;

if [ "$ARCH" == "x86_64" ]; then
  zcat $CWD/Python-2.3.3-dirs.patch.gz | patch -p0 --verbose || exit $ERROR_PATCH # thanks suse
fi

if [ -f "$CWD/$PACKAGE-$VERSION.diff" ]; then
  patch -p1 < $CWD/$PACKAGE-$VERSION.diff || exit $ERROR_PATCH
fi

OPT="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=$LIBDIR \
  --with-ncurses \
  --with-threads \
  --enable-ipv6 \
  --enable-shared || exit $ERROR_CONF
make -j3 || exit $ERROR_MAKE
make install DESTDIR=$PKG || exit $ERROR_INSTALL

# Install some python-demo files:
mkdir -p $PKG/usr/doc/python-$VERSION
cp -a Demo $PKG/usr/doc/python-$VERSION

# We'll install the python-tools under site-packages:
mkdir -p $SITEPK
( cd Tools ; cp -a * $SITEPK )
mkdir -p $PKG/usr/doc/python-$VERSION
mv $SITEPK/README $PKG/usr/doc/python-$VERSION/README.python-tools
( cd $PKG/usr/doc/python-$VERSION
  ln -sf $TOOLSDIR Tools
)
# Make a few useful symlinks:
mkdir -p $PKG/usr/bin
( cd $PKG/usr/bin
  ln -sf /usr/lib/python2.4/site-packages/modulator/modulator.py modulator
  ln -sf /usr/lib/python2.4/site-packages/pynche/pynche pynche
  ln -sf /usr/lib/python2.4/site-packages/i18n/msgfmt.py .
  ln -sf /usr/lib/python2.4/site-packages/i18n/pygettext.py .
)

# Install docs:
mkdir -p $PKG/usr/doc/python-$VERSION
cp -a README $PKG/usr/doc/python-$VERSION
cp -a Misc $PKG/usr/doc/python-$VERSION
( cd $PKG/usr/doc/python-$VERSION ; mkdir html )
( cd $PKG/usr/doc/python-$VERSION/html
  tar xjvf $SRC_DIR/html-$VERSION.tar.bz2
  chown -R root:root .
)
( cd $PKG/usr/bin
  rm -f python
  ln -sf python2.4 python
)
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
gzip -9 $PKG/usr/man/man1/*.?
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
makepkg -l y -c n $REPOS/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz || exit $ERROR_MKPKG

if [ "$CLEANUP" == "yes" ]; then
  rm -rf $TMP
fi