Skip to content

Commit

Permalink
arpwatch: rebuilt
Browse files Browse the repository at this point in the history
  • Loading branch information
conraid committed Jul 1, 2016
1 parent 7196564 commit f1d8046
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 124 deletions.
2 changes: 1 addition & 1 deletion arpwatch/README
@@ -1,5 +1,5 @@

Slackware Current Repository by Conraid
Slackware Current Repository by Conraid

======================================================================
o edit a package description. Line # up the first '|' above the
Expand Down
170 changes: 66 additions & 104 deletions arpwatch/arpwatch.SlackBuild
Expand Up @@ -2,85 +2,71 @@
#
# Slackware build script for arpwatch
#
# Copyright 2011-2015 Corrado Franco (http://conraid.net)
# Copyright 2011-2016 Corrado Franco (http://conraid.net)
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
# This program 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
# (at your option) any later version, with the following exception:
# the text of the GPL license may be omitted.

# This program 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. Compiling,
# interpreting, executing or merely reading the text of the program
# may result in lapses of consciousness and/or very being, up to and
# including the end of all existence and the Universe as we know it.
# See the GNU General Public License for more details.

# You may have received a copy of the GNU General Public License along
# with this program (most likely, a file named COPYING). If not, see
# <http://www.gnu.org/licenses/>.
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# Latest version of this SlackBuild at https://github.com/conraid/SlackBuilds
#
# 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.
#
# Latest version of this SlackBuild at http://slackers.it/repository
#
# Exit on most errors
set -e
set -eu

# Set variables:
CWD=$(pwd)

PRGNAME=${PRGNAME:-arpwatch}
PKGNAME=$(echo $PRGNAME | tr A-Z a-z)
VERSION=${VERSION:-2.1a15}
PKGVERSION=$(echo $VERSION | tr - _)
BUILD=${BUILD:-3}
PKGNAM=arpwatch
VERSION=2.1a15
BUILD=${BUILD:-4}
TAG=${TAG:-cf}
TMP=${TMP:-/tmp/pkg}
PKG=$TMP/package-$PKGNAME
DOCS="$PKG/usr/doc/$PKGNAME-$PKGVERSION"
PKG=$TMP/package-$PKGNAM
OUTPUT=${OUTPUT:-/tmp}

# Insert document files in this variable
DOCFILES="CHANGES INSTALL README"

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i686 ;;
arm*) ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) ARCH=$( uname -m ) ;;
esac
if [ -z ${ARCH:=""} ]; then
case "$( uname -m )" in
i?86) ARCH=i686 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi

if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC -pipe -fomit-frame-pointer"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi

# Set compiling FLAGS
case "$ARCH" in
i[3-5]86)
SLKCFLAGS="-O2 -march=${ARCH} -mtune=i686"; CHOST="i486"
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
i686)
SLKCFLAGS="-O2 -march=i686 -pipe -fomit-frame-pointer"; CHOST="i486"
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
x86_64)
SLKCFLAGS="-O2 -fPIC -pipe -fomit-frame-pointer"; CHOST="x86_64"
SLKLDFLAGS="-L/lib64 -L/usr/lib64"; LIBDIRSUFFIX="64"
;;
*)
SLKCFLAGS="-O2"; CHOST=$ARCH
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
esac


# Extract source and prepare:
rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP
rm -rf $PRGNAME-$VERSION
tar xvf $CWD/$PRGNAME.tar.gz
cd $PRGNAME-$VERSION
rm -rf $PKGNAM-$VERSION
tar xvf $CWD/$PKGNAM.tar.gz
cd $PKGNAM-$VERSION

# Apply patch. From SBo
patch -p1 -i $CWD/patches/arpwatch-2.1a4-fhs.patch
Expand All @@ -94,13 +80,10 @@ patch -p1 -i $CWD/patches/arpwatch-2.1a15-nolocalpcap.patch
patch -p1 -i $CWD/patches/arpwatch-2.1a15-bogon.patch
patch -p1 -i $CWD/patches/arpwatch-2.1a15-extraman.patch


# Make sure ownerships and permissions are sane:
chown -R root:root .
chmod -R u+w,go+r-w,a-s .

