# Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: Exp $ inherit eutils #transform P to match tarball versioning MYPV=${PV/_beta/beta} MYP="${PN}_${MYPV}" DESCRIPTION="Thinkpad system control kernel modules" HOMEPAGE="http://tpctl.sourceforge.net/tpctlhome.htm" SRC_URI="mirror://sourceforge/tpctl/${MYP}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="-* x86 amd64" ARCH="i386" DEPEND="virtual/glibc" pkg_setup() { enewgroup thinkpad check_KV if [ ! -f "${ROOT}/usr/src/linux/include/linux/version.h" ] then eerror "Please verify that your /usr/src/linux symlink is pointing" eerror "to your current kernel sources, and that you did run:" eerror eerror " # make dep" die "/usr/src/linux symlink not setup!" fi [ ! -f ${FILESDIR}/thinkpad ] && die "Missing ${FILESDIR}/thinkpad" } src_unpack() { check_KV unpack ${A} || die "unpack failed" cd ${S} # Use your kernel version to build. local ver=${KV:0:3} # first 3 chars of $KV, thank you bash :) if [ ! -d ${ver} ] then die "The used kernel version ${ver}.x is not supported" else ln -s ${ver}/drivers drivers ln -s ${ver}/include include mkdir -p ${ver}/drivers/.tmp_versions fi } src_compile() { check_KV # Hack to prevent from getting sandbox errors addwrite "${ROOT}usr/src/linux-${KV}/include/asm-i386" addwrite "${ROOT}usr/src/linux-${KV}/include/asm-x86_64" addwrite "${ROOT}usr/src/linux-${KV}/.tmp_versions" addwrite "${ROOT}usr/src/linux-${KV}" emake DIR_MOD="${ROOT}lib/modules" \ DIR_MOD_VER="${ROOT}lib/modules/${KV}" \ DIR_MODUTILS="${ROOT}sbin" \ KVERS="${KV}" \ KTYPE="${KV:0:3}" \ MODSUF="$([[ "${KV:0:3}" == "2.6" ]] && echo "ko" || echo "o")" \ || die "make failed" } src_install() { check_KV dodoc AUTHORS COPYING ChangeLog README SUPPORTED-MODELS TECHNOTES dodir /lib/modules/${KV}/thinkpad for foo in ${S}/drivers/*.$([[ "${KV:0:3}" == "2.6" ]] && echo "ko" || echo "o") do cp ${foo} ${D}/lib/modules/${KV}/thinkpad || die "Failed to copy kernel module" done # Stuff for DevFS if [ -d "${ROOT}etc/devfs.d" ] then dodir /etc/devfs.d echo 'REGISTER ^thinkpad/.*$ PERMISSIONS root.thinkpad 0664' \ > ${D}/etc/devfs.d/thinkpad || \ die "Creating ${D}/etc/devfs.d/thinkpad failed" fi # Stuff for UDEV if [ -d "${ROOT}etc/udev" ] then if ! grep -q "^thinkpad:root:thinkpad:[0-9]\{4\}[\t ]*$" ${ROOT}etc/udev/udev.permissions then dodir /etc/udev cat ${ROOT}etc/udev/udev.permissions \ > ${D}/etc/udev/udev.permissions echo "thinkpad:root:thinkpad:0664" \ >> ${D}/etc/udev/udev.permissions || die fi fi dodir /etc/modules.d sed 's/%KV%/'${KV}'/g' ${FILESDIR}/thinkpad > ${D}/etc/modules.d/thinkpad doman man/*.4 } pkg_postinst() { /usr/sbin/update-modules || return 0 if ! grep -q '^ *INCLUDE.*devfs\.d' /etc/devfsd.conf then ewarn 'Your /etc/devfsd.conf is missing the include for' ewarn '/etc/devfs.d/! Please fix this by adding' ewarn 'INCLUDE /etc/devfs.d' ewarn 'to your /etc/devfs.conf' fi if grep -q thinkpad /etc/devfsd.conf then ewarn 'The thinkpad devfsd entry has moved to' ewarn '/etc/devfs.d/thinkpad, so you can remove it from' ewarn '/etc/devfsd.conf if you like.' fi } pkg_prerm() { for foo in smapi superion rtcmosram thinkpadpm thinkpad do /sbin/modprobe -r ${foo} 2>/dev/null done }