Compile AVM Fritz!Card USB driver for Ubuntu (fcusb2.ko)

#!/bin/bash
 
# note
# successfully tested on Ubuntu Gutsy 7.10, this driver currently dont work with Hardy 8.04
 
apt-get install -y wget rpm build-essential linux-headers-$(uname -r) avm-fritz-firmware
 
wget http://opensuse.foehr-it.de/rpms/10_3/src/fcusb2-0.1-0.src.rpm -P /tmp
cd /tmp
rpm2cpio fcusb2-0.1-0.src.rpm | cpio -i --make-directories
 
if [ $(uname -m) == "x86_64" ]; then
	# amd64
	tar -xzf fcusb2-suse93-64bit-3.11-07.tar.gz
	cd /tmp/fritz/src/
	patch -p2 < /tmp/fritz-usb.diff
	patch -p2 < /tmp/fritz_init_work.diff
	patch -p2 < /tmp/fritz_urb.diff
	patch -p2 < /tmp/fritz_config64.diff
else
	# i386
	tar -xzf fcusb2-suse93-3.11-07.tar.gz
	cd /tmp/fritz/src/
	patch -p2 < /tmp/fritz_config.diff
	patch -p2 < /tmp/fritz_init_work.diff
	patch -p2 < /tmp/fritz-tools.diff
	patch -p2 < /tmp/fritz_urb.diff
	patch -p2 < /tmp/fritz-usb.diff 
fi
 
cd /tmp/fritz
make
 
cp /tmp/fritz/*.frm /usr/share/isdn/$(uname -r)/
cp /tmp/fritz/src/*.ko /lib/modules/$(uname -r)/kernel/drivers/isdn/hardware/avm/
 
depmod -a
echo "fcusb2          fus2base.frm    DSS1    -       -       -       -" >> /etc/isdn/capi.conf
 
capiinit
 
 
# LINKS
# http://www.kanotix.com/files/thorhammer/kanotix/non-free/avm/
# http://wiki.ubuntuusers.de/AVM_FRITZ!Card
# http://opensuse.foehr-it.de/
# http://kanotix.com/files/thorhammer/kanotix/non-free/avm/
# http://www.foehr-it.de/hlp/viewtopic.php?t=120 - Open SuSE Capi Forum
# http://rpm.pbone.net/index.php3/stat/4/idpl/5762655/com/dkms-fcusb2-3.11.07-6mdv2008.1.noarch.rpm.html - try to compile on hardy, compile succesfull but can not get B-channel
 
 
## test
apt-get install isdnactivecards drdsl pppdcapiplugin isdnutils-base module-assistant alien
 
#wget http://kanotix.com/files/thorhammer/kanotix/non-free/avm/avm-firmware_3.11-19_i386.deb -P /tmp
wget http://kanotix.com/files/thorhammer/kanotix/non-free/avm/avm-source_3.11-19_i386.deb -P /tmp
 
apt-get install avm-fritz-firmware
apt-get install -y wget build-essential
apt-get install -y linux-headers-$(uname -r)
dpkg -i --force-architecture avm-source_3.11-19_i386.deb
 
cd /usr/src
tar xjf avm.tar.bz2
 
cd /usr/src/modules/avm/fritz/fcusb2
 
 
 
## test2
#apt-get install isdnactivecards drdsl pppdcapiplugin isdnutils-base module-assistant alien
 
 
apt-get update
apt-get install -y avm-fritz-firmware
apt-get install -y wget build-essential
apt-get install -y linux-headers-$(uname -r)
 
 
wget http://kanotix.com/files/thorhammer/kanotix/non-free/avm/avm-firmware_3.11-19_i386.deb -P /tmp
wget http://kanotix.com/files/thorhammer/kanotix/non-free/avm/avm-source_3.11-19_i386.deb -P /tmp
 
dpkg -i --force-architecture /tmp/avm-source_3.11-19_i386.deb
apt-get install -f
dpkg -i --force-architecture /tmp/avm-firmware_3.11-19_i386.deb
 
tar xjf /usr/src/avm.tar.bz2 -C /usr/src
 
 
 
 
# 64 bit
wget http://kanotix.com/files/thorhammer/kanotix/non-free/avm/avm_3.11.orig.tar.gz -P /tmp/
tar xzf /tmp/avm_3.11.orig.tar.gz -C /tmp/
mv /usr/src/modules/avm/fritz/fcusb2/lib/fcusb2-lib.o /usr/src/modules/avm/fritz/fcusb2/lib/fcusb2-lib.o.i386
cp /tmp/avm-3.11/fritz64/fcusb2/lib/fcusb2-lib.o /usr/src/modules/avm/fritz/fcusb2/lib/
cp /tmp/avm-3.11/fritz64/fcusb2/fus2base.frm /usr/share/isdn/2.6.24-23/
 
cd /usr/src/modules/avm/fritz/fcusb2
make clean
make
mkdir /lib/modules/`uname -r`/kernel/extras
cp src/fcusb2.ko /lib/modules/`uname -r`/kernel/extras
 
depmod -a
 
#sed -i 's|#fcusb2|fcusb2|g' /etc/isdn/capi.conf
 
echo "fcusb2          fus2base.frm    DSS1    -       -       -       -" >> /etc/isdn/capi.conf
 
 
capiinit
capiinfo
 
 
http://everflux.de/ubuntu-intrepid-linux-2627-und-avm-fritz-fcpci-anleitung-840/
http://forum.ubuntuusers.de/topic/avm-usb2-capi-in-8.04-hardy-einbinden.-so-geh/