# Configure
LDFLAGS="$SLKLDFLAGS" \
LDFLAGS="-L/usr/lib${LIBDIRSUFFIX}" \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
Expand All @@ -109,63 +92,42 @@ CXXFLAGS="$SLKCFLAGS" \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/man \
--host=$CHOST-slackware-linux \
--build=$CHOST-slackware-linux
--host=$ARCH-slackware-linux \
--build=$ARCH-slackware-linux

# Build and install:
make ARPDIR=/var/lib/$PRGNAME
make ARPDIR=/var/lib/$PKGNAM
mkdir -p $PKG/usr/sbin $PKG/usr/man/man8
make DESTDIR=$PKG install install-man

# Install utility script
cp -a arp2ethers arpfetch massagevendor massagevendor-old \
$PKG/usr/sbin

cp -a arp2ethers arpfetch massagevendor massagevendor-old $PKG/usr/sbin

# Strip binaries:
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
find $PKG | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip -g 2> /dev/null || true

# Compress and link manpages, if any:
if [ -d $PKG/usr/man ]; then
( cd $PKG/usr/man
find -type f -exec gzip -9 {} \;
for i in $(find -type l); do ln -s $(readlink $i).gz $i.gz; rm $i; done
)
find $PKG/usr/man -type f -exec chmod 644 {} \; -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
fi

# Add a documentation directory:
mkdir -p ${DOCS}
for i in ${DOCFILES}; do
if [ -e "${i}" ]; then
if ! [ -L "${i}" ]; then
cp -a "${i}" ${DOCS}
else
cp -LRp "${i}" ${DOCS}
fi
fi;
done

# Add a slackbuild script:
install -Dm644 $CWD/$PKGNAME.SlackBuild $DOCS/$PKGNAME.SlackBuild
mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION
cp -a $DOCFILES $PKG/usr/doc/$PKGNAM-$VERSION || true
cat $CWD/$PKGNAM.SlackBuild > $PKG/usr/doc/$PKGNAM-$VERSION/$PKGNAM.SlackBuild

# Add README for ethercodes
install -Dm644 $CWD/README.ethercodes $DOCS/README.ethercodes
install -Dm644 $CWD/ethercodes.txt $PKG/usr/doc/$PKGNAM-$VERSION/README.ethercodes

# Add dat files
mkdir -p $PKG/var/lib/$PRGNAME
mkdir -p $PKG/var/lib/$PKGNAM
cp -a arp.dat ethercodes.dat d.awk duplicates.awk e.awk euppertolower.awk p.awk \
$PKG/var/lib/$PRGNAME
$PKG/var/lib/$PKGNAM

# Add init script
install -Dm644 $CWD/rc.$PRGNAME $PKG/etc/rc.d/rc.$PRGNAME.new

# Add slack-desc
install -Dm644 $CWD/slack-desc $PKG/install/slack-desc
install -Dm644 $CWD/rc.$PKGNAM $PKG/etc/rc.d/rc.$PKGNAM.new

# Add a doinst.sh
install -Dm644 $CWD/doinst.sh $PKG/install/doinst.sh
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

# Create package:
cd $PKG
/sbin/makepkg -l y -c n $CWD/$PKGNAME-$PKGVERSION-$ARCH-${BUILD}${TAG}.txz
/sbin/makepkg -l y -c n $OUTPUT/$PKGNAM-$VERSION-$ARCH-$BUILD${TAG}.txz
34 changes: 15 additions & 19 deletions arpwatch/doinst.sh
@@ -1,32 +1,28 @@
#!/bin/sh

perm() {
# Keep same perms on file
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ -e $OLD ]; then
cp -a $OLD $NEW.incoming
cat $NEW > $NEW.incoming
mv $NEW.incoming $NEW
else
chmod 0755 $NEW
fi
}

config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
# toss the redundant copy
rm $NEW
# toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}

perm etc/rc.d/rc.arpwatch.new
config etc/rc.d/rc.arpwatch.new

perms() {
# Keep same perms on file
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ -e $OLD ]; then
cp -a $OLD $NEW.incoming
cat $NEW > $NEW.incoming
mv $NEW.incoming $NEW
fi
config $NEW
}

perms etc/rc.d/rc.arpwatch.new
File renamed without changes.

0 comments on commit f1d8046

Please sign in to comment.