#!/bin/bash # Slackware build script for haproxy # Copyright 2018 T3slider # All rights reserved. # # Copyright 2022 Badchay # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 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. cd $(dirname $0) ; CWD=$(pwd) PRGNAM=haproxy VERSION=${VERSION:-2.7.6} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} PKGTYPE=${PKGTYPE:-tgz} if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi # If the variable PRINT_PACKAGE_NAME is set, then this script will report what # the name of the created package would be, and then exit. This information # could be useful to other scripts. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" exit 0 fi TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} 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" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2" LIBDIRSUFFIX="" fi # This should work with Slackware-provided kernels, but you may wish to # use 'generic' instead TARGET=${TARGET:-linux-glibc} # Include lua support? (Requires lua) LUA=${LUA:-no} # Perl Compatible Regular Expressions version 2 is enabled by default. # You might want to use libpcre1 and/or JIT-enabled version instead. PCRE=${PCRE:-PCRE2} # Include QUIC (HTTP/3) support? (experimental). # This requires QUICTLS. QUIC=${QUIC:-no} set -e rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION tar xvf $CWD/$PRGNAM-$VERSION.tar.gz cd $PRGNAM-$VERSION chown -R root:root . find -L . \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ -o -perm 511 \) -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; LUAOPT="" if [ "$LUA" == "yes" ]; then LUAOPT="USE_LUA=1" else LUAOPT="USE_LUA=" fi PCREOPT="" if [ "$PCRE" != "PCRE2" ]; then PCREOPT=$(echo $PCRE | sed -e 's/USE_//' -e 's/=1//') else PCREOPT="PCRE2" fi QUICOPT="" if [ "$QUIC" == "yes" ]; then LUAOPT="USE_QUIC=1" else LUAOPT="USE_QUIC=" fi make \ TARGET=$TARGET \ USE_$PCREOPT=1 \ $QUICOPT \ USE_OPENSSL=1 \ USE_ENGINE=1 \ USE_ZLIB=1 \ USE_NS=1 \ USE_SYSTEMD= \ $LUAOPT \ EXTRA="" make install \ PREFIX=/usr \ MANDIR=/usr/man \ DOCDIR=/usr/doc/$PRGNAM-$VERSION \ EXTRA="" \ DESTDIR=$PKG find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true find $PKG/usr/man -type f -exec gzip -9 {} \; for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done install -D -m 0644 $CWD/rc.$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new cp -a CONTRIBUTING LICENSE MAINTAINERS README BRANCHES SUBVERS VERDATE VERSION examples \ $PKG/usr/doc/$PRGNAM-$VERSION # If there's a CHANGELOG, installing at least part of the recent history # is useful, but don't let it get totally out of control: if [ -r CHANGELOG ]; then head -n 1000 CHANGELOG > $PKG/usr/doc/$PRGNAM-$VERSION/CHANGELOG touch -r CHANGELOG $PKG/usr/doc/$PRGNAM-$VERSION/CHANGELOG fi cp $CWD/{syslog.example,logrotate.example} $PKG/usr/doc/$PRGNAM-$VERSION/examples/ mkdir -p $PKG/etc/haproxy mv $PKG/usr/doc/$PRGNAM-$VERSION/examples/errorfiles $PKG/etc/haproxy/errors cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE