Gentoo Archives: gentoo-dev

From: David Michael <fedora.dm0@×××××.com>
To: gentoo-dev@l.g.o
Cc: kernel@g.o
Subject: [gentoo-dev] [PATCH] kernel-2.eclass: EAPI 7 support
Date: Fri, 05 Feb 2021 17:58:52
Message-Id: 87wnvmqtuz.fsf@gmail.com
1 This converts installation paths prefixed with EROOT or ED to have
2 a leading slash, switches DEPEND to BDEPEND for EAPI 7 so tools are
3 installed in BROOT and natively executable, and makes eapply_user
4 the default src_prepare behavior for EAPIs since 6.
5
6 It also drops the binutils build-time dependency since it was added
7 in the original kernel.eclass implementation ~20 years ago to
8 enforce a minimum version to avoid old assembly bugs. All affected
9 versions are long gone, and it isn't required to install sources
10 anyway, so skip building the unused binutils dependency.
11
12 Signed-off-by: David Michael <fedora.dm0@×××××.com>
13 ---
14
15 Hi,
16
17 Can the kernel eclass support EAPI 7 now? It would help auditing
18 dependencies to eventually support BDEPEND properly in the ebuilds using
19 the eclass.
20
21 The patch also corrects some whitespace issues that my editor was
22 highlighting, like extra end-of-line space or random embedded tabs. I
23 could drop those changes if needed.
24
25 Thanks.
26
27 David
28
29 eclass/kernel-2.eclass | 67 +++++++++++++++++++-----------------------
30 1 file changed, 31 insertions(+), 36 deletions(-)
31
32 diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
33 index dccd39ec8f2..12ab19baee7 100644
34 --- a/eclass/kernel-2.eclass
35 +++ b/eclass/kernel-2.eclass
36 @@ -1,4 +1,4 @@
37 -# Copyright 1999-2020 Gentoo Authors
38 +# Copyright 1999-2021 Gentoo Authors
39 # Distributed under the terms of the GNU General Public License v2
40
41 # @ECLASS: kernel-2.eclass
42 @@ -8,7 +8,7 @@
43 # John Mylchreest <johnm@g.o>
44 # Mike Pagano <mpagano@g.o>
45 # <so many, many others, please add yourself>
46 -# @SUPPORTED_EAPIS: 2 3 4 5 6
47 +# @SUPPORTED_EAPIS: 2 3 4 5 6 7
48 # @BLURB: Eclass for kernel packages
49 # @DESCRIPTION:
50 # This is the kernel.eclass rewrite for a clean base regarding the 2.6
51 @@ -28,7 +28,7 @@
52 # @ECLASS-VARIABLE: K_NODRYRUN
53 # @DEFAULT_UNSET
54 # @DESCRIPTION:
55 -# if this is set then patch --dry-run will not
56 +# if this is set then patch --dry-run will not
57 # be run. Certain patches will fail with this parameter
58 # See bug #507656
59
60 @@ -198,11 +198,11 @@
61 # If you do change them, there is a chance that we will not fix resulting bugs;
62 # that of course does not mean we're not willing to help.
63
64 -inherit toolchain-funcs
65 +inherit estack toolchain-funcs
66 [[ ${EAPI:-0} == [012345] ]] && inherit epatch
67 -[[ ${EAPI:-0} == [0123456] ]] && inherit estack eapi7-ver
68 +[[ ${EAPI:-0} == [0123456] ]] && inherit eapi7-ver
69 case ${EAPI:-0} in
70 - 2|3|4|5|6)
71 + 2|3|4|5|6|7)
72 EXPORT_FUNCTIONS src_{unpack,prepare,compile,install,test} \
73 pkg_{setup,preinst,postinst,postrm} ;;
74 *) die "${ECLASS}: EAPI ${EAPI} not supported" ;;
75 @@ -314,7 +314,6 @@ handle_genpatches() {
76 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
77 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
78 detect_version() {
79 -
80 # We've already run, so nothing to do here.
81 [[ -n ${KV_FULL} ]] && return 0
82
83 @@ -540,7 +539,6 @@ detect_version() {
84 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz"
85 fi
86
87 -
88 fi
89
90 debug-print-kernel2-variables
91 @@ -600,10 +598,8 @@ kernel_is_2_6() {
92
93 # Capture the sources type and set DEPENDs
94 if [[ ${ETYPE} == sources ]]; then
95 - DEPEND="!build? (
96 - sys-apps/sed
97 - >=sys-devel/binutils-2.11.90.0.31
98 - )"
99 + [[ ${EAPI} == [0-6] ]] && DEPEND="!build? ( sys-apps/sed )" ||
100 + BDEPEND="!build? ( sys-apps/sed )"
101 RDEPEND="!build? (
102 dev-lang/perl
103 sys-devel/bc
104 @@ -638,7 +634,8 @@ if [[ ${ETYPE} == sources ]]; then
105 # tree has been dropped from the kernel.
106 kernel_is lt 4 14 && LICENSE+=" !deblob? ( linux-firmware )"
107
108 - DEPEND+=" deblob? ( ${PYTHON_DEPS} )"
109 + [[ ${EAPI} == [0-6] ]] && DEPEND+=" deblob? ( ${PYTHON_DEPS} )" ||
110 + BDEPEND+=" deblob? ( ${PYTHON_DEPS} )"
111
112 if [[ -n KV_MINOR ]]; then
113 DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
114 @@ -826,7 +823,7 @@ unpack_set_extraversion() {
115
116 unpack_fix_install_path() {
117 cd "${S}"
118 - sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
119 + sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
120 }
121
122 # Compile Functions
123 @@ -855,7 +852,7 @@ compile_headers() {
124
125 # autoconf.h isnt generated unless it already exists. plus, we have
126 # no guarantee that any headers are installed on the system...
127 - [[ -f ${EROOT}usr/include/linux/autoconf.h ]] \
128 + [[ -f ${EROOT%/}/usr/include/linux/autoconf.h ]] \
129 || touch include/linux/autoconf.h
130
131 # if K_DEFCONFIG isn't set, force to "defconfig"
132 @@ -932,10 +929,10 @@ install_headers() {
133 # of this crap anymore :D
134 if kernel_is ge 2 6 18 ; then
135 env_setup_xmakeopts
136 - emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
137 + emake headers_install INSTALL_HDR_PATH="${ED%/}"${ddir}/.. ${xmakeopts} || die
138
139 # let other packages install some of these headers
140 - rm -rf "${ED}"${ddir}/scsi || die #glibc/uclibc/etc...
141 + rm -rf "${ED%/}"${ddir}/scsi || die #glibc/uclibc/etc...
142 return 0
143 fi
144
145 @@ -943,15 +940,15 @@ install_headers() {
146 # $S values where the cmdline to cp is too long
147 pushd "${S}" >/dev/null
148 dodir ${ddir}/linux
149 - cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
150 - rm -rf "${ED}"${ddir}/linux/modules || die
151 + cp -pPR "${S}"/include/linux "${ED%/}"${ddir}/ || die
152 + rm -rf "${ED%/}"${ddir}/linux/modules || die
153
154 dodir ${ddir}/asm
155 - cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm || die
156 + cp -pPR "${S}"/include/asm/* "${ED%/}"${ddir}/asm || die
157
158 if kernel_is 2 6 ; then
159 dodir ${ddir}/asm-generic
160 - cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic || die
161 + cp -pPR "${S}"/include/asm-generic/* "${ED%/}"${ddir}/asm-generic || die
162 fi
163
164 # clean up
165 @@ -983,7 +980,7 @@ install_sources() {
166 done
167 fi
168
169 - mv "${WORKDIR}"/linux* "${ED}"usr/src || die
170 + mv "${WORKDIR}"/linux* "${ED%/}"/usr/src || die
171
172 if [[ -n "${UNIPATCH_DOCS}" ]] ; then
173 for i in ${UNIPATCH_DOCS}; do
174 @@ -1025,19 +1022,19 @@ postinst_sources() {
175
176 # if we are to forcably symlink, delete it if it already exists first.
177 if [[ ${K_SYMLINK} -gt 0 ]]; then
178 - [[ -h ${EROOT}usr/src/linux ]] && { rm "${EROOT}"usr/src/linux || die; }
179 + [[ -h ${EROOT%/}/usr/src/linux ]] && { rm "${EROOT%/}"/usr/src/linux || die; }
180 MAKELINK=1
181 fi
182
183 # if the link doesnt exist, lets create it
184 - [[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
185 + [[ ! -h ${EROOT%/}/usr/src/linux ]] && MAKELINK=1
186
187 if [[ ${MAKELINK} == 1 ]]; then
188 - ln -sf linux-${KV_FULL} "${EROOT}"usr/src/linux || die
189 + ln -sf linux-${KV_FULL} "${EROOT%/}"/usr/src/linux || die
190 fi
191
192 # Don't forget to make directory for sysfs
193 - [[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && { mkdir "${EROOT}"sys || die ; }
194 + [[ ! -d ${EROOT%/}/sys ]] && kernel_is 2 6 && { mkdir "${EROOT%/}"/sys || die ; }
195
196 echo
197 elog "If you are upgrading from a previous kernel, you may be interested"
198 @@ -1048,13 +1045,13 @@ postinst_sources() {
199 # if K_EXTRAEINFO is set then lets display it now
200 if [[ -n ${K_EXTRAEINFO} ]]; then
201 echo ${K_EXTRAEINFO} | fmt |
202 - while read -s ELINE; do einfo "${ELINE}"; done
203 + while read -s ELINE; do einfo "${ELINE}"; done
204 fi
205
206 # if K_EXTRAELOG is set then lets display it now
207 if [[ -n ${K_EXTRAELOG} ]]; then
208 echo ${K_EXTRAELOG} | fmt |
209 - while read -s ELINE; do elog "${ELINE}"; done
210 + while read -s ELINE; do elog "${ELINE}"; done
211 fi
212
213 # if K_EXTRAEWARN is set then lets display it now
214 @@ -1242,7 +1239,7 @@ unipatch() {
215 local GCC_MINOR_VER=$(gcc-minor-version)
216
217 # optimization patch for gcc < 8.X and kernel > 4.13
218 - if kernel_is ge 4 13 ; then
219 + if kernel_is ge 4 13 ; then
220 if [[ ${GCC_MAJOR_VER} -lt 8 ]] && [[ ${GCC_MAJOR_VER} -gt 4 ]]; then
221 UNIPATCH_DROP+=" 5011_enable-cpu-optimizations-for-gcc8.patch"
222 UNIPATCH_DROP+=" 5012_enable-cpu-optimizations-for-gcc91.patch"
223 @@ -1323,8 +1320,8 @@ unipatch() {
224 if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
225
226 ####################################################################
227 - # IMPORTANT: This code is to support kernels which cannot be #
228 - # tested with the --dry-run parameter #
229 + # IMPORTANT: This code is to support kernels which cannot be #
230 + # tested with the --dry-run parameter #
231 # #
232 # These patches contain a removal of a symlink, followed by #
233 # addition of a file with the same name as the symlink in the #
234 @@ -1443,7 +1440,6 @@ getfilevar() {
235 # patchsets.
236
237 detect_arch() {
238 -
239 local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
240
241 # COMPAT_URI is the contents of ${ARCH}_URI
242 @@ -1554,13 +1550,12 @@ kernel-2_src_unpack() {
243 # Apply any user patches
244
245 kernel-2_src_prepare() {
246 -
247 debug-print "Applying any user patches"
248
249 # apply any user patches
250 case ${EAPI:-0} in
251 0|1|2|3|4|5) epatch_user ;;
252 - 6) eapply_user ;;
253 + *) eapply_user ;;
254 esac
255 }
256
257 @@ -1660,11 +1655,11 @@ kernel-2_pkg_postrm() {
258 [[ ${ETYPE} == headers ]] && return 0
259
260 # If there isn't anything left behind, then don't complain.
261 - [[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
262 + [[ -e ${EROOT%/}/usr/src/linux-${KV_FULL} ]] || return 0
263 echo
264 ewarn "Note: Even though you have successfully unmerged "
265 ewarn "your kernel package, directories in kernel source location: "
266 - ewarn "${EROOT}usr/src/linux-${KV_FULL}"
267 + ewarn "${EROOT%/}/usr/src/linux-${KV_FULL}"
268 ewarn "with modified files will remain behind. By design, package managers"
269 ewarn "will not remove these modified files and the directories they reside in."
270 echo
271 --
272 2.26.2

Replies

Subject Author
[gentoo-dev] Re: [PATCH] kernel-2.eclass: EAPI 7 support David Michael <fedora.dm0@×××××.com>