]> gitweb.fluxo.info Git - slackbuilds.git/commitdiff
mrtg: adding mrtg (thanx x-doctor)
authorrhatto <rhatto@370017ae-e619-0410-ac65-c121f96126d4>
Tue, 13 Oct 2009 13:27:40 +0000 (13:27 +0000)
committerrhatto <rhatto@370017ae-e619-0410-ac65-c121f96126d4>
Tue, 13 Oct 2009 13:27:40 +0000 (13:27 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/slackbuilds@2263 370017ae-e619-0410-ac65-c121f96126d4

net/analyzer/mrtg/Manifest [new file with mode: 0644]
net/analyzer/mrtg/mrtg.SlackBuild

diff --git a/net/analyzer/mrtg/Manifest b/net/analyzer/mrtg/Manifest
new file mode 100644 (file)
index 0000000..50df415
--- /dev/null
@@ -0,0 +1,23 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA256
+
+DIST mrtg-2.16.2.tar.gz 1078423 MD5 06de09c0ee0d35a0142afed5b275b4cd RMD160 2d60324f6c3bcd64fcd6b626ec6a36d4d3c92604 SHA1 44f336c79e1418b59f5a25cb5cc03a82f983fdea SHA256 ce9ec97bb6c8f94a8d8bb2d3cfa7e72b73754ed7a1081e7aca1c8cece5ce3385 SHA512 8ab4970c593c472e76137e665632d5d534ae07d03c73e81b91f28f25153f88905f99251cb250e0e7a79f671d8cecd1fb182c8cbf3d77ed8739e1f9ad96bd3823
+MKBUILD mrtg.mkbuild 5037 MD5 b3fd765d46e33e3fb75153b3c2236850 RMD160 b7e4fbecb0490506969e1c2e24c96c9444744401 SHA1 19a7c54a170f230c3513ee6104dfd9ff1567dde4 SHA256 aaede357be3a266b83d34111c620b2ff5fdd0bab06c2e130094d3b61219b3766 SHA512 362858fe1fdb3e421e216fc27f3e566b8695f42747eb4ed80c42973591ea559a73af9d686764212d873c90a06438d795e1005162ed6bd8020893b2e57832982e
+SLACKBUILD mrtg.SlackBuild 7067 MD5 0960ee34a7e45f272435cb93a3e0f691 RMD160 abb56aea935fcc9174475c56f9b2152bc3230efd SHA1 2b7bdc0d0c352c0eef2456e850c1dd917d0f6d4f SHA256 ead0a6ad3d6c3090b7f291425b1c8a3fbd41a25f8101bba048e71f190bed8cc7 SHA512 88eba06a6216cd9c80924e67796ed76c60a22105eb2be2f846900f9837e581b080bf72aca1bccbebceb4a8d2e6b4ac137b01f598c6f70f86dce1393153e3735d
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+iQIcBAEBCAAGBQJK1H+zAAoJEEHL93ESzgeiUXAP+we4eB2j8xsTqxiY+PCUMmB6
+h0NSJWnmi44rMnGkNQGj+0OEWFzN+ZETo9hbL55p9L+jFzS5bNotC+MMuRFB1/vm
+e2xX34CXEvclzbPU3OZRJmElAEwSt8EQmdMAMB0cWQDL2WCkhJgfrzLxHRwyjcMc
+xqIjx+IyDGp49vCt4b9fJoERWAONQsCJotVkQgWEcJo14Ae0YHpvSvs1a4Dlvyzw
+i4VlNKr0wXNHuAHjad41uwfmGob94JOjpUHTFXP7afSNaeRyFa/AfVfb5wQ1VugL
+WeBMgtrj4zQqyyMBxB2NrsTmRx4AmNtb81hWT1JoBuAZPHRs41ml0mOgBUtUgRQr
+xrCaxrkbzn0o41r16+66pNDSb0HyBfYeqVI9dwyU7d+gVY68jsR5Fsfcacs13/wP
+GPxtYq2RvW4gzLNmyt4KdfZaaZCS9+eYgSxjFOz1SUCCG9IgPWgZRk4dpta1hMAe
+YmGzrU5fbewloKGLNTEKPKwdTcpX6YCsnR2ZJ4pzFIHWjUm9ap87FcmAmtMdZUnY
+4dkywoabqq1Vh0mbj7jSzHAHz4aBLEplgGZo8G8xqFt3COZ7IEdL8tyneVwrCq2D
+W12BmJdQmn2kryfibuHXAGr7i3VhNViOHGt/l5Hc3A7bi9RtBONNiGmncxUVfwY5
+Ix2oTVOIZvc4KmxBjOqP
+=6l8L
+-----END PGP SIGNATURE-----
index aefbbc3490a7b450ed9d5ef0cca81c3e0d882113..5dfc18d8692e6f4a22100f1db78c3b1fe497fcbc 100755 (executable)
 #!/bin/bash
 #
-#  mrtg.SlackBuild is free software; you can redistribute it and/or modify it under the
-#  terms of the GNU General Public License as published by the Free Software
-#  Foundation; either version 2 of the License, or any later version.
+#  mrtg.SlackBuild is free software; you can redistribute
+#  it and/or modify it under the terms of the GNU General Public License as
+#  published by the Free Software Foundation; either version 2 of the License,
+#  or any later version.
 #
-#  mrtg.SlackBuild is distributed in the hope that it will be useful, but WITHOUT ANY
-#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-#  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#  mrtg.SlackBuild is distributed in the hope that it will
+#  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+#  Public License for more details.
 #
-#  You should have received a copy of the GNU General Public License along with
-#  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-#  Place - Suite 330, Boston, MA 02111-1307, USA
+#  You should have received a copy of the GNU General Public License along
+#  with this program; if not, write to the Free Software Foundation, Inc.,
+#  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 #
-# Retirado de http://www.brunorusso.eti.br/pacotes/mrtg/mrtg.SlackBuild
-# Pequenas modificacoes por rhatto
+# slackbuild for mrtg, by Silvio Rhatto
+# requires:  
+# tested: mrtg-2.16.2
+# model: generic.mkSlackBuild $Rev: 822 $
 #
 
-cat << EOCAT
-Just remembering, you need the following packages installed:
-
-  gd
-
-EOCAT
-
-if [ "$INTERACT" != "no" ]; then
-  echo "Hit ENTER do continue, Crtl-C to abort"
-  read crap
-else
-  echo sleeping 3 seconds...
-  sleep 3
-fi
-
-CWD="`pwd`"
-
+# Look for slackbuildrc
 if [ -f ~/.slackbuildrc ]; then
   source ~/.slackbuildrc
 elif [ -f /etc/slackbuildrc ]; then
   source /etc/slackbuildrc
 fi
 
-PACKAGE="mrtg"
-VERSION=${VERSION:=2.14.3}
-BUILD=${BUILD:=1rha}
+# Set variables
+CWD="$(pwd)"
+SRC_NAME="mrtg"
+PKG_NAME="mrtg"
 ARCH=${ARCH:=i486}
-SRC_DIR=${SRC:=$CWD}
+SRC_VERSION=${VERSION:=2.16.2}
+PKG_VERSION="$(echo "$SRC_VERSION" | tr '[[:blank:]-]' '_')"
+BUILD=${BUILD:=1rha}
+SRC_DIR=${SRC_DIR:=$CWD}/$PKG_NAME
 TMP=${TMP:=/tmp}
+PKG=${PKG:=$TMP/package-$PKG_NAME}
 REPOS=${REPOS:=$TMP}
+SLACKBUILD_PATH=${SLACKBUILD_PATH:="net/analyzer/mrtg"}
+PREFIX=${PREFIX:=/usr}
+PKG_WORK="$TMP/$SRC_NAME"
+CONF_OPTIONS=${CONF_OPTIONS:="--sysconfdir=/etc"}
+NUMJOBS=${NUMJOBS:=""}
 
-if [ "$ARCH" == "x86_64" ]; then
-  LIBDIR=/usr/lib64
-else
-  LIBDIR=/usr/lib
-fi
+# Set system libraries' path and optmization flags based on $ARCH
+LIBDIR="$PREFIX/lib"
 
-RTOOL="wget"
-PACKAGE_EXT="gz"
-SRC="$PACKAGE-$VERSION.tar.$PACKAGE_EXT"
-URL="http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/$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
-
-# Verifica qual e o tipo de arquitetura e define algumas opcoes de compilacao
 if [ "$ARCH" = "i386" ]; then
-  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
+  SLKCFLAGS="-O2 -march=i386 -mtune=i686"
 elif [ "$ARCH" = "i486" ]; then
-  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
+  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "i686" ]; then
+  SLKCFLAGS="-O2 -march=i686"
 elif [ "$ARCH" = "s390" ]; then
   SLKCFLAGS="-O2"
 elif [ "$ARCH" = "x86_64" ]; then
