public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] kernel-2.eclass: EAPI 7 support
@ 2021-02-05 17:58 David Michael
  2021-02-05 18:13 ` [gentoo-dev] " David Michael
  0 siblings, 1 reply; 2+ messages in thread
From: David Michael @ 2021-02-05 17:58 UTC (permalink / raw
  To: gentoo-dev; +Cc: kernel

This converts installation paths prefixed with EROOT or ED to have
a leading slash, switches DEPEND to BDEPEND for EAPI 7 so tools are
installed in BROOT and natively executable, and makes eapply_user
the default src_prepare behavior for EAPIs since 6.

It also drops the binutils build-time dependency since it was added
in the original kernel.eclass implementation ~20 years ago to
enforce a minimum version to avoid old assembly bugs.  All affected
versions are long gone, and it isn't required to install sources
anyway, so skip building the unused binutils dependency.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
---

Hi,

Can the kernel eclass support EAPI 7 now?  It would help auditing
dependencies to eventually support BDEPEND properly in the ebuilds using
the eclass.

The patch also corrects some whitespace issues that my editor was
highlighting, like extra end-of-line space or random embedded tabs.  I
could drop those changes if needed.

Thanks.

David

 eclass/kernel-2.eclass | 67 +++++++++++++++++++-----------------------
 1 file changed, 31 insertions(+), 36 deletions(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index dccd39ec8f2..12ab19baee7 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: kernel-2.eclass
@@ -8,7 +8,7 @@
 # John Mylchreest <johnm@gentoo.org>
 # Mike Pagano <mpagano@gentoo.org>
 # <so many, many others, please add yourself>
-# @SUPPORTED_EAPIS: 2 3 4 5 6
+# @SUPPORTED_EAPIS: 2 3 4 5 6 7
 # @BLURB: Eclass for kernel packages
 # @DESCRIPTION:
 # This is the kernel.eclass rewrite for a clean base regarding the 2.6
@@ -28,7 +28,7 @@
 # @ECLASS-VARIABLE:  K_NODRYRUN
 # @DEFAULT_UNSET
 # @DESCRIPTION:
-# if this is set then patch --dry-run will not 
+# if this is set then patch --dry-run will not
 # be run. Certain patches will fail with this parameter
 # See bug #507656
 
@@ -198,11 +198,11 @@
 # If you do change them, there is a chance that we will not fix resulting bugs;
 # that of course does not mean we're not willing to help.
 
-inherit toolchain-funcs
+inherit estack toolchain-funcs
 [[ ${EAPI:-0} == [012345] ]] && inherit epatch
-[[ ${EAPI:-0} == [0123456] ]] && inherit estack eapi7-ver
+[[ ${EAPI:-0} == [0123456] ]] && inherit eapi7-ver
 case ${EAPI:-0} in
-	2|3|4|5|6)
+	2|3|4|5|6|7)
 		EXPORT_FUNCTIONS src_{unpack,prepare,compile,install,test} \
 			pkg_{setup,preinst,postinst,postrm} ;;
 	*) die "${ECLASS}: EAPI ${EAPI} not supported" ;;
@@ -314,7 +314,6 @@ handle_genpatches() {
 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
 detect_version() {
-
 	# We've already run, so nothing to do here.
 	[[ -n ${KV_FULL} ]] && return 0
 
@@ -540,7 +539,6 @@ detect_version() {
 			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz"
 		fi
 
-
 	fi
 
 	debug-print-kernel2-variables
@@ -600,10 +598,8 @@ kernel_is_2_6() {
 
 # Capture the sources type and set DEPENDs
 if [[ ${ETYPE} == sources ]]; then
-	DEPEND="!build? (
-		sys-apps/sed
-		>=sys-devel/binutils-2.11.90.0.31
-	)"
+	[[ ${EAPI} == [0-6] ]] && DEPEND="!build? ( sys-apps/sed )" ||
+	BDEPEND="!build? ( sys-apps/sed )"
 	RDEPEND="!build? (
 		dev-lang/perl
 		sys-devel/bc
@@ -638,7 +634,8 @@ if [[ ${ETYPE} == sources ]]; then
 			# tree has been dropped from the kernel.
 			kernel_is lt 4 14 && LICENSE+=" !deblob? ( linux-firmware )"
 
-			DEPEND+=" deblob? ( ${PYTHON_DEPS} )"
+			[[ ${EAPI} == [0-6] ]] && DEPEND+=" deblob? ( ${PYTHON_DEPS} )" ||
+			BDEPEND+=" deblob? ( ${PYTHON_DEPS} )"
 
 			if [[ -n KV_MINOR ]]; then
 				DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
@@ -826,7 +823,7 @@ unpack_set_extraversion() {
 
 unpack_fix_install_path() {
 	cd "${S}"
-	sed	-i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
+	sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
 }
 
 # Compile Functions
@@ -855,7 +852,7 @@ compile_headers() {
 
 		# autoconf.h isnt generated unless it already exists. plus, we have
 		# no guarantee that any headers are installed on the system...
-		[[ -f ${EROOT}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"
@@ -932,10 +929,10 @@ install_headers() {
 	# of this crap anymore :D
 	if kernel_is ge 2 6 18 ; then
 		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
+		emake headers_install INSTALL_HDR_PATH="${ED%/}"${ddir}/.. ${xmakeopts} || die
 
 		# let other packages install some of these headers
-		rm -rf "${ED}"${ddir}/scsi || die #glibc/uclibc/etc...
+		rm -rf "${ED%/}"${ddir}/scsi || die #glibc/uclibc/etc...
 		return 0
 	fi
 
@@ -943,15 +940,15 @@ install_headers() {
 	# $S values where the cmdline to cp is too long
 	pushd "${S}" >/dev/null
 	dodir ${ddir}/linux
-	cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
-	rm -rf "${ED}"${ddir}/linux/modules || die
+	cp -pPR "${S}"/include/linux "${ED%/}"${ddir}/ || die
+	rm -rf "${ED%/}"${ddir}/linux/modules || die
 
 	dodir ${ddir}/asm
-	cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm || die
+	cp -pPR "${S}"/include/asm/* "${ED%/}"${ddir}/asm || die
 
 	if kernel_is 2 6 ; then
 		dodir ${ddir}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic || die
+		cp -pPR "${S}"/include/asm-generic/* "${ED%/}"${ddir}/asm-generic || die
 	fi
 
 	# clean up
@@ -983,7 +980,7 @@ install_sources() {
 		done
 	fi
 
-	mv "${WORKDIR}"/linux* "${ED}"usr/src || die
+	mv "${WORKDIR}"/linux* "${ED%/}"/usr/src || die
 
 	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
 		for i in ${UNIPATCH_DOCS}; do
@@ -1025,19 +1022,19 @@ postinst_sources() {
 
 	# if we are to forcably symlink, delete it if it already exists first.
 	if [[ ${K_SYMLINK} -gt 0 ]]; then
-		[[ -h ${EROOT}usr/src/linux ]] && { rm "${EROOT}"usr/src/linux || die; }
+		[[ -h ${EROOT%/}/usr/src/linux ]] && { rm "${EROOT%/}"/usr/src/linux || die; }
 		MAKELINK=1
 	fi
 
 	# if the link doesnt exist, lets create it
-	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
+	[[ ! -h ${EROOT%/}/usr/src/linux ]] && MAKELINK=1
 
 	if [[ ${MAKELINK} == 1 ]]; then
-		ln -sf linux-${KV_FULL} "${EROOT}"usr/src/linux || die
+		ln -sf linux-${KV_FULL} "${EROOT%/}"/usr/src/linux || die
 	fi
 
 	# Don't forget to make directory for sysfs
-	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && { mkdir "${EROOT}"sys || die ; }
+	[[ ! -d ${EROOT%/}/sys ]] && kernel_is 2 6 && { mkdir "${EROOT%/}"/sys || die ; }
 
 	echo
 	elog "If you are upgrading from a previous kernel, you may be interested"
@@ -1048,13 +1045,13 @@ postinst_sources() {
 	# 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
+		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
+		while read -s ELINE; do elog "${ELINE}"; done
 	fi
 
 	# if K_EXTRAEWARN is set then lets display it now
@@ -1242,7 +1239,7 @@ unipatch() {
 			local GCC_MINOR_VER=$(gcc-minor-version)
 
 			# optimization patch for gcc < 8.X and kernel > 4.13
-			if kernel_is ge 4 13 ; then 
+			if kernel_is ge 4 13 ; then
 				if [[ ${GCC_MAJOR_VER} -lt 8 ]] && [[ ${GCC_MAJOR_VER} -gt 4 ]]; then
 					UNIPATCH_DROP+=" 5011_enable-cpu-optimizations-for-gcc8.patch"
 					UNIPATCH_DROP+=" 5012_enable-cpu-optimizations-for-gcc91.patch"
@@ -1323,8 +1320,8 @@ unipatch() {
 			if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
 
 			####################################################################
-			# IMPORTANT: This code is to support kernels which cannot be	   #
-			# tested with the --dry-run parameter									   #	
+			# IMPORTANT: This code is to support kernels which cannot be       #
+			# tested with the --dry-run parameter                              #
 			#                                                                  #
 			# These patches contain a removal of a symlink, followed by        #
 			# addition of a file with the same name as the symlink in the      #
@@ -1443,7 +1440,6 @@ getfilevar() {
 # patchsets.
 
 detect_arch() {
-
 	local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
 
 	# COMPAT_URI is the contents of ${ARCH}_URI
@@ -1554,13 +1550,12 @@ kernel-2_src_unpack() {
 # Apply any user patches
 
 kernel-2_src_prepare() {
-
 	debug-print "Applying any user patches"
 
 	# apply any user patches
 	case ${EAPI:-0} in
 		0|1|2|3|4|5) epatch_user ;;
-		6) eapply_user ;;
+		*) eapply_user ;;
 	esac
 }
 
@@ -1660,11 +1655,11 @@ kernel-2_pkg_postrm() {
 	[[ ${ETYPE} == headers ]] && return 0
 
 	# If there isn't anything left behind, then don't complain.
-	[[ -e ${EROOT}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 "${EROOT}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
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-dev] Re: [PATCH] kernel-2.eclass: EAPI 7 support
  2021-02-05 17:58 [gentoo-dev] [PATCH] kernel-2.eclass: EAPI 7 support David Michael
@ 2021-02-05 18:13 ` David Michael
  0 siblings, 0 replies; 2+ messages in thread
From: David Michael @ 2021-02-05 18:13 UTC (permalink / raw
  To: gentoo-dev; +Cc: kernel

On Fri, Feb 5, 2021 at 12:58 PM David Michael <fedora.dm0@gmail.com> wrote:
> This converts installation paths prefixed with EROOT or ED to have
> a leading slash, switches DEPEND to BDEPEND for EAPI 7 so tools are
> installed in BROOT and natively executable, and makes eapply_user
> the default src_prepare behavior for EAPIs since 6.
>
> It also drops the binutils build-time dependency since it was added
> in the original kernel.eclass implementation ~20 years ago to
> enforce a minimum version to avoid old assembly bugs.  All affected
> versions are long gone, and it isn't required to install sources
> anyway, so skip building the unused binutils dependency.

Oops, I forgot about the bug.  If someone applies this, you can add
the following line here:

Closes: https://bugs.gentoo.org/702280


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-05 18:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-05 17:58 [gentoo-dev] [PATCH] kernel-2.eclass: EAPI 7 support David Michael
2021-02-05 18:13 ` [gentoo-dev] " David Michael

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox