b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

General talk about packaging procedures and packages.
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by zAchAry »

Linux Wireless wrote:The Broadcom wireless chip needs software, called "firmware", that runs on the wireless chip itself during operation. This firmware is copyrighted by Broadcom and must be extracted from Broadcom's proprietary drivers. To get such firmware on your system, you must download the driver from a legal distribution point, as noted below. Then you must extract the firmware from that Broadcom driver by using b43-fwcutter (or bcm43xx-fwcutter) and install it in the special directory for firmware - usually /lib/firmware. Please note that the firmware from the binary drivers is copyrighted by Broadcom Corporation and must not be redistributed.

Source: b43 - Linux Wireless - device firmware installation.
If so, then what would be the easiest (user-friendly) way to get it installed on SalixOS?

I'd like to see SalixOS listed at b43 - Linux Wireless which will also help to gain more popularity amongst b43 owners.

The package b43-fwcutter-013-i486-1pw.txz can be legally published in the official SalixOS repository, and will be published if the SalixOS Team will accept to put it in, of course.

The most easy, step by step, way, for now, is:

Code: Select all

$ wget http://people.salixos.org/pwatk/packages/n/b43-firmware/4.178.10.4/SLKBUILD

Code: Select all

# slkbuild -X SLKBUILD

Code: Select all

# installpkg b43-firmware-4.178.10.4-fw-1pw.txz
Can somebody submit here a script which will use wget and after the download process is completed* the script will start to build a package with the SLKBUILD and after the compiling process and after the script has detected a .txz file with the right keywords: b43 and firmware, the script will start to install the firmware.

On the other hand, if the process it automated, like the situation above, it'll be smarter to command the script to create a new folder (in the /tmp directory maybe) and to download, compile and install everything from it, and then all the newly created content will be deleted.

___________________
* Since the file in question is not provided from a secured SSL connection (https://) then the best thing to do, imho, is to confirm the checksum of the downloaded file with a command like md5sum or sha1sum etc.
Image
Help to make Slackware easier Donate to Salix
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by pwatk »

The package b43-fwcutter-013-i486-1pw.txz can be legally published in the official SalixOS repository, and will be published if the SalixOS Team will accept to put it in, of course.
Submitted: https://sourceforge.net/apps/trac/salix/ticket/385
Image
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by zAchAry »

Awesome, n/b43-fwcutter-013-i486-1pw.txz: Added. :)

is there any chance to add to it (or to a separate package) a bash-script with a "SLKBUILD for b43-firmware"


If it'll be only a script then the script will itself use wget, to get the SLKBUILD.
Or a bash-script with a SLKBUILD will be attached and, if slapt-get is able to do it, a dialog will appear asking the user to install the firmware and the following commands will take place:

the dialog idea is from: http://linuxwireless.org/en/users/Drive ... AC8-Debian
Ubuntu/Debian

In recent versions of Ubuntu and Debian, installing the b43-fwcutter package will handle everything for you:

Code: Select all

sudo apt-get install b43-fwcutter
You will be asked to automatically fetch and install the firmware into the right location.
Note: when using Ubuntu 8.10 I've never saw any such of dialog (except when installing VBox) and I've needed to execute the script install_bcm43xx_firmware.sh to get b43 driver to work (it was broadcom-sta before that)

see a bash script posted here



if only a bash script is packed then

Code: Select all

# mktemp -d
# cd <the_name_of_the_new_directory>
# wget http://people.salixos.org/pwatk/packages/n/b43-firmware/4.178.10.4/SLKBUILD
# slkbuild -X SLKBUILD
# installpkg b43-firmware-4.178.10.4-fw-1pw.txz
# rm -r /tmp/<the_name_of_the_new_directory>

if a bash script and the SLKBUILD are packed in the same package then

Code: Select all

# mktemp -d
# install SLKBUILD  /tmp<the_name_of_the_new_directory>
# cd <the_name_of_the_new_directory>
# slkbuild -X SLKBUILD
# installpkg b43-firmware-4.178.10.4-fw-1pw.txz
# rm -r /tmp/<the_name_of_the_new_directory>

sandbox
# wget http://people.salixos.org/pwatk/package ... 4/SLKBUILD -P /tmp
# wget http://people.salixos.org/pwatk/package ... 4/SLKBUILD -P /tmp/<the_name_of_the_new_directory>

# mkdir /tmp/broadcom-wl-4.178.10.4
# wget http://people.salixos.org/pwatk/package ... 4/SLKBUILD -P /tmp/broadcom-wl-4.178.10.4
# rm -r /tmp/broadcom-wl-4.178.10.4
Image
Help to make Slackware easier Donate to Salix
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by pwatk »

Something like this but done properly (error handling etc).

Code: Select all

