# Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="2" inherit eutils linux-info DESCRIPTION="IBM ThinkPad Harddrive Active Protection disk head parking daemon" HOMEPAGE="http://hdaps.sourceforge.net/" SRC_URI="http://cache.gmane.org//gmane/linux/drivers/hdaps/devel/1372-001.bin -> ${P}.c http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1324/raw -> hdaps_protect-2.6.26.patch http://cache.gmane.org//gmane/linux/drivers/hdaps/devel/1393-001.bin -> hdaps_protect-2.6.27.patch" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86" IUSE="" RDEPEND="" RESTRICT="mirror" S="${WORKDIR}" MODULE_PROVIDER="tp_smapi" pkg_setup() { # We require the hdaps module; problem is that it can come from either # kernel sources or from the tp_smapi package. This hack is required because # the linux-info eclass doesn't export any more suitable config checkers. # Here we just skip calling its pkg_setup() in case the module is provided # by the package. if ! has_version app-laptop/tp_smapi || \ ! built_with_use app-laptop/tp_smapi hdaps ; then CONFIG_CHECK="SENSORS_HDAPS" ERROR_SENSORS_HDAPS="${P} requires support for HDAPS (CONFIG_SENSORS_HDAPS)" linux-info_pkg_setup MODULE_PROVIDER="kernel" fi } src_unpack() { cd "${S}" cp "${DISTDIR}"/{${P}.c,hdaps_protect-*.patch} . } src_compile() { cd "${S}" gcc ${CFLAGS} "${P}".c -o hdapsd || die "failed to compile" } src_install() { dosbin "${WORKDIR}"/hdapsd newconfd "${FILESDIR}"/hdapsd.conf hdapsd newinitd "${FILESDIR}"/hdapsd.init hdapsd # udev rule for input device if [[ "${MODULE_PROVIDER}" == "tp_smapi" ]] ; then dodir /etc/udev/rules.d echo 'KERNEL=="event[0-9]*",ATTRS{phys}=="hdaps/input1",ATTRS{modalias}=="input:b0019v1014p5054e4801-*",SYMLINK+="input/hdaps/accelerometer-event"' \ > ${D}/etc/udev/rules.d/51-hdaps.rules else # silence warnings about not having tp_smapi sed -i -r 's/(OPTIONS="-a)"/\1 -y"/' ${D}/etc/conf.d/hdapsd fi # Install our kernel patches dodoc *.patch } # Yes, this sucks as the source location may change, kernel sources may not be # installed, but we try our best anyway kernel_patched() { get_version if grep -qs "blk_protect_register" "${KERNEL_DIR}"/block/blk-sysfs.c ; then einfo "Your kernel has already been patched for blk_freeze" return 0 fi return 1 } pkg_config() { kernel_patched && return 0 local docdir="${ROOT}/usr/share/doc/${PF}/" local p="hdaps_protect-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.patch.bz2" # We need to find our FILESDIR as it's now lost if [[ ! -e ${docdir}/${p} ]] ; then eerror "We don't have a patch for kernel ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} yet" return 1 fi if [[ ! -d ${KERNEL_DIR} ]] ; then eerror "Kernel sources not found!" return 1 fi cd "${KERNEL_DIR}" epatch "${docdir}/${p}" echo einfo "Now you should rebuild your kernel, its modules" einfo "and then install them." } pkg_postinst() { if [[ "${MODULE_PROVIDER}" != "tp_smapi" ]] ; then elog "The new reduced power version of hdapsd (less interrupts)" elog "is only supported by >=tp_smapi-0.32 ." elog "NOTE: If you wish to change to tp_smapi, you'll have to" elog " re-emerge ${PN} to create the necessary udev rule." echo fi if ! kernel_patched ; then ewarn "Your kernel has NOT been patched for blk_freeze" elog "The ebuild can attempt to patch your kernel like so" elog " emerge --config =${PF}" fi }