# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils linux-info DESCRIPTION="Kernel-space driver for Alcatel SpeedTouch USB modems" HOMEPAGE="http://www.speedtouch.com/" SRC_URI="http://www.speedtouch.com/download/drivers/USB/SpeedTouch330_firmware_${PV//./}.zip" # Taken from http://www.speedtouch.com/driver_upgrade_lx_${PV}.htm LICENSE="SpeedTouch-USB-Firmware" SLOT="0" KEYWORDS="~x86" IUSE="" # udev replaces hotplug, as mentioned at # http://www.linux-usb.org/SpeedTouch/firmware/firmware.html # hotplug only needs to be *installed*, to create /etc/hotplug/usb/ - it does # not need to be running. RDEPEND="net-dialup/ppp sys-apps/module-init-tools >=sys-apps/baselayout-1.12.0_pre13-r1 >=sys-apps/hotplug-20040923-r1 >=sys-fs/udev-068-r1 !net-dialup/speedtouch" DEPEND="${RDEPEND} app-arch/unzip sys-apps/grep sys-apps/coreutils" S=${WORKDIR} pkg_setup() { linux-info_pkg_setup CONFIG_CHECK="!STANDALONE FW_LOADER NET PACKET ATM NETDEVICES \ PPP PPPOATM USB USB_DEVICEFS USB_ATM USB_SPEEDTOUCH" check_extra_config echo [[ -e /etc/hotplug/usb.usermap ]] && egrep -q " 0x06[bB]9 +0x4061 " /etc/hotplug/usb.usermap && \ ewarn "Please remove the SpeedTouch line from /etc/hotplug/usb.usermap" # Check kernel version if kernel_is lt 2 6 10 ; then eerror "The kernel-space driver exists only in kernels >= 2.6.10." eerror "Please emerge net-dialup/speedtouch instead or upgrade the kernel." die "Unsupported kernel version" fi # Check ppp if ! built_with_use net-dialup/ppp atm ; then eerror "net-dialup/ppp should be built with PPP over ATM support enabled." eerror "Run the following command and try again:" eerror " euse -E atm && emerge net-dialup/ppp" die "PPP not configured" fi } src_install() { local FILE_VER="${PV#*.}" FILE_VER="${PV%%.*}.${FILE_VER//./}" # {major_ver}.{minor_digits} # Extract the "stage 1" portion of the firmware dd if=KQD6_${FILE_VER} of=speedtch-1.bin.2 \ ibs=1 obs=991 count=991 skip=36 &> /dev/null \ || die "Extraction of stage 1 firmware (step 1) failed" dd if=ZZZL_${FILE_VER} of=speedtch-1.bin.4 \ ibs=1 obs=935 count=935 skip=32 &> /dev/null \ || die "Extraction of stage 1 firmware (step 2) failed" # Extract the "stage 2" portion of the firmware dd if=KQD6_${FILE_VER} of=speedtch-2.bin.2 \ ibs=1 obs=762650 count=762650 skip=1027 &> /dev/null \ || die "Extraction of stage 2 firmware (step 1) failed" dd if=ZZZL_${FILE_VER} of=speedtch-2.bin.4 \ ibs=1 obs=775545 count=775545 skip=967 &> /dev/null \ || die "Extraction of stage 2 firmware (step 2) failed" # Copy to the firmware directory insinto /lib/firmware insopts -m 600 doins speedtch-{1,2}.bin.{2,4} || die "doins firmware failed" # Symlinks for other revisions of the modem cd ${D}/lib/firmware for n in 1 2 ; do for rev in 0 1 ; do ln -sfn speedtch-${n}.bin.2 speedtch-${n}.bin.${rev} done # Seems like a reasonable guess, for revision 3 ln -sfn speedtch-${stub}${n}.bin.4 speedtch-${n}.bin.3 done insinto /etc/hotplug/usb insopts -m 644 doins ${FILESDIR}/speedtch.usermap || die "doins usermap failed" # The documentation is necessary to complete the setup dodoc ${FILESDIR}/README || die "dodoc failed" } pkg_postinst() { ewarn "To complete the installation, you must read the documentation in" ewarn "${ROOT}usr/share/doc/${PF}" }