source: npl/internetserver/dhcp/dhcp.SlackBuild.orig @ 892871d

Last change on this file since 892871d was 39a3656, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

dhcpupdate

  • Property mode set to 100644
File size: 5.6 KB
Line 
1#!/bin/bash
2
3# Copyright 2008, 2009, 2010, 2011, 2012, 2017, 2018, 2020, 2021  Patrick J. Volkerding, Sebeka, MN, USA
4# All rights reserved.
5#
6# Redistribution and use of this script, with or without modification, is
7# permitted provided that the following conditions are met:
8#
9# 1. Redistributions of this script must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11#
12#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
13#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
15#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
18#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23cd $(dirname $0) ; CWD=$(pwd)
24
25PKGNAM=dhcp
26# Leave this one .gz as other compressors do not help much and we can keep
27# the original upstream .asc
28VERSION=${VERSION:-$(basename $(echo $PKGNAM-*.tar.gz | cut -f 2- -d -) .tar.gz)}
29BUILD=${BUILD:-1}
30
31PKG_VERSION=$(echo $VERSION | tr - _)
32
33NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}
34
35# Automatically determine the architecture we're building on:
36if [ -z "$ARCH" ]; then
37  case "$( uname -m )" in
38    i?86) export ARCH=i586 ;;
39    arm*) export ARCH=arm ;;
40    # Unless $ARCH is already set, use uname -m for all other archs:
41       *) export ARCH=$( uname -m ) ;;
42  esac
43fi
44
45# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
46# the name of the created package would be, and then exit. This information
47# could be useful to other scripts.
48if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
49  echo "$PKGNAM-$PKG_VERSION-$ARCH-$BUILD.txz"
50  exit 0
51fi
52
53TMP=${TMP:-/tmp}
54PKG=$TMP/package-dhcp
55
56if [ "$ARCH" = "i586" ]; then
57  SLKCFLAGS="-O2 -march=i586 -mtune=i686 -fcommon"
58  LIBDIRSUFFIX=""
59elif [ "$ARCH" = "s390" ]; then
60  SLKCFLAGS="-O2 -fcommon"
61  LIBDIRSUFFIX=""
62elif [ "$ARCH" = "x86_64" ]; then
63  SLKCFLAGS="-O2 -fPIC -fcommon"
64  LIBDIRSUFFIX="64"
65else
66  SLKCFLAGS="-O2 -fcommon"
67  LIBDIRSUFFIX=""
68fi
69
70rm -rf $PKG
71mkdir -p $TMP $PKG
72
73cd $TMP
74rm -rf dhcp-$VERSION
75tar xvf $CWD/dhcp-$VERSION.tar.gz || exit 1
76cd dhcp-$VERSION || exit 1
77
78chown -R root:root .
79find . \
80  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
81  -exec chmod 755 {} \+ -o \
82  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
83  -exec chmod 644 {} \+
84
85# Add PATH setting to /sbin/dhclient-script
86zcat $CWD/dhclient-script.PATH.diff.gz | patch -p1 || exit 1
87
88# Fix paths in manual pages
89sed -i \
90    -e "s,ETCDIR,/etc,g" \
91    -e "s,DBDIR,/var/state/dhcp,g" \
92    -e "s,RUNDIR,/var/run,g" \
93    client/*.{5,8} \
94    server/*.{5,8} \
95    doc/*/*.{5,8}
96
97CFLAGS="$SLKCFLAGS" \
98./configure \
99  --prefix=/usr \
100  --sysconfdir=/etc \
101  --localstatedir=/var \
102  --infodir=/usr/info \
103  --mandir=/usr/man \
104  --libdir=/usr/lib${LIBDIRSUFFIX} \
105  --docdir=/usr/doc/dhcp-$VERSION \
106  --build=$ARCH-slackware-linux \
107  --with-srv-lease-file=/var/state/dhcp/dhcpd.leases \
108  --with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \
109  --with-cli-lease-file=/var/state/dhcp/dhclient.leases \
110  --with-cli6-lease-file=/var/state/dhcp/dhclient6.leases || exit 1
111
112# Default pid dir is still /var/run, so no need to declare it
113
114make $NUMJOBS || make || exit 1
115make install DESTDIR=$PKG || exit 1
116
117# DHCP libraries need not be included, yet.
118rm -rf $PKG/usr/{include,lib${LIBDIRSUFFIX}}
119
120# We need this in /sbin
121mkdir -p $PKG/sbin
122mv $PKG/usr/sbin/dhclient $PKG/sbin
123
124# Install the dhclient-script for linux
125cat client/scripts/linux > $PKG/sbin/dhclient-script
126chmod 700 $PKG/sbin/dhclient-script
127
128# Create the initial *.leases files:
129mkdir -p $PKG/var/state/dhcp
130touch $PKG/var/state/dhcp/dhcpd.leases.new
131touch $PKG/var/state/dhcp/dhcpd6.leases.new
132touch $PKG/var/state/dhcp/dhclient.leases.new
133touch $PKG/var/state/dhcp/dhclient6.leases.new
134
135cat << EOF > $PKG/etc/dhcpd.conf.new
136# dhcpd.conf
137#
138# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
139#
140EOF
141
142cat << EOF > $PKG/etc/dhclient.conf.new
143# dhclient.conf
144#
145# Configuration file for ISC dhclient (see 'man dhclient.conf')
146#
147EOF
148
149# Compress and if needed symlink the man pages:
150if [ -d $PKG/usr/man ]; then
151  ( cd $PKG/usr/man
152    for manpagedir in $(find . -type d -name "man*") ; do
153      ( cd $manpagedir
154        for eachpage in $( find . -type l -maxdepth 1) ; do
155          ln -s $( readlink $eachpage ).gz $eachpage.gz
156          rm $eachpage
157        done
158        gzip -9 *.?
159      )
160    done
161  )
162fi
163
164find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
165  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
166
167mkdir -p $PKG/usr/doc/dhcp-$VERSION/examples
168cp -a \
169  LICENSE README RELNOTES \
170  $PKG/usr/doc/dhcp-$VERSION
171mv $PKG/etc/dhcpd.conf $PKG/etc/dhclient.conf \
172  $PKG/usr/doc/dhcp-$VERSION/examples || true
173
174# If there's a ChangeLog, installing at least part of the recent history
175# is useful, but don't let it get totally out of control:
176if [ -r ChangeLog ]; then
177  DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION)
178  cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog
179  touch -r ChangeLog $DOCSDIR/ChangeLog
180fi
181
182mkdir -p $PKG/install
183cat $CWD/slack-desc > $PKG/install/slack-desc
184zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
185
186cd $PKG
187/sbin/makepkg -l y -c n $TMP/dhcp-$PKG_VERSION-$ARCH-$BUILD.txz
188
Note: See TracBrowser for help on using the repository browser.