diff options
author | Jose Quaresma <quaresma.jose@gmail.com> | 2021-10-03 22:31:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-23 23:14:16 +0100 |
commit | 6f9508c2743d2924da79f33fc6618401af15bd07 (patch) | |
tree | 268f6ea51e0593f9f72957c71ec68d2df4aabdc8 /meta/classes/patch.bbclass | |
parent | 0352c571019a8d31c15fba75fc5c8cd4c4442908 (diff) | |
download | poky-6f9508c2743d2924da79f33fc6618401af15bd07.tar.gz |
patch.bbclass: when the patch fails show more info on the fatal error
There are situations when the user have the 'patchdir' defined
as a parameter on SRC_URI. However he doesn't know that with this
the patch is applied relatively to the receipe source dir 'S'.
- When user have 'patchdir' defined check if this directory exist.
- If the patch fails show addition info to the user:
- Import: show the striplevel
- Resolver: show the expanded 'patchdir' to the user.
The next example is from opencv in meta-oe layer, here the
patch is applied on the target directory ${WORKDIR}/git/contrib.
S = "${WORKDIR}/git"
SRCREV_FORMAT = "opencv_contrib"
SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \
file://0001-sfm-link-with-Glog_LIBS.patch;patchdir=../contrib \
"
* When the patch fail there are no message that indicates the real reason.
patchdir=../no-found-on-file-system
ERROR: opencv-4.5.2-r0 do_patch: Command Error: 'quilt --quiltrc /build/tmp/work/core2-64-poky-linux/opencv/4.5.2-r0/recipe-sysroot-native/etc/quiltrc push' exited with 0 Output:
stdout: Applying patch 0001-sfm-link-with-Glog_LIBS.patch
can't find file to patch at input line 37
Perhaps you used the wrong -p or --strip option?
* The check of the patchdir will add a new fatal error
when the user specifies a wrong path than don't exist.
patchdir=../no-found-on-file-system
ERROR: opencv-4.5.2-r0 do_patch: Target directory '/build/tmp/work/core2-64-poky-linux/opencv/4.5.2-r0/git/../no-found-on-file-system' not found, patchdir '../no-found-on-file-system' is incorrect in patch file '0001-sfm-link-with-Glog_LIBS.patch'
* When we can't aplly the patch but the patchdir exist,
show the expanded patchdir on fatal error.
patchdir=../git
ERROR: opencv-4.5.2-r0 do_patch: Applying patch '0001-sfm-link-with-Glog_LIBS.patch' on target directory '/build/tmp/work/core2-64-poky-linux/opencv/4.5.2-r0/git/../git'
Command Error: 'quilt --quiltrc /build/tmp/work/core2-64-poky-linux/opencv/4.5.2-r0/recipe-sysroot-native/etc/quiltrc push' exited with 0 Output:
stdout: Applying patch 0001-sfm-link-with-Glog_LIBS.patch
can't find file to patch at input line 37
Perhaps you used the wrong -p or --strip option?
(From OE-Core rev: af46b360b364f6b50cd389d838dc5dd3099ecc41)
Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit c44bc7c0fb8b7c2e44dd93607a3bfd9733e1df80)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/patch.bbclass')
-rw-r--r-- | meta/classes/patch.bbclass | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass index 25ec089ae1..484d27ac76 100644 --- a/meta/classes/patch.bbclass +++ b/meta/classes/patch.bbclass | |||
@@ -131,6 +131,9 @@ python patch_do_patch() { | |||
131 | patchdir = parm["patchdir"] | 131 | patchdir = parm["patchdir"] |
132 | if not os.path.isabs(patchdir): | 132 | if not os.path.isabs(patchdir): |
133 | patchdir = os.path.join(s, patchdir) | 133 | patchdir = os.path.join(s, patchdir) |
134 | if not os.path.isdir(patchdir): | ||
135 | bb.fatal("Target directory '%s' not found, patchdir '%s' is incorrect in patch file '%s'" % | ||
136 | (patchdir, parm["patchdir"], parm['patchname'])) | ||
134 | else: | 137 | else: |
135 | patchdir = s | 138 | patchdir = s |
136 | 139 | ||
@@ -147,12 +150,12 @@ python patch_do_patch() { | |||
147 | patchset.Import({"file":local, "strippath": parm['striplevel']}, True) | 150 | patchset.Import({"file":local, "strippath": parm['striplevel']}, True) |
148 | except Exception as exc: | 151 | except Exception as exc: |
149 | bb.utils.remove(process_tmpdir, True) | 152 | bb.utils.remove(process_tmpdir, True) |
150 | bb.fatal(str(exc)) | 153 | bb.fatal("Importing patch '%s' with striplevel '%s'\n%s" % (parm['patchname'], parm['striplevel'], str(exc))) |
151 | try: | 154 | try: |
152 | resolver.Resolve() | 155 | resolver.Resolve() |
153 | except bb.BBHandledException as e: | 156 | except bb.BBHandledException as e: |
154 | bb.utils.remove(process_tmpdir, True) | 157 | bb.utils.remove(process_tmpdir, True) |
155 | bb.fatal(str(e)) | 158 | bb.fatal("Applying patch '%s' on target directory '%s'\n%s" % (parm['patchname'], patchdir, str(e))) |
156 | 159 | ||
157 | bb.utils.remove(process_tmpdir, True) | 160 | bb.utils.remove(process_tmpdir, True) |
158 | del os.environ['TMPDIR'] | 161 | del os.environ['TMPDIR'] |