--- branches/magellan-next/include/kernel.sminc 2011/12/01 16:48:58 9466 +++ trunk/include/kernel.sminc 2012/03/04 14:16:15 11369 @@ -2,16 +2,20 @@ # $Id$ # needed extra vars: -# ${KERNEL_TYPE}: needed, 'sources', 'headers' or 'image' -# ${BRANCH}: needed, style branch of the kernel -# ${KERNEL_CONFIG}: optional, needed if you want to override the default -# searchpath ${SOURCEDIR}/${PNAME}/config-${PVER}-${BRANCH}-${PBUILD} +# ${KERNEL_TYPE}: needed, 'sources', 'headers' or 'image' +# ${BRANCH}: needed, style branch of the kernel +# ${KERNEL_CONFIG}: optional, needed if you want to override the default +# searchpath ${SOURCEDIR}/${PNAME}/config-${PVER}-${BRANCH}-${PBUILD} +# +# ${PSUBVER}: optional, only needed for 2.6.x.x naming scheme +# ${EXTRAVERSION}: optinal, extra version for the kernel name +# default setting is ${PSUBVER}-${BRANCH}-${PBUILD} +# ${KERNEL_IMAGE_PATH}: override the default KERNEL_IMAGE_PATH (to build xen images for e.g.) +# ${COMPRESS_MODULES}: compresses the kernel modules with given compressor (gzip|bzip2|xz) +# ${LINUX_FIRMWARE}: remove included firmware bits if requested +# set the version here like USE_LINUX_FIRMARE="20110605" +# version "internal" keeps the bits too # -# ${PSUBVER}: optional, only needed for 2.6.x.x naming scheme -# ${EXTRAVERSION}: optinal, extra version for the kernel name -# default setting is ${PSUBVER}-${BRANCH}-${PBUILD} -# ${KERNEL_IMAGE_PATH}: override the default KERNEL_IMAGE_PATH (to build xen images for e.g.) -# ${COMPRESS_MODULES}: compresses the kernel modules with given compressor (gzip|bzip2|xz) sminclude mtools @@ -23,15 +27,6 @@ KERNEL_ARCH_EXTENSION="" fi -# remove included firmware bits if requested -# set the version here like USE_LINUX_FIRMARE="20110605" -# version "internal" keeps the bits too -if [[ ! -z ${LINUX_FIRMWARE} ]] && [[ ${LINUX_FIRMWARE} != internal ]] -then - DEPEND="${DEPEND} - >= sys-kernel/linux-firmware-${LINUX_FIRMWARE}" -fi - if [[ ! -z ${COMPRESS_MODULES} ]] then case ${COMPRESS_MODULES} in @@ -59,51 +54,48 @@ fi # some sane defaults -: ${PCATEGORIE="sys-kernel"} +: ${PCAT="sys-kernel"} : ${HOMEPAGE="http://magellan-linux.de/"} -: ${SRCFILE="linux-${PVER/${PSUBVER}/}.tar.bz2"} -: ${SRCDIR="${BUILDDIR}/linux-${PVER}-${BRANCH}-${PBUILD}"} : ${TARBALLPVER="${PVER}"} +: ${SRCFILE="linux-${TARBALLPVER}.tar.bz2"} +: ${SRCDIR="${BUILDDIR}/linux-${PVER}-${BRANCH}-${PBUILD}"} -case ${KERNEL_TYPE} in - image|sources) - if [[ -z ${SRC_URI[*]} ]] - then - SRC_URI=( - http://www.kernel.org/pub/linux/kernel/v$(echo ${PVER} | cut -d. -f1).x/${SRCFILE} - http://ftp.uni-erlangen.de/pub/Linux/MIRROR.kernel/v$(echo ${PVER} | cut -d. -f1).x/${SRCFILE} - mirror://kernel-${BRANCH}/${SRCFILE} - mirror://kernel-${BRANCH}/config-${PVER}-${BRANCH}-${PBUILD}-i686 - mirror://kernel-${BRANCH}/config-${PVER}-${BRANCH}-${PBUILD}-x86_64 - ) - fi - ;; - - headers) - if [[ -z ${SRC_URI[*]} ]] - then - SRC_URI=( - http://www.kernel.org/pub/linux/kernel/v$(echo ${PVER} | cut -d. -f1-2)/${SRCFILE} - http://ftp.uni-erlangen.de/pub/Linux/MIRROR.kernel/v$(echo ${PVER} | cut -d. -f1-2)/${SRCFILE} - mirror://kernel-${BRANCH}/${SRCFILE} - ) - fi - ;; -esac +if [[ -z ${SRC_URI[*]} ]] +then + SRC_URI=( + http://www.kernel.org/pub/linux/kernel/v$(echo ${PVER} | cut -d. -f1).x/${SRCFILE} + http://ftp.uni-erlangen.de/pub/Linux/MIRROR.kernel/v$(echo ${PVER} | cut -d. -f1).x/${SRCFILE} + mirror://kernel-${BRANCH}/${SRCFILE} + ) + case ${KERNEL_TYPE} in + image|sources) + SRC_URI=( + ${SRC_URI[*]} + mirror://kernel-${BRANCH}/config-${PVER}-${BRANCH}-${PBUILD}-i686 + mirror://kernel-${BRANCH}/config-${PVER}-${BRANCH}-${PBUILD}-x86_64 + ) + ;; + esac +fi case ${KERNEL_TYPE} in image) : ${PROVIDE="virtual/kernel"} - : ${DEPEND=">= sys-apps/module-init-tools-3.2 + : ${DEPEND=">= virtual/module-tools >= sys-fs/udev-115 - >= sys-apps/mkinitrd-5.0.8 + >= virtual/initramfs-tools >= virtual/initscripts"} - : ${DESCRIPTION="Kernel image of the '${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}' kernel."} + if [[ ! -z ${LINUX_FIRMWARE} ]] && [[ ${LINUX_FIRMWARE} != internal ]] + then + DEPEND="${DEPEND} + >= sys-kernel/linux-firmware-${LINUX_FIRMWARE}" + fi + : ${DESCRIPTION="Kernel image of the '${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}' kernel branch."} ;; sources) : ${PROVIDE="virtual/kernel-sources"} - : ${DESCRIPTION="Kernel sources of the '${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}' kernel."} + : ${DESCRIPTION="Kernel sources of the '${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}' kernel branch."} ;; headers) @@ -124,7 +116,7 @@ kernel_src_prepare() { munpack ${SRCFILE} || die - mv ${BUILDDIR}/linux-${TARBALLPVER/${PSUBVER}/} ${SRCDIR} || die + mv ${BUILDDIR}/linux-${TARBALLPVER} ${SRCDIR} || die # fix permissions chown -R 0:0 ${SRCDIR} || die @@ -284,6 +276,9 @@ { cd ${SRCDIR} make ARCH=${ARCH/i*86/x86} INSTALL_HDR_PATH=${BINDIR}/usr headers_install || die + + # clean-up unnecessary files + find ${BINDIR} -name .install -or -name ..install.cmd | xargs --no-run-if-empty rm -f } kernel_sources_src_install() @@ -439,21 +434,23 @@ { # check for linux-VERSION/include as the kernel-image installs # the file Modules.symver in the linux-VERSION directory - if [ ! -d ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD}/include ] + if mqueryfeature "kernelsrcunpack" && + [ ! -d ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD}/include ] then echo "Unpacking linux-${KPVER}-${KBRANCH}-${KPBUILD} source tarball ... " tar xvjf ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD}.tar.bz2 -C ${MROOT}/usr/src fi - if [ ! -d ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} ] && + if mqueryfeature "kernelsrcunpack" && + [ ! -d ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} ] && [ -f ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD}.tar.bz2 ] then echo "Unpacking kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} source tarball ... " tar xvjf ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD}.tar.bz2 -C ${MROOT}/usr/src fi - # if not exist create linux symlink - if [ ! -h ${MROOT}/usr/src/linux ] + # create linux symlink + if mqueryfeature "linuxsymlink" then echo "Creating linux -> linux-${KPVER}-${KBRANCH}-${KPBUILD} symlink ... " [ ! -d ${MROOT}/usr/src ] && install ${MROOT}/usr/src @@ -461,8 +458,8 @@ ${MROOT}/usr/src/linux || die fi - # if not exist create kernel-modules symlink - if [ ! -h ${MROOT}/usr/src/kernel-modules ] && + # create kernel-modules symlink + if mqueryfeature "linuxsymlink" && [ -d ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} ] then echo "Creating kernel-modules -> kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} symlink ... "