# Copyright 1999-2005 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" LICENSE="SpeedTouch-USB-Firmware" #taken from http://www.speedtouch.com/driver_upgrade_lx_${PV}.htm 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. DEPEND="app-arch/unzip sys-apps/coreutils" RDEPEND="net-dialup/ppp sys-apps/module-init-tools sys-apps/grep >=sys-apps/baselayout-1.11.13-r1 >=sys-apps/hotplug-20040923-r1 >=sys-fs/udev-068-r1 !net-dialup/speedtouch" S=${WORKDIR} pkg_setup() { 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 } pkg_config() { CONFIG_CHECK="KOBJECT_UEVENT !STANDALONE FW_LOADER NET PACKET ATM NETDEVICES \ PPP ~PPP_DEFLATE ~PPP_BSDCOMP PPPOATM USB USB_DEVICEFS USB_ATM USB_SPEEDTOUCH" check_extra_config echo einfo "Check pppd support for PPPoA" 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" return 1 fi einfo "Checking SpeedTouch modem" local DETECTION_FAILED=0 local REVISION local FIRMWARE_FILENAME_1="speedtch-ZZZL-1.bin" local FIRMWARE_FILENAME_2="speedtch-ZZZL-2.bin" # Attempt to detect an attached modem if [ -e /proc/bus/usb/devices ]; then REVISION=$(grep '^P: *Vendor=06b9 ProdID=4061 ' \ /proc/bus/usb/devices \ | sed -e 's/.*Rev= *\([^ ]*\)/\1/') if [ ! -z "${REVISION}" ]; then einfo "Modem revision is ${REVISION}" fi case "${REVISION}" in 0.00|2.00) # Old stingray and purple modem einfo "Detected a Stingray/purple (or older silver) modem" FIRMWARE_FILENAME_1="speedtch-KQD6-1.bin" FIRMWARE_FILENAME_2="speedtch-KQD6-2.bin" ;; 4.00) # Modern silver modem einfo "Detected a modern silver modem" ;; *) # Detection failed - assume it's a modern silver modem ewarn "SpeedTouch modem not found in the list of USB devices" DETECTION_FAILED=1 ;; esac else # Failed to detect because /proc/bus/usb/devices not present ewarn "USB Device Filesystem (USB_DEVICEFS) is not enabled in the kernel" DETECTION_FAILED=1 fi if [ ${DETECTION_FAILED} -eq 1 ]; then # Assume a modern silver modem as the default ewarn "Failed to detect attached SpeedTouch device" ewarn "Defaulted to version 4 (modern silver modem)" ewarn "To change the firmware files for an older modem, run:" ewarn "cd /lib/firmware && ln -sfn speedtch-KQD6-1 speedtch-1.bin && ln -sfn speedtch-KQD6-2 speedtch-2.bin" fi # Create symlinks ln -sfn ${FIRMWARE_FILENAME_1} /lib/firmware/speedtch-1.bin && \ ln -sfn ${FIRMWARE_FILENAME_2} /lib/firmware/speedtch-2.bin || { eerror "Failed to create symlinks to firmware files" return 1 } [ -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" return 0 } src_install() { local FILE_VER="${PV#*.}" FILE_VER="${PV%%.*}.${FILE_VER//./}" # {major_ver}.{minor_digits} einfo "Extracting firmware files" # Extract the "stage 1" portion of the firmware dd if=${S}/KQD6_${FILE_VER} of=${S}/speedtch-KQD6-1.bin \ ibs=1 obs=991 count=991 skip=36 &> /dev/null \ || die "Extraction of stage 1 firmware (step 1) failed" dd if=${S}/ZZZL_${FILE_VER} of=${S}/speedtch-ZZZL-1.bin \ 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=${S}/KQD6_${FILE_VER} of=${S}/speedtch-KQD6-2.bin \ ibs=1 obs=762650 count=762650 skip=1027 &> /dev/null \ || die "Extraction of stage 2 firmware (step 1) failed" dd if=${S}/ZZZL_${FILE_VER} of=${S}/speedtch-ZZZL-2.bin \ 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 ${S}/speedtch-KQD6-1.bin doins ${S}/speedtch-KQD6-2.bin doins ${S}/speedtch-ZZZL-1.bin doins ${S}/speedtch-ZZZL-2.bin insopts -m 644; insinto /etc/hotplug/usb doins ${FILESDIR}/speedtch.usermap # Docs dodoc ${FILESDIR}/README ${FILESDIR}/speedtch-hotplug-3 } pkg_postinst() { einfo "To complete the installation, you must read the documentation in" einfo "/usr/share/doc/${PF}" } pkg_prerm() { # Remove symlinks created by emerge --config [ -L /lib/firmware/speedtch-1.bin ] \ && rm -f /lib/firmware/speedtch-1.bin [ -L /lib/firmware/speedtch-2.bin ] \ && rm -f /lib/firmware/speedtch-2.bin }