source: npl/internetserver/wireguard_tools/wireguard-tools.SlackBuild.orig

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

wiregaurd

  • Property mode set to 100755
File size: 3.6 KB
Line 
1#!/bin/bash
2
3# Copyright 2021  Patrick J. Volkerding, Sebeka, Minnesota, 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=wireguard-tools
26VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
27BUILD=${BUILD:-1}
28
29# Automatically determine the architecture we're building on:
30if [ -z "$ARCH" ]; then
31  case "$(uname -m)" in
32    i?86) ARCH=i586 ;;
33    arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;;
34    # Unless $ARCH is already set, use uname -m for all other archs:
35    *) ARCH=$(uname -m) ;;
36  esac
37  export ARCH
38fi
39
40# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
41# the name of the created package would be, and then exit. This information
42# could be useful to other scripts.
43if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
44  echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz"
45  exit 0
46fi
47
48NUMJOBS=${NUMJOBS:-" -j $(expr $(nproc) + 1) "}
49
50if [ "$ARCH" = "i586" ]; then
51  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
52  LIBDIRSUFFIX=""
53elif [ "$ARCH" = "i686" ]; then
54  SLKCFLAGS="-O2 -march=i686"
55  LIBDIRSUFFIX=""
56elif [ "$ARCH" = "s390" ]; then
57  SLKCFLAGS="-O2"
58  LIBDIRSUFFIX=""
59elif [ "$ARCH" = "x86_64" ]; then
60  SLKCFLAGS="-O2 -fPIC"
61  LIBDIRSUFFIX="64"
62elif [ "$ARCH" = "armv7hl" ]; then
63  SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16"
64  LIBDIRSUFFIX=""
65else
66  SLKCFLAGS="-O2"
67  LIBDIRSUFFIX=""
68fi
69
70TMP=${TMP:-/tmp}
71PKG=$TMP/package-$PKGNAM
72
73rm -rf $PKG
74mkdir -p $TMP $PKG
75
76cd $TMP
77rm -rf $PKGNAM-$VERSION
78tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1
79cd $PKGNAM-$VERSION/src || exit 1
80
81chown -R root:root .
82#find . \
83#  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
84#  -exec chmod 755 {} \+ -o \
85#  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
86#  -exec chmod 644 {} \+
87
88# Build:
89MANDIR=/usr/man \
90LIBDIR=/usr/lib${LIBDIRSUFFIX} \
91make $NUMJOBS || exit 1
92
93# Install:
94MANDIR=/usr/man \
95LIBDIR=/usr/lib${LIBDIRSUFFIX} \
96DESTDIR=$PKG \
97make install || exit 1
98
99# Strip binaries:
100find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
101
102# Compress manual pages:
103find $PKG/usr/man -type f -exec gzip -9 {} \+
104for i in $( find $PKG/usr/man -type l ) ; do
105  ln -s $( readlink $i ).gz $i.gz
106  rm $i
107done
108
109# Add a documentation directory:
110mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
111cp -a \
112  ../COPYING* ../README* \
113  $PKG/usr/doc/${PKGNAM}-$VERSION
114
115mkdir -p $PKG/install
116cat $CWD/slack-desc > $PKG/install/slack-desc
117
118cd $PKG
119/sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz
Note: See TracBrowser for help on using the repository browser.