-  SLKCFLAGS="-O2"
+  SLKCFLAGS="-O2 -fPIC"
+  LIBDIR="$PREFIX/lib64"
+  LDFLAGS="-L/lib64 -L/usr/lib64"
 fi
 
-TMP="$TMP/$PACKAGE"
-PKG="$TMP/package-mrtg"
-rm -rf $TMP
-mkdir -p $PKG
-cd $TMP
-
-tar xvf$tarflag $SRC_DIR/$SRC
-cd mrtg-$VERSION
+# Set error codes (used by 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;     ERROR_VCS=41;       ERROR_MKDIR=42
+ERROR_MANIFEST=43;
+
+# Clean up any leftovers of previous builds
+rm -rf "$PKG_WORK" 2> /dev/null
+rm -rf "$PKG" 2> /dev/null
+
+# Create directories if necessary
+mkdir -p "$SRC_DIR" || exit $ERROR_MKDIR
+mkdir -p "$PKG" || exit $ERROR_MKDIR
+mkdir -p "$REPOS" || exit $ERROR_MKDIR
+mkdir -p "$PKG_WORK" || exit $ERROR_MKDIR
+
+# Dowload source if necessary
+SRC="$SRC_NAME-$VERSION.tar.gz"
+URL="http://oss.oetiker.ch/mrtg/pub/$SRC"
+
+if [ ! -s "$SRC_DIR/$SRC" ] || ! gunzip -t "$SRC_DIR/$SRC" 2> /dev/null; then
+  wget "$URL" -O "$SRC_DIR/$SRC" || exit $ERROR_WGET
+fi
 
