Thanks Zac, Göktürk, I have added EPREFIX logics for EAPI<3 and improved the trailing slashes and quotes.
Benda --- kernel-2.eclass 2016-02-17 22:46:25.235543840 +0900 +++ kernel-2.eclass 2016-06-12 11:48:19.843801138 +0900 @@ -105,6 +105,8 @@ HOMEPAGE="https://www.kernel.org/ https://www.gentoo.org/ ${HOMEPAGE}" : ${LICENSE:="GPL-2"} +has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT} + # This is the latest KV_PATCH of the deblob tool available from the # libre-sources upstream. If you bump this, you MUST regenerate the Manifests # for ALL kernel-2 consumer packages where deblob is available. @@ -667,7 +669,7 @@ # 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 ]] \ + [[ -f "${EROOT}"usr/include/linux/autoconf.h ]] \ || touch include/linux/autoconf.h # if K_DEFCONFIG isn't set, force to "defconfig" @@ -731,10 +733,10 @@ # of this crap anymore :D if kernel_is ge 2 6 18 ; then env_setup_xmakeopts - emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die + emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die # let other packages install some of these headers - rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc... + rm -rf "${ED}"${ddir}/scsi #glibc/uclibc/etc... return 0 fi @@ -742,15 +744,15 @@ # $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 + cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die + rm -rf "${ED}"${ddir}/linux/modules dodir ${ddir}/asm - cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm + cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm if kernel_is 2 6 ; then dodir ${ddir}/asm-generic - cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic + cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic fi # clean up @@ -784,7 +786,7 @@ > "${S}"/patches.txt fi - mv ${WORKDIR}/linux* "${D}"/usr/src + mv ${WORKDIR}/linux* "${ED}"usr/src if [[ -n "${UNIPATCH_DOCS}" ]] ; then for i in ${UNIPATCH_DOCS}; do @@ -797,8 +799,8 @@ #============================================================== preinst_headers() { local ddir=$(kernel_header_destdir) - [[ -L ${ddir}/linux ]] && rm ${ddir}/linux - [[ -L ${ddir}/asm ]] && rm ${ddir}/asm + [[ -L "${EPREFIX}"${ddir}/linux ]] && rm "${EPREFIX}"${ddir}/linux + [[ -L "${EPREFIX}"${ddir}/asm ]] && rm "${EPREFIX}"${ddir}/asm } # pkg_postinst functions @@ -819,21 +821,21 @@ # 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 + [[ -h "${EROOT}"usr/src/linux ]] && rm "${EROOT}"usr/src/linux MAKELINK=1 fi # if the link doesnt exist, lets create it - [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1 + [[ ! -h "${EROOT}"usr/src/linux ]] && MAKELINK=1 if [[ ${MAKELINK} == 1 ]]; then - cd "${ROOT}"usr/src + cd "${EROOT}"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 + [[ ! -d "${EROOT}"sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys echo elog "If you are upgrading from a previous kernel, you may be interested" @@ -1353,11 +1355,11 @@ [[ ${ETYPE} == headers ]] && return 0 # If there isn't anything left behind, then don't complain. - [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0 + [[ -e "${EROOT}"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 "${EROOT}usr/src/linux-${KV_FULL}" ewarn "with modified files will remain behind. By design, package managers" ewarn "will not remove these modified files and the directories they reside in." echo