inherit versionator EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst [[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}" export CTARGET=${CTARGET:-${CHOST}} if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then export CTARGET=${CATEGORY/cross-} fi RESTRICT="binchecks strip primaryuri" [[ -z ${LINUX_HOSTCFLAGS} ]] && \ LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include" #Eclass functions only from here onwards ... #============================================================== detect_version() { if [[ -n ${KV_FULL} ]]; then # we will set this for backwards compatibility. KV=${KV_FULL} # we know KV_FULL so lets stop here. but not without resetting S S=${WORKDIR}/linux-${KV_FULL} return fi CKV=${CKV:-${PV}} OKV=${OKV:-${CKV}} OKV=${OKV/_rc/-rc} OKV=${OKV/-r*} KV_MAJOR=$(get_version_component_range 1 ${OKV}) KV_MINOR=$(get_version_component_range 2 ${OKV}) KV_PATCH=$(get_version_component_range 3- ${OKV}) KV_PATCH=${KV_PATCH/[-_]*} KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" RELEASE=${CKV/${OKV}} RELEASE=${RELEASE/_rc/-rc} RELEASETYPE=${RELEASE//[0-9]} MM_REV=$(echo ${PR} | cut -b2) MM_VER="${CKV//_/-}-mm${MM_REV}" SKUNK_REV=$(echo ${PR} | cut -b3) EXTRAVERSION="${RELEASE}-skunk${MM_REV}.${SKUNK_REV}" KV_FULL=${OKV}${EXTRAVERSION} S=${WORKDIR}/linux-${KV_FULL} KV=${KV_FULL} if [[ ${RELEASETYPE} == -rc ]]; then OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))" KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" PREPATCH="patch-${CKV//_/-}" else KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${CKV//_/-}.tar.bz2" fi MM_BROKENOUT="${MM_VER}-broken-out" MM_BROKENOUT_URI="mirror://kernel/linux/kernel/people/akpm/patches/${KV_MAJOR}.${KV_MINOR}/${CKV//_/-}/${MM_VER}/${MM_BROKENOUT}.tar.bz2" SKUNK_PATCH="${CKV//_/-}-skunk${MM_REV}.${SKUNK_REV}" SKUNK_PATCH_URI="http://downloads.sourceforge.net/${PN}/${SKUNK_PATCH}.bz2" KERNEL_URI="${KERNEL_URI} ${MM_BROKENOUT_URI} ${SKUNK_PATCH_URI}" } PROVIDE="virtual/linux-sources virtual/alsa" SLOT="${PVR}" IUSE="symlink" # Unpack functions #============================================================== universal_unpack() { cd ${WORKDIR} unpack linux-${OKV}.tar.bz2 [[ -n ${PREPATCH} ]] && unpack ${PREPATCH}.bz2 unpack ${MM_BROKENOUT}.tar.bz2 unpack ${SKUNK_PATCH}.bz2 if [[ -d "linux" ]]; then mv linux linux-${KV_FULL} \ || die "Unable to move source tree to ${KV_FULL}." elif [[ "${OKV}" != "${KV_FULL}" ]]; then mv linux-${OKV} 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 sandbox sed -i \ -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \ "${S}"/arch/ppc/Makefile } unpack_set_extraversion() { cd "${S}" sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile cd "${OLDPWD}" } unpack_set_kernelname() { cd "${S}" sed -i -e "s:^\(NAME =\).*:\1 ${KERNELNAME}:" 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 } # install functions #============================================================== install_universal() { #fix silly permissions in tarball cd ${WORKDIR} chown -R root:0 * chmod -R a+r-w+X,u+w * cd ${OLDPWD} } install_sources() { local file cd "${S}" dodir /usr/src echo ">>> Copying sources ..." mv ${WORKDIR}/linux* ${D}/usr/src } # pkg_postinst functions #============================================================== postinst_sources() { local MAKELINK=0 # if we have USE=symlink, then force K_SYMLINK=1 use symlink && K_SYMLINK=1 # 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=1 fi # if the link doesnt exist, lets create it [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1 if [[ ${MAKELINK} == 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 # 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_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 } # skunkpatch #============================================================== skunkpatch() { cd ${S} if [[ -n ${PREPATCH} ]]; then echo ">>> Applying -rc prepatch ... " patch -p1 -s < ${WORKDIR}/${PREPATCH} fi MM_SERIES="$(cat ${DISTDIR}/${MM_SERIES} | sed '/#/d')" echo ">>> Applying -mm broken-out patches ... " for patch in ${MM_SERIES}; do patch -p1 -s < ${WORKDIR}/broken-out/${patch} done echo ">>> Applying -skunk patch ... " patch -p1 -s < ${WORKDIR}/${SKUNK_PATCH} } # common functions #============================================================== skunk-sources-3_src_unpack() { universal_unpack skunkpatch unpack_set_extraversion unpack_set_kernelname unpack_fix_install_path cd "${S}" } skunk-sources-3_src_compile() { cd "${S}" } skunk-sources-3_src_install() { install_universal install_sources } skunk-sources-3_pkg_postinst() { postinst_sources } skunk-sources-3_pkg_setup() { ABI="${KERNEL_ABI}" echo ">>> Preparing to unpack ..." }