diff mbox series

[v3] dos2unix.bbclass: Fix patch error for recipes that inherit dos2unix.

Message ID 20250123091223.1535398-1-hongxu.jia@windriver.com
State New
Headers show
Series [v3] dos2unix.bbclass: Fix patch error for recipes that inherit dos2unix. | expand

Commit Message

Hongxu Jia Jan. 23, 2025, 9:12 a.m. UTC
While SPDX_INCLUDE_SOURCES = "1", call do_patch in do_create_spdx failed
for these recipes inherit dos2unix

Prepend function convert_crlf_to_lf to task do_patch to assure always
run before do_patch

Add dos2unix-native to PATCHDEPENDENCY to assure the existence of
command dos2unix before convert_crlf_to_lf is executed in do_patch
- The do_creat_spdx task has added PATCHDEPENDENCY to depends
- The do_unpack_and_patch task has added task after do_patch
  (addtask do_unpack_and_patch after do_patch do_preconfigure)

Also remove extra do_convert_crlf_to_lf in archiver.bbclass which
is not necessary any more

Suggested-by Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
Changed in v2: 

Do not call bb.build.exec_func to run do_convert_crlf_to_lf in classes/spdx-common,
preprend it to task do_patch to assure always run before do_patch

Changed in v3:
Add dos2unix-native to PATCHDEPENDENCY other than to DEPENDS
which is too late for do_patch

 meta/classes-recipe/dos2unix.bbclass | 8 +++++---
 meta/classes/archiver.bbclass        | 3 ---
 2 files changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/dos2unix.bbclass b/meta/classes-recipe/dos2unix.bbclass
index 18e89b1cf2..3a094197a2 100644
--- a/meta/classes-recipe/dos2unix.bbclass
+++ b/meta/classes-recipe/dos2unix.bbclass
@@ -10,11 +10,13 @@ 
 # on Linux(LF), which can cause annoying patching errors during
 # git push/checkout processes.
 
-do_convert_crlf_to_lf[depends] += "dos2unix-native:do_populate_sysroot"
+PATCHDEPENDENCY += "dos2unix-native:do_populate_sysroot"
 
 # Convert CRLF line terminators to LF
-do_convert_crlf_to_lf () {
+convert_crlf_to_lf () {
 	find ${S} -type f -exec dos2unix {} \;
 }
 
-addtask convert_crlf_to_lf after do_unpack before do_patch
+python do_patch:prepend() {
+    bb.build.exec_func('convert_crlf_to_lf', d)
+}
diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index df271feddd..4404f0c032 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -507,9 +507,6 @@  python do_unpack_and_patch() {
         src_orig = '%s.orig' % src
         oe.path.copytree(src, src_orig)
 
-    if bb.data.inherits_class('dos2unix', d):
-        bb.build.exec_func('do_convert_crlf_to_lf', d)
-
     # Make sure gcc and kernel sources are patched only once
     if not (d.getVar('SRC_URI') == "" or is_work_shared(d)):
         bb.build.exec_func('do_patch', d)