#!/bin/sh
clear
echo -n "
 If you have a device with a low-power PHY (LP-PHY) e.g. BCM4312
 use version 4.178.10.4 else use version 4.150.10.5.

 1) 4.150.10.5
 2) 4.178.10.4

 Please select b43-firmware version: "
read retval
case $retval in
  1) pkgver=4.150.10.5 ;;
  2) pkgver=4.178.10.4 ;;
  *) exit ;;
esac

tmp=`mktemp -d`

( 
cd $tmp
wget http://people.salixos.org/pwatk/packages/n/b43-firmware/$pkgver/SLKBUILD
slkbuild -X
installpkg b43-firmware-$pkgver-fw-*pw.t?z
)

rm -rf $tmp
Image
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by zAchAry »

for the record (md5sum, sha1sum)

broadcom-wl-4.178.10.4.tar.bz2

Code: Select all

etf[~]$ md5sum broadcom-wl-4.178.10.4.tar.bz2 
14477e8cbbb91b11896affac9b219fdb  broadcom-wl-4.178.10.4.tar.bz2
etf[~]$ sha1sum broadcom-wl-4.178.10.4.tar.bz2 
ad5b3170cb9c72636e84392aefcdacf306270938  broadcom-wl-4.178.10.4.tar.bz2
broadcom-wl-4.150.10.5.tar.bz2

Code: Select all

etf[~]$ md5sum broadcom-wl-4.150.10.5.tar.bz2
0c6ba9687114c6b598e8019e262d9a60  broadcom-wl-4.150.10.5.tar.bz2
etf[~]$ sha1sum broadcom-wl-4.150.10.5.tar.bz2
2dc21875dae79113b31d1dd16179ab3431d0f0ae  broadcom-wl-4.150.10.5.tar.bz2
Where should this script be located at?
Perhaps at /usr/bin or maybe at /usr/sbin ??
Image
Help to make Slackware easier Donate to Salix
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by pwatk »

Probably /usr/share/b43-fwcutter because I'm considering including the b43-firmware SLKBUILD's and an update function.

Anyway, I need some feedback on this script then I need to find out if it's likely this will be accepted in to the repo.

install-b43-firmware.sh:

Code: Select all

#!/bin/sh

clear ; echo -e "
+---------------------------+
| b43-firmware installation |
+---------------------------+"

if [ ! "$UID" = "0" ]; then
  echo -e "\nPlease login as root and try again.\n"
  exit 1
fi

prevpkg=$(cd /var/log/packages ; find * -name b43-firmware*)
if [ -n "$prevpkg" ]; then
  echo -e "\nPlease remove the following package(s) and try again:\n\n$prevpkg\n"
  exit 1
fi

echo -n "
If you have a device with a low-power PHY (LP-PHY) e.g. BCM4312
select version 4.178.10.4 else select version 4.150.10.5.

1) 4.150.10.5 (default)
2) 4.178.10.4

Please select version [1]: "
read retval
case $retval in
  2) pkgver=4.178.10.4 ;;
  *) pkgver=4.150.10.5 ;;
esac

