aboutsummaryrefslogtreecommitdiff
path: root/patches/mysql/mysql.SlackBuild
blob: 7e5a4c1032a311c2a1651107f2d7abbb80c2c7c6 (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
#!/bin/bash
#
# Build and install MySQL on Slackware
#
# by:  David Cantrell <david@slackware.com>
# Currently maintained by:  Patrick Volkerding <volkerdi@slackware.com>
#
# Small changes by rhatto
#

CWD="`pwd`"

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

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

RTOOL="wget"
PACKAGE_EXT="bz2"
SRC="$PACKAGE-$VERSION.tar.$PACKAGE_EXT"
URL="http://mirror.pacific.net.au/linux/slackware/slackware-10.2/patches/source/mysql/$SRC"

if [ "$PACKAGE_EXT" == "bz2" ]; then
  tarflag="j"
else
  tarflag="z"
fi

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

if [ "$RTOOL" == "wget" ] && [ ! -f "$SRC_DIR/$SRC" ]; then
  wget "$URL" -O "$SRC_DIR/$SRC"
fi

if [ ! -d $TMP ]; then
  mkdir -p $TMP
fi

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

LIBDIR="lib"
if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIR="lib64"
fi

cd $TMP
rm -rf mysql-$VERSION
tar xjvf $SRC_DIR/$SRC
cd mysql-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" CXX=gcc CXXFLAGS="$SLKCFLAGS -felide-constructors -fno-exceptions -fno-rtti" \
./configure \
  --prefix=/usr \
  --libdir=/usr/$LIBDIR
  --with-mysqld-user=mysql \
  --with-unix-socket-path=/var/run/mysql/mysql.sock \
  --localstatedir=/var/lib/mysql \
  --enable-assembler \
  --with-raid \
  --without-debug \
  --enable-thread-safe-client \
  --without-bench \
  --with-extra-charsets=complex \
  --with-vio \
  --with-openssl \
  --program-prefix="" \
  --program-suffix="" \
  $ARCH-slackware-linux
#
# --without-readline

make -j3
make install DESTDIR=$PKG

# Strip ELF objects:
( 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
)

mkdir -p $PKG/etc
( cd support-files
  cp my-huge.cnf my-large.cnf my-medium.cnf my-small.cnf $PKG/etc )

# install docs
mkdir -p $PKG/usr/doc/mysql-$VERSION/Docs
# Don't need the (huge) INSTALL-SOURCE... the source is installed already.
#cp -a COPYING* INSTALL-SOURCE MIRRORS README /usr/doc/mysql-$VERSION
cp -a COPYING* MIRRORS README $PKG/usr/doc/mysql-$VERSION
( cd Docs
  cp -a INSTALL-BINARY *.html *.txt Flags \
     $PKG/usr/doc/mysql-$VERSION/Docs )
# Also too large to justify since the .html version is right there:
rm $PKG/usr/doc/mysql-$VERSION/Docs/manual.txt
find $PKG/usr/doc/mysql-$VERSION -type f -exec chmod 644 {} \;

# this is the directory where databases are stored
mkdir -p $PKG/var/lib/mysql
chown mysql.mysql $PKG/var/lib/mysql
chmod 750 $PKG/var/lib/mysql

# this is where the socket is stored
mkdir -p $PKG/var/run/mysql
chown mysql.mysql $PKG/var/run/mysql
chmod 755 $PKG/var/run/mysql

# Do not include the test suite:
rm -r $PKG/usr/mysql-test

# Add init script:
mkdir -p $PKG/etc/rc.d
# This is intentionally chmod 644.
zcat $CWD/rc.mysqld.gz > $PKG/etc/rc.d/rc.mysqld.new

# Install script:
mkdir -p $PKG/install
zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/install/slack-desc

# Add some handy library symlinks:
if [ -r $PKG/usr/$LIBDIR/mysql/libmysqlclient.so.14 ]; then
  mkdir -p $PKG/usr/$LIBDIR
  ( cd $PKG/usr/$LIBDIR
    rm -f libmysqlclient.so libmysqlclient.so.14
    ln -sf mysql/libmysqlclient.so .
    ln -sf mysql/libmysqlclient.so.14 .
  )
fi
if [ -r $PKG/usr/$LIBDIR/mysql/libmysqlclient_r.so.14 ]; then
  mkdir -p $PKG/usr/$LIBDIR
  ( cd $PKG/usr/$LIBDIR
    rm -f libmysqlclient_r.so libmysqlclient_r.so.14
    ln -sf mysql/libmysqlclient_r.so .
    ln -sf mysql/libmysqlclient_r.so.14 .
  )
fi

# Packaging standards:
chown -R root.bin $PKG/usr/bin
rm -f $PKG/usr/info/dir
gzip -9 $PKG/usr/info/*
gzip -9 $PKG/usr/man/man?/*.?

# Build package:
cd $PKG
makepkg -l y -c n $REPOS/mysql-$VERSION-$ARCH-$BUILD.tgz

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