aboutsummaryrefslogtreecommitdiff
path: root/net/analyzer/rrdtool/rrdtool.SlackBuild
blob: 43d8d8edbb61f25d4f9034fb5ab41f0db8bcfaeb (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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/bin/bash
# Copyright (c) 2006 Eric Hameleers <alien@sox.homeip.net>
# Distributed under the terms of the GNU General Public License, Version 2
# -----------------------------------------------------------------------------
#
# Slackware SlackBuild script 
# ===========================
# By:        Eric Hameleers <alien@sox.homeip.net>
# For:       rrdtool
# URL:       http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/
# Needs:     
# Changelog:
# 1.2.8-1:   18/May/2005 by Eric Hameleers <alien@sox.homeip.net>
#            * Initial build.
# 1.2.12-1:  21/feb/2006 by Eric Hameleers <alien@sox.homeip.net>
#            * Upgrade. The cgilib is no longer needed as of 1.2.12.
# 
# Run 'sh SlackBuild --cleanup' to build a Slackware package.
# The package (.tgz) plus descriptive .txt file are created in /tmp .
# Install using 'installpkg'. 
#
# Small modifications made 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

# --- INIT ---
# Set initial variables:
CWD=`pwd`

if [ "$INTERACT" != "no" ]; then
  echo "Hit ENTER do continue, Crtl-C to abort"
  read crap
else
  echo sleeping 3 seconds...
  sleep 3
fi

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

PACKAGE="rrdtool"
PRGNAM="$PACKAGE"
ARCH=${ARCH:=i486}
VERSION=${VERSION:=1.2.15}
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

if [ "$ARCH" == "x86_64" ]; then
  export LDFLAGS="-L/lib64 -L/usr/lib64"
  LIBDIR=/usr/lib64
else
  LIBDIR=/usr/lib
fi

SRC="$PRGNAM-$VERSION.tar.gz"
URL="http://people.ee.ethz.ch/~oetiker/webtools/$PRGNAM/pub/$SRC"

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

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

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"
fi

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

if [ ! -d $TMP/tmp-$PRGNAM ]; then
  mkdir -p $TMP/tmp-$PRGNAM # location to build the source
fi
if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi

# --- PACKAGE BUILDING ---

echo "++"
echo "|| $PRGNAM-$VERSION"
echo "++"

rm -rf $PKG/*

cd $PKG

# Explode the package framework:
if [ -f $CWD/_$PRGNAM.tar.gz ]; then
  explodepkg $CWD/_$PRGNAM.tar.gz || exit $ERROR_TAR
fi

cd $TMP

# --- TARBALL EXTRACTION,PATCH,MODIFY ---

echo "Extracting the program tarball for $PRGNAM..."
tar xvf $SRC_DIR/${PRGNAM}-${VERSION}.tar.gz || exit $ERROR_TAR

cd ${PRGNAM}-${VERSION}
chown -R root.root .

# --- BUILDING ---

echo Building ...

CPPFLAGS="$SLKCFLAGS"
CFLAGS="$SLKCFLAGS"
export CPPFLAGS CFLAGS
./configure --prefix=/usr \
            --localstatedir=/var \
            --sysconfdir=/etc \
            --libdir=$LIBDIR \
            --enable-perl-site-install \
            2>&1 | tee $TMP/configure-${PRGNAM}.log || exit $ERROR_CONF
make 2>&1 | tee $TMP/make-${PRGNAM}.log || exit $ERROR_MAKE

#
# Install all the needed stuff to the package dir
#
# Use installwatch if available:
which installwatch > /dev/null 2>&1
if [ $? == 0 ]; then
  installwatch -o $TMP/install-${PRGNAM}.log make DESTDIR=$PKG install || exit $ERROR_INSTALL
else
  make DESTDIR=$PKG install 2>&1 |tee $TMP/install-${PRGNAM}.log || exit $ERROR_INSTALL
fi

# unneeded perl stuff
find $PKG/usr/lib/perl5/ -name Bundle -type d | xargs rm -rf
find $PKG/usr/lib/perl5/ -name perllocal.pod | xargs rm -f
find $PKG/usr/lib/perl5/ -name .packlist | xargs rm -f
find $PKG/usr/lib/perl5/ -type f -size 0c | xargs rm -f
# Remove empty directories (assuming two levels of file-less directories)
find $PKG/usr/lib/perl5/ -type d | xargs rmdir 2>/dev/null
find $PKG/usr/lib/perl5/ -type d | xargs rmdir 2>/dev/null

# Screw-uppings
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
mv $PKG/usr/share/rrdtool/examples $PKG/usr/doc/$PRGNAM-$VERSION/
mv $PKG/usr/share/doc/*/html $PKG/usr/doc/$PRGNAM-$VERSION/
rm -rf $PKG/usr/share/doc
mkdir -p $PKG/usr/man/man3/
mv $PKG/usr/share/man/man3/* $PKG/usr/man/man3/
rm -rf $PKG/usr/share/man


# --- DOCUMENTATION ---

DOCS="CHANGES CONTRIBUTORS COPYING COPYRIGHT NEWS NT-BUILD-TIPS.txt \
      README THREADS TODO"

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a $DOCS \
      $PKG/usr/doc/$PRGNAM-$VERSION
chmod -R a-w $PKG/usr/doc/$PRGNAM-$VERSION/*

# Compress the man page(s)
gzip -9f $PKG/usr/man/*/*

# Strip binaries
( 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
)


# --- OWNERSHIP, RIGHTS ---

chmod -R o-w $PKG
chown root:bin $PKG/usr/bin/* $PKG/usr/sbin/* $PKG/bin/* $PKG/sbin/* \
               $PKG/usr/X11R6/bin/* $PKG/opt/kde/bin/* 2>/dev/null


# --- PACKAGE DESCRIPTION ---

mkdir -p $PKG/install

cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

       |-----handy-ruler-----------------------------------------------------|
rrdtool: rrdtool (Time-series data storage and graphing software)
rrdtool:
rrdtool: RRDtool (Round Robin Database Tool) is time-series data storage and
rrdtool: graphing utility created by the author of MRTG. Using RRDtool, you
rrdtool: can write your own MRTG-like tools in a matter minutes with only a
rrdtool: few lines of Perl or shell code.
rrdtool:
rrdtool:
rrdtool:
rrdtool:
rrdtool:
EOF

if [ -f $CWD/doinst.sh ]; then
  cat $CWD/doinst.sh > $PKG/install/doinst.sh
fi


# --- BUILDING ---

# Build the package:
cd $PKG

# mv usr/lib/perl usr/lib/perl5

makepkg --linkadd y --chown n $REPOS/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz \
  2>&1 | tee $TMP/makepkg-${PRGNAM}.log || exit $ERROR_MKPKG
#(cd $REPOS && md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.tgz.md5)
#cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $REPOS/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.txt


# --- CLEANUP ---

# Clean up the extra stuff:
if [ "$CLEANUP" == "yes" ]; then
  rm -rf $TMP
fi