#!/bin/sh # Copyright 2016, 2017, 2018, 2020 Eric Hameleers, Eindhoven, Netherlands # # 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. # Since my package no longer compiled, I have borrowed the patches from # the SBo script written by: Andreas Voegele PRGNAM=broadcom-sta VERSION=${VERSION:-6.30.223.271} SRCVER=${SRCVER:-35} BUILD=${BUILD:-2} TAG=${TAG:-alien} NUMJOBS=${NUMJOBS:-" -j$(nproc) "} KERNEL=${KERNEL:-$( uname -r )} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$(uname -m)" in i?86) ARCH=i586 ;; arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;; # Unless $ARCH is already set, use uname -m for all other archs: *) ARCH=$(uname -m) ;; esac export ARCH fi case "$ARCH" in i?86) ARCHSUFF="" ;; x86_64) ARCHSUFF="_64" ;; *) echo "Unsupported architecture $ARCH" exit 1 ;; esac CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/pkg-$PRGNAM rm -rf $PKG mkdir -p $TMP $PKG cd $TMP rm -rf $PRGNAM-$VERSION mkdir $PRGNAM-$VERSION cd $PRGNAM-$VERSION tar xvf $CWD/hybrid-v${SRCVER}${ARCHSUFF}-nodebug-pcoem-$( echo $VERSION | tr . _ ).tar.?z || exit 1 # Stability fixes: cat $CWD/patches/04-user_ioctl.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/05-remove-time-and-date-macros.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/13-broadcom-sta-null-pointer-crash.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/14-rdtscl.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/009-fix_mac_profile_discrepancy.patch \ | patch -p1 --verbose || exit 1 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 # Add support for newer kernels: #cat $CWD/patches/15-linux47.patch \ # | patch -p2 --verbose || exit 1 cat $CWD/patches/16-linux48.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/17-fix-kernel-warnings.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/18-linux411.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/19-linux412.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/20-linux414.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/21-linux415.patch \ | patch -p2 --verbose || exit 1 cat $CWD/patches/22-linux51.patch \ | patch -p1 --verbose || exit 1 cat $CWD/patches/23-linux56.patch \ | patch -p1 --verbose || exit 1 cat $CWD/patches/24-linux59.patch \ | patch -p1 --verbose || exit 1 cat $CWD/patches/25-linux517.patch \ | patch -p1 --verbose || exit 1 cat $CWD/patches/26-linux518.patch \ | patch -p1 --verbose || exit 1 # 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 # Make sure ownerships and permissions are sane: chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; # Compile the kernel module: make -C /lib/modules/$KERNEL/build M=$(pwd) clean make -C /lib/modules/$KERNEL/build M=$(pwd) # Manually install the lot: install -Dm644 wl.ko $PKG/lib/modules/$KERNEL/kernel/extra/wl.ko install -Dm644 $CWD/b43_blacklist.conf.new $PKG/etc/modprobe.d/b43_blacklist.conf.new # Add documentation: mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a \ lib/LICENSE.txt $CWD/README* \ $PKG/usr/doc/$PRGNAM-$VERSION cp -ia $CWD/patches $PKG/usr/doc/$PRGNAM-$VERSION/ cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild # Add a package description and a post-install script: mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat << EOF > $PKG/install/doinst.sh # Handle the incoming configuration files: config() { for infile in \$1; do NEW="\$infile" 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... done } config etc/modprobe.d/b43_blacklist.conf.new # Update kernel module dependencies information: chroot . /sbin/depmod -a $KERNEL 1>/dev/null 2>/dev/null EOF cd $PKG /sbin/makepkg -l y -c n $TMP/$PRGNAM-${VERSION}_$(echo $KERNEL |tr - _)-$ARCH-$BUILD$TAG.txz