-./configure --bindir=/usr/bin --libdir=$LIBDIR --localstatedir=/usr/share \
-            --sharedstatedir=/usr/share --libexecdir=/usr/lib --mandir=/usr/man \
-            --datadir=/usr/share --sysconfdir=/etc
+# Check Manifest file
+if [ -e "$CWD/Manifest" ]; then
+
+  # Manifest signature checking
+  if grep -q -- "-----BEGIN PGP SIGNED MESSAGE-----" $CWD/Manifest; then
+    echo "Checking Manifest signature..."
+    gpg --verify $CWD/Manifest
+    if [ "$?" != "0" ]; then
+      exit $ERROR_MANIFEST
+    fi
+  fi
+
+  MANIFEST_LINES="`grep -E -v "^(MKBUILD|SLACKBUILD)" $CWD/Manifest | wc -l`"
+
+  for ((MANIFEST_COUNT=1; MANIFEST_COUNT <= $MANIFEST_LINES; MANIFEST_COUNT++)); do
+
+    MANIFEST_LINE="`grep -E -v "^(MKBUILD|SLACKBUILD)" $CWD/Manifest | head -n $MANIFEST_COUNT | tail -n 1`"
+    MANIFEST_FILE="`echo $MANIFEST_LINE | awk '{ print $2 }'`"
+    MANIFEST_FILE_TYPE="`echo $MANIFEST_LINE | awk '{ print $1 }'`"
+
+    if [ -e "$SRC_DIR/$MANIFEST_FILE" ]; then
+      MANIFEST_FILE="$SRC_DIR/$MANIFEST_FILE"
+    else
+      MANIFEST_FILE="`find $CWD -name $MANIFEST_FILE`"
+    fi
+
+    if [ ! -e "$MANIFEST_FILE" ] || [ -d "$MANIFEST_FILE" ]; then
+      continue
+    fi
+
+    echo "Checking Manifest for $MANIFEST_FILE_TYPE $MANIFEST_FILE integrity..."
+
+    SIZE_SRC="`wc -c $MANIFEST_FILE | awk '{ print $1 }'`"
+    SIZE_MANIFEST="`echo $MANIFEST_LINE | awk '{ print $3 }'`"
+
+    # Check source code size
+    if [ "$SIZE_SRC" != "$SIZE_MANIFEST" ]; then
+      echo "SIZE Manifest: $SIZE_MANIFEST; SIZE $SRC: $SIZE_SRC"
+      exit $ERROR_MANIFEST
+    else
+      echo "Size match."
+    fi
+
+    # Check source code integrity
+    for ALGO in md5 rmd160 sha1 sha256 sha512; do
+      if [ $ALGO = "rmd160" ]; then
+        ALGO_SRC="`openssl rmd160 $MANIFEST_FILE | awk '{ print $2 }'`"
+      else
+        ALGO_SRC="`"$ALGO"sum $MANIFEST_FILE | awk '{ print $1 }'`"
+      fi
+      ALGO="`echo $ALGO | tr '[:lower:]' '[:upper:]'`"
+      ALGO_MANIFEST=$(echo $MANIFEST_LINE | sed "s/.* $ALGO //" | awk '{ print $1 }')
+      if [ "$ALGO_SRC" != "$ALGO_MANIFEST" ]; then
+        echo "$ALGO Manifest: $ALGO_MANIFEST; $ALGO $SRC: $ALGO_SRC"
+        exit $ERROR_MANIFEST
+      else
+        echo "$ALGO match."
+      fi
+    done
+
+  done
 
