Articles
[SCRIPT] Make module for Agere Pinball modems agrsm06pci
- Details
- Created on 12 January 2011
Note: This script is for Porteus V 1.0.
You'll need to download the source file for the driver (agrsm06pci). As of 06/15/2011, it could be found here.
Cut + paste main code below and save as: agrsm06pci.pbuild
Make it executable: chmod +x agrsm06pci.pbuild
Run the script: ./agrsm06pci.pbuild
Note: It should be run in the same directory as the tar.gz source file.
#!/bin/sh
# porteus build script for agrsm06pci
CWD=$PWD
ARCH=$(uname -m)
ARCH=${ARCH:-i486}
TMP=/tmp/packages
PKG=$TMP/_pkg_
#get ready when slax's gonna change the module's extension
#just like slackware did since version 13
pkgext=xzm
#SLAXMAJOR=$(awk '{print $2}' /etc/slax-version | cut -d'.' -f1)
#don't know yet what it's gonna be
#if [ $SLAXMAJOR -ge 7 ]; then
# pkgext=lzm
#fi
#archive expected in format agrsm06pci-*.tar.gz
if [ $(ls agrsm06pci-*.tar.gz 2>/dev/null | wc -l) -ne 1 ]; then
echo "couldn't find the source archive"
exit 1
fi
archive=$(ls agrsm06pci-*.tar.gz)
src=$(tar tf $archive| head -n1 | tr -d \/)
VERSION=$(echo ${archive%.tar.gz} | sed 's?^agrsm06pci-??' | \
sed 's?-[a-z]\{3,\}$??' | sed 's?-?_?g')
LIB=""
case "$ARCH" in
i386) CFLAGS="-O3 -march=i386 -mcpu=i686";;
i486) CFLAGS="-O3 -march=i486 -mtune=i686";;
i686) CFLAGS="-O3 -march=i686 -mtune=i686";;
athlon-xp) CFLAGS="-O3 -march=athlon-xp -pipe -fomit-frame-pointer";;
x86_64) CFLAGS="-O3"; LIB=64;;
esac
#should we include the architexture in the name?
#MODNAME=agrsm06pci-${VERSION}-$ARCH.$pkgext
MODNAME=agrsm06pci-$VERSION.$pkgext
description()
{
cat < /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \
xargs strip --strip-unneeded 2> /dev/null
}
generatelist()
{
(cd $PKG
LIST=$PKG/usr/src/slaxbuilds/agrsm06pci/pkglist.txt
rm -f $LIST
find * | while read f
do
if [ -d "$f" ]; then
echo "${f}/" >> $LIST
fi
if [ -L "$f" ]; then
echo "$f -> $(readlink -n $f)" >> $LIST
elif [ ! -d "$f" ]; then
echo "$f" >> $LIST
fi
done
)
}
if [ -e $TMP ]; then
rm -Rf $TMP/*
fi
mkdir -p $TMP
cd $TMP
tar zxvf $CWD/$archive || exit 1
cd $src || exit 1
# permissions || exit 1
#make module || exit 1
make || exit 1
clear
mkdir -p $PKG
#make install || exit 1
./agrinst || exit 1
mkdir -p $PKG/usr/lib/AgereSoftModem
cp AgereMdmDaemon $PKG/usr/lib/AgereSoftModem/
mkdir -p $PKG/lib/modules/`uname -r`/kernel/drivers/char/
cp /lib/modules/`uname -r`/kernel/drivers/char/agr* $PKG/lib/modules/`uname -r`/kernel/drivers/char/
mkdir -p $PKG/etc/rc.d/
cp agr_softmodem $PKG/etc/rc.d/rc.agr_softmodem
chmod +x $PKG/etc/rc.d/rc.agr_softmodem
depmod -a
strip
#normally this is not necessary
(cd $PKG/usr
if [ -d share/man ]; then
mv share/man .
fi
)
(cd $PKG/usr
if [ -d share/doc ]; then
mv share/doc .
fi
)
#we might want to copy README* LICENCE etc to $PKG/usr/doc/agrsm06pci-$VERSION
mkdir -p $PKG/usr/doc/agrsm06pci-$VERSION
cp README* LICENSE $PKG/usr/doc/agrsm06pci-$VERSION
# copy this script and some info to /usr/src/pbuilds/agrsm06pci
mkdir -p $PKG/usr/src/pbuilds/agrsm06pci
cp $CWD/agrsm06pci.pbuild $PKG/usr/src/pbuilds/agrsm06pci
description > $PKG/usr/src/puilds/agrsm06pci/readme.txt
generatelist
clear
echo
cd $CWD
rm -f $MODNAME
# use this one if you are using Slax 6.1.X
#mksquashfs $PKG $MODNAME -b 256K -lzmadic 256K || exit 33
#Use this one if you are using Porteus
dir2xzm $PKG $MODNAME
chmod a-wx $MODNAME
chmod a+r $MODNAME
echo
echo " agrsm06pci"
echo
description
echo
echo "module $MODNAME successfully created in $CWD"
echo
echo "removing stuff from install"
rm -rf /usr/lib/AgereSoftModem/
rm -rf /lib/modules/`uname -r`/kernel/drivers/char/agr*
rm -Rf $TMP/*