From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Rl8DO-00043i-By for garchives@archives.gentoo.org; Thu, 12 Jan 2012 00:08:22 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A3FB321C06E; Thu, 12 Jan 2012 00:08:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3F3E021C06E for ; Thu, 12 Jan 2012 00:08:14 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 902321B4017 for ; Thu, 12 Jan 2012 00:08:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 1108C80044 for ; Thu, 12 Jan 2012 00:08:13 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <0fbb85146952ee2ee107029abad5061cbf5a4076.blueness@gentoo> Subject: [gentoo-commits] proj/hardened-dev:uclibc commit in: eclass/ X-VCS-Repository: proj/hardened-dev X-VCS-Files: eclass/kernel-2.eclass X-VCS-Directories: eclass/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 0fbb85146952ee2ee107029abad5061cbf5a4076 Date: Thu, 12 Jan 2012 00:08:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 183fd194-ee4c-4e83-872c-b37cd8b41c0f X-Archives-Hash: 1ab171184cec025c061eac8fdd181696 commit: 0fbb85146952ee2ee107029abad5061cbf5a4076 Author: Anthony G. Basile gentoo org> AuthorDate: Thu Jan 12 00:08:06 2012 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Thu Jan 12 00:08:06 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/hardened-dev.= git;a=3Dcommit;h=3D0fbb8514 eclass/kernel-2.eclass: removed PDEPEND on virtual/dev-manager --- eclass/kernel-2.eclass | 1229 ++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 1229 insertions(+), 0 deletions(-) diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass new file mode 100644 index 0000000..724a485 --- /dev/null +++ b/eclass/kernel-2.eclass @@ -0,0 +1,1229 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.274 2011/1= 2/28 13:38:05 psomas Exp $ + +# Description: kernel.eclass rewrite for a clean base regarding the 2.6 +# series of kernel with back-compatibility for 2.4 +# +# Original author: John Mylchreest +# Maintainer: kernel-misc@gentoo.org +# +# Please direct your bugs to the current eclass maintainer :) + +# added functionality: +# unipatch - a flexible, singular method to extract, add and remove pat= ches. + +# A Couple of env vars are available to effect usage of this eclass +# These are as follows: +# +# K_USEPV - When setting the EXTRAVERSION variable, it should +# add PV to the end. +# this is useful for thigns like wolk. IE: +# EXTRAVERSION would be something like : -wolk-4.19-r1 +# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be +# automatically set within the kernel Makefile +# K_NOUSENAME - if this is set then EXTRAVERSION will not include the +# first part of ${PN} in EXTRAVERSION +# K_NOUSEPR - if this is set then EXTRAVERSION will not include the +# anything based on ${PR}. +# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, +# ck-sources, ac-sources) it will use PR (ie: -r5) as +# the patchset version for +# and not use it as a true package revision +# K_EXTRAEINFO - this is a new-line seperated list of einfo displays i= n +# postinst and can be used to carry additional postinst +# messages +# K_EXTRAELOG - same as K_EXTRAEINFO except using elog instead of einf= o +# K_EXTRAEWARN - same as K_EXTRAEINFO except using ewarn instead of ei= nfo +# K_SYMLINK - if this is set, then forcably create symlink anyway +# +# K_DEFCONFIG - Allow specifying a different defconfig target. +# If length zero, defaults to "defconfig". +# K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any +# combination of "base" and "extras" +# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply. +# A value of "5" would apply genpatches-2.6.12-5 to +# my-sources-2.6.12.ebuild +# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo S= ecurity +# K_DEBLOB_AVAILABLE - A value of "0" will disable all of the optional d= eblob +# code. If empty, will be set to "1" if deblobbing is +# possible. Test ONLY for "1". +# K_PREDEBLOBBED - This kernel was already deblobbed elsewhere. +# If false, either optional deblobbing will be available +# or the license will note the inclusion of freedist +# code. +# K_LONGTERM - If set, the eclass will search for the kernel source +# in the long term directories on the upstream servers +# as the location has been changed by upstream +# H_SUPPORTEDARCH - this should be a space separated list of ARCH's whi= ch +# can be supported by the headers ebuild + +# UNIPATCH_LIST - space delimetered list of patches to be applied to t= he +# kernel +# UNIPATCH_EXCLUDE - an addition var to support exlusion based complete= ly +# on "*" and not "_*" +# - this should _NOT_ be used from the ebuild as this is +# reserved for end users passing excludes from the cli +# UNIPATCH_DOCS - space delimemeted list of docs to be installed to +# the doc dir +# UNIPATCH_STRICTORDER - if this is set places patches into directories = of +# order, so they are applied in the order passed + +inherit eutils toolchain-funcs versionator multilib +EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install p= kg_preinst pkg_postinst pkg_postrm + +# Added by Daniel Ostrow +# This is an ugly hack to get around an issue with a 32-bit userland on = ppc64. +# I will remove it when I come up with something more reasonable. +[[ ${PROFILE_ARCH} =3D=3D "ppc64" ]] && CHOST=3D"powerpc64-${CHOST#*-}" + +export CTARGET=3D${CTARGET:-${CHOST}} +if [[ ${CTARGET} =3D=3D ${CHOST} && ${CATEGORY/cross-} !=3D ${CATEGORY} = ]]; then + export CTARGET=3D${CATEGORY/cross-} +fi + +HOMEPAGE=3D"http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}" +: ${LICENSE:=3D"GPL-2"} + +# This is the latest KV_PATCH of the deblob tool available from the +# libre-sources upstream. If you bump this, you MUST regenerate the Mani= fests +# for ALL kernel-2 consumer packages where deblob is available. +: ${DEBLOB_MAX_VERSION:=3D38} + +# No need to run scanelf/strip on kernel sources/headers (bug #134453). +RESTRICT=3D"binchecks strip" + +# set LINUX_HOSTCFLAGS if not already set +: ${LINUX_HOSTCFLAGS:=3D"-Wall -Wstrict-prototypes -Os -fomit-frame-poin= ter -I${S}/include"} + +# debugging functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +# this function exists only to help debug kernel-2.eclass +# if you are adding new functionality in, put a call to it +# at the start of src_unpack, or during SRC_URI/dep generation. +debug-print-kernel2-variables() { + for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE = \ + RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \ + UNIPATCH_LIST S KERNEL_URI K_WANT_GENPATCHES ; do + debug-print "${v}: ${!v}" + done +} + +#Eclass functions only from here onwards ... +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +handle_genpatches() { + local tarball + [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1 + + debug-print "Inside handle_genpatches" + local OKV_ARRAY + IFS=3D"." read -r -a OKV_ARRAY <<<"${OKV}" + + # for > 3.0 kernels, handle genpatches tarball name + # genpatches for 3.0 and 3.0.1 might be named + # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2 + # respectively. Handle this. + + for i in ${K_WANT_GENPATCHES} ; do + if [[ ${KV_MAJOR} -ge 3 ]]; then + if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then + tarball=3D"genpatches-${KV_MAJOR}.${KV_MINOR}-${K_GENPATCHES_VER}.${i= }.tar.bz2" + else + tarball=3D"genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i= }.tar.bz2" + fi + else + tarball=3D"genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2" + fi + debug-print "genpatches tarball: $tarball" + GENPATCHES_URI=3D"${GENPATCHES_URI} mirror://gentoo/${tarball}" + UNIPATCH_LIST_GENPATCHES=3D"${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${ta= rball}" + done +} + +detect_version() { + # this function will detect and set + # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) + # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1) + # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gent= oo-r1) + + # We've already run, so nothing to do here. + [[ -n ${KV_FULL} ]] && return 0 + + # CKV is used as a comparison kernel version, which is used when + # PV doesnt reflect the genuine kernel version. + # this gets set to the portage style versioning. ie: + # CKV=3D2.6.11_rc4 + CKV=3D${CKV:-${PV}} + OKV=3D${OKV:-${CKV}} + OKV=3D${OKV/_beta/-test} + OKV=3D${OKV/_rc/-rc} + OKV=3D${OKV/-r*} + OKV=3D${OKV/_p*} + + KV_MAJOR=3D$(get_version_component_range 1 ${OKV}) + # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1) + local OKV_ARRAY + IFS=3D"." read -r -a OKV_ARRAY <<<"${OKV}" + + # if KV_MAJOR >=3D 3, then we have no more KV_MINOR + #if [[ ${KV_MAJOR} -lt 3 ]]; then + if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then + KV_MINOR=3D$(get_version_component_range 2 ${OKV}) + KV_PATCH=3D$(get_version_component_range 3 ${OKV}) + if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then + KV_EXTRA=3D$(get_version_component_range 4- ${OKV}) + KV_EXTRA=3D${KV_EXTRA/[-_]*} + else + KV_PATCH=3D$(get_version_component_range 3- ${OKV}) + fi + else + KV_PATCH=3D$(get_version_component_range 2 ${OKV}) + KV_EXTRA=3D$(get_version_component_range 3- ${OKV}) + KV_EXTRA=3D${KV_EXTRA/[-_]*} + fi + + debug-print "KV_EXTRA is ${KV_EXTRA}" + + KV_PATCH=3D${KV_PATCH/[-_]*} + + local v n=3D0 missing + #if [[ ${KV_MAJOR} -lt 3 ]]; then + if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then + for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do + [[ -z ${!v} ]] && n=3D1 && missing=3D"${missing}${v} "; + done + else + for v in CKV OKV KV_{MAJOR,PATCH} ; do + [[ -z ${!v} ]] && n=3D1 && missing=3D"${missing}${v} "; + done + fi + + [[ $n -eq 1 ]] && \ + eerror "Missing variables: ${missing}" && \ + die "Failed to extract kernel version (try explicit CKV in ebuild)!" + unset v n missing + +# if [[ ${KV_MAJOR} -ge 3 ]]; then + if [[ ${#OKV_ARRAY[@]} -lt 3 ]]; then + KV_PATCH_ARR=3D(${KV_PATCH//\./ }) + + # at this point 080811, Linus is putting 3.1 kernels in 3.0 directory + # revisit when 3.1 is released + if [[ ${KV_PATCH} -gt 0 ]]; then + KERNEL_BASE_URI=3D"mirror://kernel/linux/kernel/v${KV_MAJOR}.$((${KV_= PATCH_ARR} - 1))" + else + KERNEL_BASE_URI=3D"mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PAT= CH_ARR}" + fi + # KERNEL_BASE_URI=3D"mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PA= TCH_ARR}" + [[ -n "${K_LONGTERM}" ]] && + KERNEL_BASE_URI=3D"${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATC= H_ARR}" + else + #KERNEL_BASE_URI=3D"mirror://kernel/linux/kernel/v${KV_MAJOR}.0" + #KERNEL_BASE_URI=3D"mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MIN= OR}" + if [[ ${KV_MAJOR} -ge 3 ]]; then + KERNEL_BASE_URI=3D"mirror://kernel/linux/kernel/v${KV_MAJOR}.x" + else + KERNEL_BASE_URI=3D"mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MIN= OR}" + fi + + [[ -n "${K_LONGTERM}" ]] && + #KERNEL_BASE_URI=3D"${KERNEL_BASE_URI}/longterm" + KERNEL_BASE_URI=3D"${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINO= R}.${KV_PATCH}" + fi + + debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}" + + if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then + # handle non genpatch using sources correctly + if [[ -z ${K_WANT_GENPATCHES} && -z ${K_GENPATCHES_VER} && ${KV_PATCH}= -gt 0 ]]; then + KERNEL_URI=3D"${KERNEL_BASE_URI}/patch-${OKV}.bz2" + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${CKV}.bz2" + fi + KERNEL_URI=3D"${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_= MINOR}.tar.bz2" + else + KERNEL_URI=3D"${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" + fi + + RELEASE=3D${CKV/${OKV}} + RELEASE=3D${RELEASE/_beta} + RELEASE=3D${RELEASE/_rc/-rc} + RELEASE=3D${RELEASE/_pre/-pre} + # We cannot trivally call kernel_is here, because it calls us to detect= the + # version + #kernel_is ge 2 6 && RELEASE=3D${RELEASE/-pre/-git} + [ $(($KV_MAJOR * 1000 + ${KV_MINOR:-0})) -ge 2006 ] && RELEASE=3D${RELE= ASE/-pre/-git} + RELEASETYPE=3D${RELEASE//[0-9]} + + # Now we know that RELEASE is the -rc/-git + # and RELEASETYPE is the same but with its numerics stripped + # we can work on better sorting EXTRAVERSION. + # first of all, we add the release + EXTRAVERSION=3D"${RELEASE}" + debug-print "0 EXTRAVERSION:${EXTRAVERSION}" + [[ -n ${KV_EXTRA} ]] && [[ ${KV_MAJOR} -lt 3 ]] && EXTRAVERSION=3D".${K= V_EXTRA}${EXTRAVERSION}" + + debug-print "1 EXTRAVERSION:${EXTRAVERSION}" + if [[ -n "${K_NOUSEPR}" ]]; then + # Don't add anything based on PR to EXTRAVERSION + debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}" + elif [[ -n ${K_PREPATCHED} ]]; then + debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}" + EXTRAVERSION=3D"${EXTRAVERSION}-${PN/-*}${PR/r}" + elif [[ "${ETYPE}" =3D "sources" ]]; then + debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}" + # For some sources we want to use the PV in the extra version + # This is because upstream releases with a completely different + # versioning scheme. + case ${PN/-*} in + wolk) K_USEPV=3D1;; + vserver) K_USEPV=3D1;; + esac + + [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION=3D"${EXTRAVERSION}-${PN/-*}" + [[ -n "${K_USEPV}" ]] && EXTRAVERSION=3D"${EXTRAVERSION}-${PV//_/-= }" + [[ -n "${PR//r0}" ]] && EXTRAVERSION=3D"${EXTRAVERSION}-${PR}" + fi + debug-print "2 EXTRAVERSION:${EXTRAVERSION}" + + # The only messing around which should actually effect this is for KV_E= XTRA + # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else + # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION + + if [[ -n ${KV_EXTRA} ]]; then + if [[ -n ${KV_MINOR} ]]; then + OKV=3D"${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" + else + OKV=3D"${KV_MAJOR}.${KV_PATCH}" + fi + KERNEL_URI=3D"${KERNEL_BASE_URI}/patch-${CKV}.bz2 + ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${CKV}.bz2" + fi + + # We need to set this using OKV, but we need to set it before we do any + # messing around with OKV based on RELEASETYPE + KV_FULL=3D${OKV}${EXTRAVERSION} + + # we will set this for backwards compatibility. + S=3D${WORKDIR}/linux-${KV_FULL} + KV=3D${KV_FULL} + + # -rc-git pulls can be achieved by specifying CKV + # for example: + # CKV=3D"2.6.11_rc3_pre2" + # will pull: + # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2= .bz2 + + if [[ ${KV_MAJOR}${KV_MINOR} -eq 26 ]]; then + + if [[ ${RELEASETYPE} =3D=3D -rc ]] || [[ ${RELEASETYPE} =3D=3D -pre ]]= ; then + OKV=3D"${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))" + KERNEL_URI=3D"${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2 + ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${CKV//_/-}.bz2" + fi + + if [[ ${RELEASETYPE} =3D=3D -git ]]; then + KERNEL_URI=3D"${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2 + ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${OKV}${RELEASE}.bz2" + fi + + if [[ ${RELEASETYPE} =3D=3D -rc-git ]]; then + OKV=3D"${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))" + KERNEL_URI=3D"${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_MIN= OR}.${KV_PATCH}${RELEASE}.bz2 + ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATC= H}${RELEASE/-git*}.bz2 + ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" + + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${K= V_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${K= V_PATCH}${RELEASE}.bz2" + fi + else + if [[ ${RELEASETYPE} =3D=3D -rc ]] || [[ ${RELEASETYPE} =3D=3D -pre ]]= ; then + if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then + OKV=3D"2.6.39" + else + KV_PATCH_ARR=3D(${KV_PATCH//\./ }) + OKV=3D"${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))" + fi + KERNEL_URI=3D"${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2 + ${KERNEL_BASE_URI}/testing/linux-${OKV}.tar.bz2" + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${CKV//_/-}.bz2" + fi + + if [[ ${RELEASETYPE} =3D=3D -git ]]; then + KERNEL_URI=3D"${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2 + ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${OKV}${RELEASE}.bz2" + fi + + if [[ ${RELEASETYPE} =3D=3D -rc-git ]]; then + if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then + OKV=3D"2.6.39" + else + KV_PATCH_ARR=3D(${KV_PATCH//\./ }) + OKV=3D"${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))" + fi + KERNEL_URI=3D"${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_PAT= CH}${RELEASE}.bz2 + ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/= -git*}.bz2 + ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2" + + UNIPATCH_LIST_DEFAULT=3D"${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RE= LEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.bz2" + fi + + + fi + + + debug-print-kernel2-variables + + handle_genpatches +} + +# Note: duplicated in linux-info.eclass +kernel_is() { + # ALL of these should be set before we can safely continue this functio= n. + # some of the sources have in the past had only one set. + local v n=3D0 + for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=3D1 ; done + [[ $n -eq 1 ]] && detect_version + unset v n + + # Now we can continue + local operator test value + + case ${1#-} in + lt) operator=3D"-lt"; shift;; + gt) operator=3D"-gt"; shift;; + le) operator=3D"-le"; shift;; + ge) operator=3D"-ge"; shift;; + eq) operator=3D"-eq"; shift;; + *) operator=3D"-eq";; + esac + [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many paramete= rs" + + : $(( test =3D (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH )) + : $(( value =3D (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + = ${3:-${KV_PATCH}} )) + [ ${test} ${operator} ${value} ] +} + +kernel_is_2_4() { + kernel_is 2 4 +} + +kernel_is_2_6() { + kernel_is 2 6 || kernel_is 2 5 +} + +# Capture the sources type and set DEPENDs +if [[ ${ETYPE} =3D=3D sources ]]; then + DEPEND=3D"!build? ( sys-apps/sed + >=3Dsys-devel/binutils-2.11.90.0.31 )" + RDEPEND=3D"!build? ( >=3Dsys-libs/ncurses-5.2 + sys-devel/make )" + + SLOT=3D"${PVR}" + DESCRIPTION=3D"Sources for the ${KV_MAJOR}.${KV_MINOR:-$KV_PATCH} linux= kernel" + IUSE=3D"symlink build" + + # Bug #266157, deblob for libre support + if [[ -z ${K_PREDEBLOBBED} ]] ; then + # Bug #359865, force a call to detect_version if needed + kernel_is ge 2 6 27 && \ + [[ -z "${K_DEBLOB_AVAILABLE}" ]] && \ + kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \ + K_DEBLOB_AVAILABLE=3D1 + if [[ ${K_DEBLOB_AVAILABLE} =3D=3D "1" ]] ; then + IUSE=3D"${IUSE} deblob" + # Reflect that kernels contain firmware blobs unless otherwise + # stripped + LICENSE=3D"${LICENSE} !deblob? ( freedist )" + + if [[ -n KV_MINOR ]]; then + DEBLOB_PV=3D"${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" + else + DEBLOB_PV=3D"${KV_MAJOR}.${KV_PATCH}" + fi + + if [[ ${KV_MAJOR} -ge 3 ]]; then + DEBLOB_PV=3D"${KV_MAJOR}.${KV_MINOR}" + fi + + DEBLOB_A=3D"deblob-${DEBLOB_PV}" + DEBLOB_CHECK_A=3D"deblob-check-${DEBLOB_PV}" + DEBLOB_HOMEPAGE=3D"http://www.fsfla.org/svnwiki/selibre/linux-libre/" + DEBLOB_URI_PATH=3D"download/releases/LATEST-${DEBLOB_PV}.N" + if ! has "${EAPI:-0}" 0 1 ; then + DEBLOB_CHECK_URI=3D"${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-che= ck -> ${DEBLOB_CHECK_A}" + else + DEBLOB_CHECK_URI=3D"mirror://gentoo/${DEBLOB_CHECK_A}" + fi + DEBLOB_URI=3D"${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}" + HOMEPAGE=3D"${HOMEPAGE} ${DEBLOB_HOMEPAGE}" + + KERNEL_URI=3D"${KERNEL_URI} + deblob? ( + ${DEBLOB_URI} + ${DEBLOB_CHECK_URI} + )" + else + # We have no way to deblob older kernels, so just mark them as + # tainted with non-libre materials. + LICENSE=3D"${LICENSE} freedist" + fi + fi + +elif [[ ${ETYPE} =3D=3D headers ]]; then + DESCRIPTION=3D"Linux system headers" + + # Since we should NOT honour KBUILD_OUTPUT in headers + # lets unset it here. + unset KBUILD_OUTPUT + + SLOT=3D"0" +else + eerror "Unknown ETYPE=3D\"${ETYPE}\", must be \"sources\" or \"headers\= "" + die "Unknown ETYPE=3D\"${ETYPE}\", must be \"sources\" or \"headers\"" +fi + +# Cross-compile support functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +kernel_header_destdir() { + [[ ${CTARGET} =3D=3D ${CHOST} ]] \ + && echo /usr/include \ + || echo /usr/${CTARGET}/usr/include +} + +cross_pre_c_headers() { + use crosscompile_opts_headers-only && [[ ${CHOST} !=3D ${CTARGET} ]] +} + +env_setup_xmakeopts() { + # Kernel ARCH !=3D portage ARCH + export KARCH=3D$(tc-arch-kernel) + + # When cross-compiling, we need to set the ARCH/CROSS_COMPILE + # variables properly or bad things happen ! + xmakeopts=3D"ARCH=3D${KARCH}" + if [[ ${CTARGET} !=3D ${CHOST} ]] && ! cross_pre_c_headers ; then + xmakeopts=3D"${xmakeopts} CROSS_COMPILE=3D${CTARGET}-" + elif type -p ${CHOST}-ar > /dev/null ; then + xmakeopts=3D"${xmakeopts} CROSS_COMPILE=3D${CHOST}-" + fi + export xmakeopts +} + +# Unpack functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +unpack_2_4() { + # this file is required for other things to build properly, + # so we autogenerate it + make -s mrproper ${xmakeopts} || die "make mrproper failed" + make -s symlinks ${xmakeopts} || die "make symlinks failed" + make -s include/linux/version.h ${xmakeopts} || die "make include/linux= /version.h failed" + echo ">>> version.h compiled successfully." +} + +unpack_2_6() { + # this file is required for other things to build properly, so we + # autogenerate it ... generate a .config to keep version.h build from + # spitting out an annoying warning + make -s mrproper ${xmakeopts} 2>/dev/null \ + || die "make mrproper failed" + + # quick fix for bug #132152 which triggers when it cannot include linux + # headers (ie, we have not installed it yet) + if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then + touch .config + eerror "make defconfig failed." + eerror "assuming you dont have any headers installed yet and continuin= g" + epause 5 + fi + + make -s include/linux/version.h ${xmakeopts} 2>/dev/null \ + || die "make include/linux/version.h failed" + rm -f .config >/dev/null +} + +universal_unpack() { + debug-print "Inside universal_unpack" + + local OKV_ARRAY + IFS=3D"." read -r -a OKV_ARRAY <<<"${OKV}" + + cd "${WORKDIR}" + if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then + unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2 + else + unpack linux-${OKV}.tar.bz2 + fi + + if [[ -d "linux" ]]; then + debug-print "Moving linux to linux-${KV_FULL}" + mv linux linux-${KV_FULL} \ + || die "Unable to move source tree to ${KV_FULL}." + elif [[ "${OKV}" !=3D "${KV_FULL}" ]]; then + if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]] && + [[ "${ETYPE}" =3D "sources" ]]; then + debug-print "moving linux-${KV_MAJOR}.${KV_MINOR} to linux-${KV_FULL}= " + mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \ + || die "Unable to move source tree to ${KV_FULL}." + else + debug-print "moving linux-${OKV} to linux-${KV_FULL} " + mv linux-${OKV} linux-${KV_FULL} \ + || die "Unable to move source tree to ${KV_FULL}." + fi + elif [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then + mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \ + || die "Unable to move source tree to ${KV_FULL}." + fi + cd "${S}" + + # remove all backup files + find . -iname "*~" -exec rm {} \; 2> /dev/null + + # fix a problem on ppc where TOUT writes to /usr/src/linux breaking san= dbox + # only do this for kernel < 2.6.27 since this file does not exist in la= ter + # kernels + if [[ -n ${KV_MINOR} && ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]= ] + then + sed -i \ + -e 's|TOUT :=3D .tmp_gas_check|TOUT :=3D $(T).tmp_gas_check|' \ + "${S}"/arch/ppc/Makefile + else + sed -i \ + -e 's|TOUT :=3D .tmp_gas_check|TOUT :=3D $(T).tmp_gas_check|' \ + "${S}"/arch/powerpc/Makefile + fi +} + +unpack_set_extraversion() { + cd "${S}" + sed -i -e "s:^\(EXTRAVERSION =3D\).*:\1 ${EXTRAVERSION}:" Makefile + cd "${OLDPWD}" +} + +# Should be done after patches have been applied +# Otherwise patches that modify the same area of Makefile will fail +unpack_fix_install_path() { + cd "${S}" + sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile +} + +# Compile Functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +compile_headers() { + env_setup_xmakeopts + + # if we couldnt obtain HOSTCFLAGS from the Makefile, + # then set it to something sane + local HOSTCFLAGS=3D$(getfilevar HOSTCFLAGS "${S}"/Makefile) + HOSTCFLAGS=3D${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-p= ointer} + + if kernel_is 2 4; then + yes "" | make oldconfig ${xmakeopts} + echo ">>> make oldconfig complete" + make dep ${xmakeopts} + elif kernel_is 2 6; then + # 2.6.18 introduces headers_install which means we dont need any + # of this crap anymore :D + kernel_is ge 2 6 18 && return 0 + + # autoconf.h isnt generated unless it already exists. plus, we have + # no guarantee that any headers are installed on the system... + [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \ + || touch include/linux/autoconf.h + + # if K_DEFCONFIG isn't set, force to "defconfig" + # needed by mips + if [[ -z ${K_DEFCONFIG} ]]; then + if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then + case ${CTARGET} in + powerpc64*) K_DEFCONFIG=3D"ppc64_defconfig";; + powerpc*) K_DEFCONFIG=3D"pmac32_defconfig";; + *) K_DEFCONFIG=3D"defconfig";; + esac + else + K_DEFCONFIG=3D"defconfig" + fi + fi + + # if there arent any installed headers, then there also isnt an asm + # symlink in /usr/include/, and make defconfig will fail, so we have + # to force an include path with $S. + HOSTCFLAGS=3D"${HOSTCFLAGS} -I${S}/include/" + ln -sf asm-${KARCH} "${S}"/include/asm + cross_pre_c_headers && return 0 + + make ${K_DEFCONFIG} HOSTCFLAGS=3D"${HOSTCFLAGS}" ${xmakeopts} || die "= defconfig failed (${K_DEFCONFIG})" + if compile_headers_tweak_config ; then + yes "" | make oldconfig HOSTCFLAGS=3D"${HOSTCFLAGS}" ${xmakeopts} || = die "2nd oldconfig failed" + fi + make prepare HOSTCFLAGS=3D"${HOSTCFLAGS}" ${xmakeopts} || die "prepare= failed" + make prepare-all HOSTCFLAGS=3D"${HOSTCFLAGS}" ${xmakeopts} || die "pre= pare failed" + fi +} + +compile_headers_tweak_config() { + # some targets can be very very picky, so let's finesse the + # .config based upon any info we may have + case ${CTARGET} in + sh*) + sed -i '/CONFIG_CPU_SH/d' .config + echo "CONFIG_CPU_SH${CTARGET:2:1}=3Dy" >> .config + return 0;; + esac + + # no changes, so lets do nothing + return 1 +} + +# install functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +install_universal() { + #fix silly permissions in tarball + cd "${WORKDIR}" + chown -R root:0 * >& /dev/null + chmod -R a+r-w+X,u+w * + cd ${OLDPWD} +} + +install_headers() { + local ddir=3D$(kernel_header_destdir) + + # 2.6.18 introduces headers_install which means we dont need any + # of this crap anymore :D + if kernel_is ge 2 6 18 ; then + env_setup_xmakeopts + emake headers_install INSTALL_HDR_PATH=3D"${D}"/${ddir}/.. ${xmakeopts= } || die + + # let other packages install some of these headers + rm -rf "${D}"/${ddir}/sound #alsa-headers + rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc... + return 0 + fi + + # Do not use "linux/*" as that can cause problems with very long + # $S values where the cmdline to cp is too long + pushd "${S}" >/dev/null + dodir ${ddir}/linux + cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die + rm -rf "${D}"/${ddir}/linux/modules + + dodir ${ddir}/asm + cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm + + if kernel_is 2 6 ; then + dodir ${ddir}/asm-generic + cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic + fi + + # clean up + find "${D}" -name '*.orig' -exec rm -f {} \; + + popd >/dev/null +} + +install_sources() { + local file + + cd "${S}" + dodir /usr/src + echo ">>> Copying sources ..." + + file=3D"$(find ${WORKDIR} -iname "docs" -type d)" + if [[ -n ${file} ]]; then + for file in $(find ${file} -type f); do + echo "${file//*docs\/}" >> "${S}"/patches.txt + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D" >> "${S}"/patches.txt + cat ${file} >> "${S}"/patches.txt + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D" >> "${S}"/patches.txt + echo "" >> "${S}"/patches.txt + done + fi + + if [[ ! -f ${S}/patches.txt ]]; then + # patches.txt is empty so lets use our ChangeLog + [[ -f ${FILESDIR}/../ChangeLog ]] && \ + echo "Please check the ebuild ChangeLog for more details." \ + > "${S}"/patches.txt + fi + + mv ${WORKDIR}/linux* "${D}"/usr/src +} + +# pkg_preinst functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +preinst_headers() { + local ddir=3D$(kernel_header_destdir) + [[ -L ${ddir}/linux ]] && rm ${ddir}/linux + [[ -L ${ddir}/asm ]] && rm ${ddir}/asm +} + +# pkg_postinst functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +postinst_sources() { + local MAKELINK=3D0 + + # if we have USE=3Dsymlink, then force K_SYMLINK=3D1 + use symlink && K_SYMLINK=3D1 + + # if we're using a deblobbed kernel, it's not supported + [[ $K_DEBLOB_AVAILABLE =3D=3D 1 ]] && \ + use deblob && \ + K_SECURITY_UNSUPPORTED=3Ddeblob + + # if we are to forcably symlink, delete it if it already exists first. + if [[ ${K_SYMLINK} > 0 ]]; then + [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux + MAKELINK=3D1 + fi + + # if the link doesnt exist, lets create it + [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=3D1 + + if [[ ${MAKELINK} =3D=3D 1 ]]; then + cd "${ROOT}"usr/src + ln -sf linux-${KV_FULL} linux + cd ${OLDPWD} + fi + + # Don't forget to make directory for sysfs + [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys + + echo + elog "If you are upgrading from a previous kernel, you may be intereste= d" + elog "in the following document:" + elog " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-up= grade.xml" + echo + + # if K_EXTRAEINFO is set then lets display it now + if [[ -n ${K_EXTRAEINFO} ]]; then + echo ${K_EXTRAEINFO} | fmt | + while read -s ELINE; do einfo "${ELINE}"; done + fi + + # if K_EXTRAELOG is set then lets display it now + if [[ -n ${K_EXTRAELOG} ]]; then + echo ${K_EXTRAELOG} | fmt | + while read -s ELINE; do elog "${ELINE}"; done + fi + + # if K_EXTRAEWARN is set then lets display it now + if [[ -n ${K_EXTRAEWARN} ]]; then + echo ${K_EXTRAEWARN} | fmt | + while read -s ELINE; do ewarn "${ELINE}"; done + fi + + # optionally display security unsupported message + # Start with why + if [[ ${K_SECURITY_UNSUPPORTED} =3D deblob ]]; then + ewarn "Deblobbed kernels are UNSUPPORTED by Gentoo Security." + elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then + ewarn "${PN} is UNSUPPORTED by Gentoo Security." + fi + # And now the general message. + if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then + ewarn "This means that it is likely to be vulnerable to recent securit= y issues." + ewarn "For specific information on why this kernel is unsupported, ple= ase read:" + ewarn "http://www.gentoo.org/proj/en/security/kernel.xml" + fi + + # warn sparc users that they need to do cross-compiling with >=3D 2.6.2= 5(bug #214765) + KV_MAJOR=3D$(get_version_component_range 1 ${OKV}) + KV_MINOR=3D$(get_version_component_range 2 ${OKV}) + KV_PATCH=3D$(get_version_component_range 3 ${OKV}) + if [[ "$(tc-arch)" =3D "sparc" ]]; then + if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.2= 4 ]] + then + echo + elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way tha= t" + elog "you now need to do" + elog " make CROSS_COMPILE=3Dsparc64-unknown-linux-gnu-" + elog "instead of just" + elog " make" + elog "to compile the kernel. For more information please browse to" + elog "https://bugs.gentoo.org/show_bug.cgi?id=3D214765" + echo + fi + fi +} + +# pkg_setup functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +setup_headers() { + [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=3D${PN/-*/} + for i in ${H_SUPPORTEDARCH}; do + [[ $(tc-arch) =3D=3D "${i}" ]] && H_ACCEPT_ARCH=3D"yes" + done + + if [[ ${H_ACCEPT_ARCH} !=3D "yes" ]]; then + echo + eerror "This version of ${PN} does not support $(tc-arch)." + eerror "Please merge the appropriate sources, in most cases" + eerror "(but not all) this will be called $(tc-arch)-headers." + die "Package unsupported for $(tc-arch)" + fi +} + +# unipatch +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +unipatch() { + local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH E= LINE + local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG + + # set to a standard locale to ensure sorts are ordered properly. + myLC_ALL=3D"${LC_ALL}" + myLANG=3D"${LANG}" + LC_ALL=3D"C" + LANG=3D"" + + [ -z "${KPATCH_DIR}" ] && KPATCH_DIR=3D"${WORKDIR}/patches/" + [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} + + # We're gonna need it when doing patches with a predefined patchlevel + eshopts_push -s extglob + + # This function will unpack all passed tarballs, add any passed patches= , and remove any passed patchnumbers + # usage can be either via an env var or by params + # although due to the nature we pass this within this eclass + # it shall be by param only. + # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST=3D"${@}" + UNIPATCH_LIST=3D"${@}" + + #unpack any passed tarballs + for i in ${UNIPATCH_LIST}; do + if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then + if [ -n "${UNIPATCH_STRICTORDER}" ]; then + unset z + STRICT_COUNT=3D$((10#${STRICT_COUNT} + 1)) + for((y=3D0; y<$((6 - ${#STRICT_COUNT})); y++)); + do z=3D"${z}0"; + done + PATCH_ORDER=3D"${z}${STRICT_COUNT}" + + mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}" + pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null + unpack ${i##*/} + popd >/dev/null + else + pushd "${KPATCH_DIR}" >/dev/null + unpack ${i##*/} + popd >/dev/null + fi + + [[ ${i} =3D=3D *:* ]] && echo ">>> Strict patch levels not currently = supported for tarballed patchsets" + else + extention=3D${i/*./} + extention=3D${extention/:*/} + PIPE_CMD=3D"" + case ${extention} in + xz) PIPE_CMD=3D"xz -dc";; + lzma) PIPE_CMD=3D"lzma -dc";; + bz2) PIPE_CMD=3D"bzip2 -dc";; + patch) PIPE_CMD=3D"cat";; + diff) PIPE_CMD=3D"cat";; + gz|Z|z) PIPE_CMD=3D"gzip -dc";; + ZIP|zip) PIPE_CMD=3D"unzip -p";; + *) UNIPATCH_DROP=3D"${UNIPATCH_DROP} ${i/:*/}";; + esac + + PATCH_LEVEL=3D${i/*([^:])?(:)} + i=3D${i/:*/} + x=3D${i/*\//} + x=3D${x/\.${extention}/} + + if [ -n "${PIPE_CMD}" ]; then + if [ ! -r "${i}" ]; then + echo + eerror "FATAL: unable to locate:" + eerror "${i}" + eerror "for read-only. The file either has incorrect permissions" + eerror "or does not exist." + die Unable to locate ${i} + fi + + if [ -n "${UNIPATCH_STRICTORDER}" ]; then + unset z + STRICT_COUNT=3D$((10#${STRICT_COUNT} + 1)) + for((y=3D0; y<$((6 - ${#STRICT_COUNT})); y++)); + do z=3D"${z}0"; + done + PATCH_ORDER=3D"${z}${STRICT_COUNT}" + + mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/ + $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH= _LEVEL}) || die "uncompressing patch failed" + else + $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) || die= "uncompressing patch failed" + fi + fi + fi + done + + #populate KPATCH_DIRS so we know where to look to remove the excludes + x=3D${KPATCH_DIR} + KPATCH_DIR=3D"" + for i in $(find ${x} -type d | sort -n); do + KPATCH_DIR=3D"${KPATCH_DIR} ${i}" + done + + # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot + # bug #272676 + if [[ "$(tc-arch)" =3D "sparc" || "$(tc-arch)" =3D "sparc64" ]]; then + if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.2= 8 ]]; then + UNIPATCH_DROP=3D"${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch" + echo + ewarn "fbcondecor currently prevents sparc/sparc64 from booting" + ewarn "for kernel versions >=3D 2.6.29. Removing fbcondecor patch." + ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=3D272676 for detai= ls" + echo + fi + fi + + #so now lets get rid of the patchno's we want to exclude + UNIPATCH_DROP=3D"${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}" + for i in ${UNIPATCH_DROP}; do + ebegin "Excluding Patch #${i}" + for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done + eend $? + done + + # and now, finally, we patch it :) + for x in ${KPATCH_DIR}; do + for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*= " | sort -n); do + STDERR_T=3D"${T}/${i/*\//}" + STDERR_T=3D"${STDERR_T/.patch*/.err}" + + [ -z ${i/*.patch*/} ] && PATCH_DEPTH=3D${i/*.patch/} + #[ -z ${i/*.diff*/} ] && PATCH_DEPTH=3D${i/*.diff/} + + if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=3D0; fi + + ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)" + while [ ${PATCH_DEPTH} -lt 5 ]; do + echo "Attempting Dry-run:" >> ${STDERR_T} + echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run = -f < ${i}" >> ${STDERR_T} + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D" >> ${STDERR_T} + if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f <= ${i} >> ${STDERR_T}) $? -eq 0 ]; then + echo "Attempting patch:" > ${STDERR_T} + echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}= " >> ${STDERR_T} + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D" >> ${STDERR_T} + if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> = ${STDERR_T}) "$?" -eq 0 ]; then + eend 0 + rm ${STDERR_T} + break + else + eend 1 + eerror "Failed to apply patch ${i/*\//}" + eerror "Please attach ${STDERR_T} to any bug you may post." + eshopts_pop + die "Failed to apply ${i/*\//}" + fi + else + PATCH_DEPTH=3D$((${PATCH_DEPTH} + 1)) + fi + done + if [ ${PATCH_DEPTH} -eq 5 ]; then + eend 1 + eerror "Please attach ${STDERR_T} to any bug you may post." + eshopts_pop + die "Unable to dry-run patch." + fi + done + done + + # This is a quick, and kind of nasty hack to deal with UNIPATCH_DOCS wh= ich + # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite= , + # which is why I'm not taking too much time over this. + local tmp + for i in ${UNIPATCH_DOCS}; do + tmp=3D"${tmp} ${i//*\/}" + cp -f ${i} "${T}"/ + done + UNIPATCH_DOCS=3D"${tmp}" + + # clean up KPATCH_DIR's - fixes bug #53610 + for x in ${KPATCH_DIR}; do rm -Rf ${x}; done + + LC_ALL=3D"${myLC_ALL}" + LANG=3D"${myLANG}" + eshopts_pop +} + +# getfilevar accepts 2 vars as follows: +# getfilevar +# pulled from linux-info + +getfilevar() { + local workingdir basefname basedname xarch=3D$(tc-arch-kernel) + + if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then + echo -e "\n" + eerror "getfilevar requires 2 variables, with the second a valid file.= " + eerror " getfilevar " + else + workingdir=3D${PWD} + basefname=3D$(basename ${2}) + basedname=3D$(dirname ${2}) + unset ARCH + + cd ${basedname} + echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \ + make ${BUILD_FIXES} -s -f - e 2>/dev/null + cd ${workingdir} + + ARCH=3D${xarch} + fi +} + +detect_arch() { + # This function sets ARCH_URI and ARCH_PATCH + # with the neccessary info for the arch sepecific compatibility + # patchsets. + + local ALL_ARCH LOOP_ARCH COMPAT_URI i + + # COMPAT_URI is the contents of ${ARCH}_URI + # ARCH_URI is the URI for all the ${ARCH}_URI patches + # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH + + ARCH_URI=3D"" + ARCH_PATCH=3D"" + ALL_ARCH=3D"ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC= X86" + + for LOOP_ARCH in ${ALL_ARCH}; do + COMPAT_URI=3D"${LOOP_ARCH}_URI" + COMPAT_URI=3D"${!COMPAT_URI}" + + [[ -n ${COMPAT_URI} ]] && \ + ARCH_URI=3D"${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower= :]')? ( ${COMPAT_URI} )" + + if [[ ${LOOP_ARCH} =3D=3D "$(echo $(tc-arch-kernel) | tr '[:lower:]' '= [:upper:]')" ]]; then + for i in ${COMPAT_URI}; do + ARCH_PATCH=3D"${ARCH_PATCH} ${DISTDIR}/${i/*\//}" + done + fi + done +} + +headers___fix() { + # Voodoo to partially fix broken upstream headers. + # note: do not put inline/asm/volatile together (breaks "inline asm vol= atile") + sed -i \ + -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \ + -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \ + -e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \ + -e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \ + -e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \ + "$@" +} + +# common functions +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +kernel-2_src_unpack() { + universal_unpack + debug-print "Doing unipatch" + + [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_= LIST_GENPATCHES} ]] && \ + unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPA= TCH_LIST}" + + debug-print "Doing premake" + + # allow ebuilds to massage the source tree after patching but before + # we run misc `make` functions below + [[ $(type -t kernel-2_hook_premake) =3D=3D "function" ]] && kernel-2_ho= ok_premake + + debug-print "Doing epatch_user" + epatch_user + + debug-print "Doing unpack_set_extraversion" + + [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion + unpack_fix_install_path + + # Setup xmakeopts and cd into sourcetree. + env_setup_xmakeopts + cd "${S}" + + # We dont need a version.h for anything other than headers + # at least, I should hope we dont. If this causes problems + # take out the if/fi block and inform me please. + # unpack_2_6 should now be 2.6.17 safe anyways + if [[ ${ETYPE} =3D=3D headers ]]; then + kernel_is 2 4 && unpack_2_4 + kernel_is 2 6 && unpack_2_6 + fi + + if [[ $K_DEBLOB_AVAILABLE =3D=3D 1 ]] && use deblob ; then + cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed" + cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEB= LOB_CHECK_A} failed" + chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob s= cripts failed" + fi +} + +kernel-2_src_compile() { + cd "${S}" + [[ ${ETYPE} =3D=3D headers ]] && compile_headers + + if [[ $K_DEBLOB_AVAILABLE =3D=3D 1 ]] && use deblob ; then + echo ">>> Running deblob script ..." + sh "${T}/${DEBLOB_A}" --force || \ + die "Deblob script failed to run!!!" + fi +} + +# if you leave it to the default src_test, it will run make to +# find whether test/check targets are present; since "make test" +# actually produces a few support files, they are installed even +# though the package is binchecks-restricted. +# +# Avoid this altogether by making the function moot. +kernel-2_src_test() { :; } + +kernel-2_pkg_preinst() { + [[ ${ETYPE} =3D=3D headers ]] && preinst_headers +} + +kernel-2_src_install() { + install_universal + [[ ${ETYPE} =3D=3D headers ]] && install_headers + [[ ${ETYPE} =3D=3D sources ]] && install_sources +} + +kernel-2_pkg_postinst() { + [[ ${ETYPE} =3D=3D sources ]] && postinst_sources +} + +kernel-2_pkg_setup() { + if kernel_is 2 4; then + if [[ $(gcc-major-version) -ge 4 ]] ; then + echo + ewarn "Be warned !! >=3Dsys-devel/gcc-4.0.0 isn't supported with linu= x-2.4!" + ewarn "Either switch to another gcc-version (via gcc-config) or use a= " + ewarn "newer kernel that supports gcc-4." + echo + ewarn "Also be aware that bugreports about gcc-4 not working" + ewarn "with linux-2.4 based ebuilds will be closed as INVALID!" + echo + epause 10 + fi + fi + + ABI=3D"${KERNEL_ABI}" + [[ ${ETYPE} =3D=3D headers ]] && setup_headers + [[ ${ETYPE} =3D=3D sources ]] && echo ">>> Preparing to unpack ..." +} + +kernel-2_pkg_postrm() { + # This warning only makes sense for kernel sources. + [[ ${ETYPE} =3D=3D headers ]] && return 0 + + # If there isn't anything left behind, then don't complain. + [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0 + echo + ewarn "Note: Even though you have successfully unmerged " + ewarn "your kernel package, directories in kernel source location: " + ewarn "${ROOT}usr/src/linux-${KV_FULL}" + ewarn "with modified files will remain behind. By design, package manag= ers" + ewarn "will not remove these modified files and the directories they re= side in." + echo +}