summaryrefslogtreecommitdiff
path: root/network/broadcom-sta/broadcom-sta.SlackBuild
blob: e5330239429f38036f2504f75b65a9fb48cad3f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/sh

# Slackware build script for broadcom-sta

# Copyright 2015-2019 Andreas Voegele <andreas@andreasvoegele.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

PRGNAM=broadcom-sta
VERSION=${VERSION:-6.30.223.271}
BUILD=${BUILD:-3}
TAG=${TAG:-_SBo}

KERNEL=${KERNEL:-$( uname -r )}
IFNAME=${IFNAME:-eth}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

case "$ARCH" in
  i?86)
    SRCNAM=hybrid-v35-nodebug-pcoem
    ;;
  x86_64)
    SRCNAM=hybrid-v35_64-nodebug-pcoem
    ;;
  *)
    echo "$ARCH is not supported..."
    exit 1
    ;;
esac

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
mkdir $PRGNAM-$VERSION
cd $PRGNAM-$VERSION
tar xvf $CWD/$SRCNAM-$( echo $VERSION | tr . _ ).tar.gz
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 {} \;

if [ "$IFNAME" != "eth" ]; then
  sed -i "/BRCM_WLAN_IFNAME/s/eth/$IFNAME/" src/wl/sys/wl_linux.c
fi

patch -p2 < $CWD/patches/04-user_ioctl.patch
patch -p2 < $CWD/patches/05-remove-time-and-date-macros.patch
patch -p2 < $CWD/patches/13-broadcom-sta-6.30.223.248-linux-3.18-null-pointer-crash.patch
patch -p2 < $CWD/patches/14-rdtscl.patch
#patch -p2 < $CWD/patches/15-linux47.patch
if [ -n "${KERNEL##[23].*}" -a -n "${KERNEL##4.[0-6].*}" ]; then
  sed -i.orig 's/IEEE80211_BAND_\([25]\)GHZ/NL80211_BAND_\1GHZ/g' \
    src/wl/sys/wl_cfg80211_hybrid.c
fi
patch -p2 < $CWD/patches/16-linux48.patch
patch -p2 < $CWD/patches/17-fix-kernel-warnings.patch
patch -p2 < $CWD/patches/18-linux411.patch
patch -p2 < $CWD/patches/19-linux412.patch
patch -p2 < $CWD/patches/20-linux414.patch
patch -p2 < $CWD/patches/21-linux415.patch
patch -p1 < $CWD/patches/009-fix_mac_profile_discrepancy.patch

# See https://lkml.org/lkml/2019/3/1/643
sed -i 's/get_ds()/KERNEL_DS/g' src/wl/sys/wl_iw.c
sed -i 's/get_ds()/KERNEL_DS/g' src/wl/sys/wl_cfg80211_hybrid.c

env -u ARCH make -C /lib/modules/$KERNEL/build M=$(pwd) clean
env -u ARCH make -C /lib/modules/$KERNEL/build M=$(pwd)

mkdir -p $PKG/lib/modules/$KERNEL/kernel/extra
cp wl.ko $PKG/lib/modules/$KERNEL/kernel/extra

mkdir -p $PKG/etc/modprobe.d
cat $CWD/b43_blacklist.conf.new > $PKG/etc/modprobe.d/b43_blacklist.conf.new

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a lib/LICENSE.txt $CWD/README_$VERSION.txt $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat << EOF > $PKG/install/doinst.sh
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
  elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then
    # toss the redundant copy
    rm \$NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

config etc/modprobe.d/b43_blacklist.conf.new

# A good idea whenever kernel modules are added or changed:
if [ -x sbin/depmod ]; then
  chroot . /sbin/depmod -a $KERNEL 1> /dev/null 2> /dev/null
fi
EOF

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-${VERSION}_$( echo $KERNEL | tr - _ )-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}