# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit linux-info eutils autotools DESCRIPTION="Processor Hardware Control is a patch for the Linux Kernel which provides a kernel interface for changing the voltage/frequency pairs of processors from userspace." HOMEPAGE="https://www.dedigentoo.org/trac/linux-phc/" SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86" IUSE="" which_patch() { if kernel_is ge 2 6 19 then PATCH="kernel-patch/${P}-kernel-vanilla-2.6.19.patch" elif kernel_is ge 2 6 18 then PATCH="kernel-patch/${P}-kernel-vanilla-2.6.18.patch" elif kernel_is ge 2 6 17 then PATCH="kernel-patch/${P}-kernel-vanilla-2.6.17.patch" elif kernel_is ge 2 6 16 then PATCH="kernel-patch/${P}-kernel-vanilla-2.6.16.patch" elif kernel_is ge 2 6 15 then PATCH="kernel-patch/${P}-kernel-vanilla-2.6.15.patch" else die "No ${PN} patch for kernel version ${KV_FULL} - sorry not supported" fi } pkg_setup() { linux-info_pkg_setup pkg_preinst } src_unpack() { which_patch if egrep -q 'linux-phc' \ ${KV_DIR}/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c then ewarn "already installed ${PN} for kernel ${KV_FULL}" ewarn "If this is an upgrade attempt, try unmerging first." ewarn "If this failes remove your kernel source from /usr/src" ewarn "and remerge your kernel sources" die fi unpack ${A} [ ! -f "${S}/${PATCH}" ] && \ die "patch ${PATCH} not found. Please enter a bug at bugs.gentoo.org" cd "${S}" local mydir="arch/i386/kernel/cpu/cpufreq" mkdir -p "${S}/${mydir}" cp -P "${KV_DIR}/${mydir}/Kconfig" "${S}/${mydir}/" cp -P "${KV_DIR}/${mydir}/speedstep-centrino.c" "${S}/${mydir}/" epatch "${S}/${PATCH}" || die "epatch failed" } src_compile() { einfo 'Compiling measurefreq' cd "${S}/utils/measurefreq" WANT_AUTOCONF=2.5 eautoconf || die 'eautoconf failed' WANT_AUTOMAKE=1.9 eautomake || die 'eautomake failed' econf || die 'econf failed' emake || die 'emake failed' } src_install() { cd "${S}" insinto "$(/bin/readlink -f ${KV_DIR})" doins -r arch/* dodoc README doinitd gentoo/etc/init.d/undervolt doconfd gentoo/etc/conf.d/undervolt cd "${S}/utils/measurefreq" einstall || die "einstall failed" } pkg_preinst() { if has collision_protect ${FEATURES}; then ewarn "Collisions are expected as this patches kernel code. Disable" ewarn "FEATURES=collision-protect before use" die 'incompatible FEATURES=collision-protect' fi } pkg_postinst() { elog "Please read https://www.dedigentoo.org/trac/linux-phc/#Documentation before using linux-phc" elog "You can use the utility measurefreq to find appropriate voltage values." ewarn "Edit /etc/conf.d/undervolt before using the initscript" } pkg_postrm() { ewarn "Unmerging this ebuild won't revert the patches in your kernel" ewarn "Reemerge your kernel if you want that." }