echo -n "
You have selected version \`$pkgver'

Do you wish to continue [Y/n]: "
read retval
if [ ! "`echo $retval | grep -iE 'y|yes'`" ]; then
  echo -e "\nInstallation aborted.\n"
  exit 1
fi

tmp=`mktemp -d`

(
set -e
cd $tmp
wget http://people.salixos.org/pwatk/packages/n/b43-firmware/$pkgver/SLKBUILD
slkbuild -X
installpkg b43-firmware-$pkgver-fw-*pw.t?z
set +e
)

rm -rf $tmp
Image
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by zAchAry »

ask me whatever you need me to do.
Image
Help to make Slackware easier Donate to Salix
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by pwatk »

I've run the script and everything seams to work ok but...

Should I really make version 4.150.10.5 the default or should I have it exit if you just hit enter?
Does the package install ok (I assume it would but I commented that out)?
Are there anymore checks I should add?
Is there anything I could have wrote better?
Image
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by zAchAry »

pwatk wrote:Are there anymore checks I should add?
Concernong to the SLKBUILD:

I remember, when I was very interested about Mozilla News and Development Worldwide there was an article (but I can't find it) about AMO (addons.mozilla.org) which reported that AMO will use SSL (https://) to prevent from interwebz criminals to "inject" malicious code to the downloaded .XPI extension file.
Not only that AMO is using SSL, even all the XUL products modified to get updates only via sources with SSL (doesn't have to be AMO and can be disabled via about:config).

Back to the main subject:
Since the files broadcom-wl-4.150.10.5.tar.bz2 and broadcom-wl-4.178.10.4.tar.bz2 are not reachable with SSL (and ARE NOT distributable, by law) then you can add to the SLKBUILD script a command to verify the check-sums of the files in question.

On the other hand:
a. The chances that someone will try to sabotage the files in question, while another user is running the script above, are almost 0%.
b. Not to mention that this downloading process is occurring only once.

But:
a. For me, and I'm sure that for many others that care about WiFi support, this is one of the most critical installations.
b. I think there are enough users of GNU/Linux users that are using the exact downloading source.
c. Can give a reputation for SalixOS that its packages are completely secured. ~
Image
Help to make Slackware easier Donate to Salix
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: b43-fwcutter-013-i486-1pw.txz + SLKBUILD for b43-firmware

Post by pwatk »

Will this suffice?

Spot the added feature :P.

SLKBUILD

Code: Select all

# Packager: Phill Watkins <phill~dot~watkins~at~gmail~dot~com>

# Note: If you have a device with a low-power PHY (LP-PHY) e.g. BCM4312
#       use version 4.178.10.4 else use version 4.150.10.5.

pkgname=b43-firmware
pkgver=4.150.10.5
#pkgver=4.178.10.4
pkgrel=4pw
arch=fw
source=\
(
"http://downloads.openwrt.org/sources/broadcom-wl-$pkgver.tar.bz2"
"http://people.salixos.org/pwatk/packages/n/$pkgname/rc.b43.gz"
"http://people.salixos.org/pwatk/packages/n/$pkgname/b43.txt.gz"
)
sourcetemplate=http://people.salixos.org/pwatk/packages/n/$pkgname/$pkgver
url=http://linuxwireless.org/en/users/Drivers/b43

doinst() {
    for mod in b43 ssb wl lib80211;do
      if [ "$(lsmod | grep "^$mod ")" ]; then
        modprobe -r $mod
      fi
    done
    depmod -a > /dev/null 2>&1
    modprobe b43
    
    # Remove any references to the b43 or broadcom-sta modules from any of the
    # following files:
    #
    # /etc/rc.d/rc.modules.local
    # /etc/rc.d/rc.modules-$(uname -r)
    # /etc/rc.d/rc.modules
    # /etc/modprobe.d/blacklist.conf
    #
    # These entries may have been have been created by the user or by a previous
    # version of this package, either way we don't need or want them.

    if [ -f etc/rc.d/rc.modules.local ]; then
      rcmod="etc/rc.d/rc.modules.local"
    elif [ -f etc/rc.d/rc.modules-$(uname -r) ]; then
      rcmod="etc/rc.d/rc.modules-$(uname -r)"
    else
      rcmod="etc/rc.d/rc.modules"
    fi
    
    cp -a etc/modprobe.d/blacklist.conf{,.orig}
    cp -a $rcmod{,.orig}

    for mod in b43 ssb wl lib80211 ;do
      sed -i -e "/blacklist $mod$/d" etc/modprobe.d/blacklist.conf
      sed -i -e "/modprobe $mod$/d" $rcmod
    done

    dotorig() {
      orig="${1}.orig"
      new="$1"
      if [ "$(cat $new | md5sum)" = "$(cat $orig | md5sum)" ]; then
        rm $orig
      fi
    }
    dotorig etc/modprobe.d/blacklist.conf
    dotorig $rcmod
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"b43-firmware (Broadcom BCM43xx firmware)"
"The Broadcom wireless chip needs software, called \"firmware\", that"
"runs on the wireless chip itself during operation. This firmware is"
"copyrighted by Broadcom and must be extracted from Broadcom's"
"proprietary drivers."
"This package contains firmware extracted from the Broadcom driver by"
"using b43-fwcutter (or bcm43xx-fwcutter)"
)

build() {
    set -e
    
    cd $startdir/src/broadcom-wl-$pkgver
    install -d $startdir/pkg/lib/firmware
    
    # Begin overkill :P
    if [ "$pkgver" = "4.150.10.5" ]; then
      fw="driver/wl_apsta_mimo.o"
      md5="cb8d70972b885b1f8883b943c0261a3c"
    elif [ "$pkgver" = "4.178.10.4" ]; then
      fw="linux/wl_apsta.o"
      md5="bb8537e3204a1ea5903fe3e66b5e2763"
    fi
    
    if [ "`md5sum $fw | awk '{print $1}'`" = "$md5" ]; then
      b43-fwcutter --unsupported -w $startdir/pkg/lib/firmware $fw
    else
      echo "$(basename $0): \`$(pwd)/$fw' failed md5 check" ; exit 1
    fi
    # End overkill
    
    chmod 755 $startdir/pkg/lib/firmware/b43
    
    [ -f README ] && install -Dm 0644 README $startdir/pkg/usr/doc/$pkgname-$pkgver/README || true
    
    install -Dm 0755 $startdir/src/rc.b43 $startdir/pkg/etc/rc.d/rc.b43
    install -Dm 0644 $startdir/src/b43.txt $startdir/pkg/etc/rc.d/desc.d/b43.txt

    set +e
} 
Image
Post Reply