-make || exit 32
-make install DESTDIR=$PKG
+else
+  exit $ERROR_MANIFEST
+fi
 
-chown -R root.bin $PKG/usr/bin
-( cd $PKG
-       find . | xargs file | grep ELF \
-       | cut -f 1 -d : | \
-       xargs strip --strip-unneeded
-)
-( cd $PKG/usr/man
-       find . -name "*.?" | xargs gzip -9
+# Untar
+cd "$PKG_WORK"
+tar --no-same-owner --no-same-permissions -xvf "$SRC_DIR/$SRC" || exit $ERROR_TAR
+PKG_SRC="$PWD/`ls -l | awk '/^d/ { print $NF }'`"
+cd "$PKG_SRC"
+
+# Configure
+CFLAGS="$SLKCFLAGS" \
+  CXXFLAGS="$SLKCFLAGS" \
+  ./configure \
+  --prefix="$PREFIX" --libdir="$LIBDIR" $CONF_OPTIONS || exit $ERROR_CONF
+
+# Compile
+make $NUMJOBS || exit $ERROR_MAKE
+
+# Install
+make install DESTDIR="$PKG" || exit $ERROR_INSTALL
+
+# 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
 )
 
-mkdir $PKG/install
-
-cat << EOF > $PKG/install/slack-desc
+# Install documentation
+DOCS="NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING LICENSE SIGNATURE readme.*"
+mkdir -p "$PKG/usr/doc/$PKG_NAME-$PKG_VERSION" || exit $ERROR_MKDIR
+for doc in $DOCS; do
+  if [ -f "$doc" ]; then
+    cp -a $doc "$PKG/usr/doc/$PKG_NAME-$PKG_VERSION"
+  fi
+done
+
+# Add package description (slack-desc)
+mkdir -p "$PKG/install" || exit $ERROR_MKDIR
+cat << EODESC > "$PKG/install/slack-desc"
 # HOW TO EDIT THIS FILE:
-# The "handy ruler" below makes it easier to edit a package description.  Line
+# 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
+# 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------------------------------------------------------|
+    |-----handy-ruler---------------------------------------------------------|
 mrtg: mrtg (Multi Router Grapher)
 mrtg:
 mrtg: The Multi Router Traffic Grapher (MRTG) is an open-source  tool to
@@ -127,17 +207,17 @@ mrtg: containing Web Graphics which provide a LIVE visual representation of
 mrtg: this traffic.
 mrtg:
 mrtg: Check 
-mrtg:      http://www.stat.ee.ethz.ch/mrtg/
+mrtg:   http://oss.oetiker.ch/mrtg/   
 mrtg: to see what it does.
 mrtg:
-EOF
-
-mkdir -p $PKG/etc/mrtg
-cd $PKG
+EODESC
 
-makepkg -l y -c n $REPOS/mrtg-$VERSION-$ARCH-$BUILD.tgz
+# Build the package
+cd "$PKG"
+mkdir -p $REPOS/$SLACKBUILD_PATH
+makepkg -l y -c n "$REPOS/$SLACKBUILD_PATH/$PKG_NAME-$PKG_VERSION-$ARCH-$BUILD.tgz" || exit $ERROR_MKPKG
 
-if [ "$CLEANUP" == "yes" ]; then
-  rm -rf $TMP
+# Delete source and build directories if requested
+if [ "$CLEANUP" == "yes" ] || [ "$1" = "--cleanup" ]; then
+  rm -rf "$PKG_WORK" "$PKG"
 fi
-