[PATCH] patch.py: make sure that patches/series file exists before quilt pop


Martin Jansa
 

* Since quilt upgrade to 0.67 some recipes sometimes fail in do_patch with
errors like:

ERROR: Applying patch 'GPLv2.patch' on target directory '/OE/build/oe-core/tmp-glibc/work/qemux86_64-oe-linux/keymaps/1.0-r31'
CmdError('quilt --quiltrc /OE/build/oe-core/tmp-glibc/work/qemux86_64-oe-linux/keymaps/1.0-r31/recipe-sysroot-native/etc/quiltrc push', 0, 'stdout:
stderr: File series fully applied, ends at patch GPLv2.patch
')

* It affects only recipes with S = "${WORKDIR}", which wipe only
${S}/patches, because in other cases whole ${S} is wiped when
do_unpack is re-executed.

* It was originally added in:
https://git.openembedded.org/openembedded-core/commit/?id=5fe5e6a15f26f23f0c5b863fafad7a0d382a55e2

since then it was extended to wipe whole ${S} when ${S} != ${WORKDIR} in:
https://git.openembedded.org/openembedded-core/commit/?id=5fe5e6a15f26f23f0c5b863fafad7a0d382a55e2
https://git.openembedded.org/openembedded-core/commit/?id=eccae514b71394ffaed8fc45dea7942152a334a1

this is now causing issues to quilt-0.67 because it checks that
${S}/patches/series exists during 'quilt pop -a -f' which we call
from QuiltTree.Clean to undo patches possibly already applied
in ${S} in previous do_patch execution.

* There are couple recipes affected by this e.g. keymaps (.patch already
removed in oe-core), makedevs (.patch removal sent to ML yesterday
https://lists.openembedded.org/g/openembedded-core/message/166172),
devmem2
(https://lists.openembedded.org/g/openembedded-devel/message/97270), but
there are other recipes with S = "${WORKDIR}" where you can trigger this
e.g. by having a .patch file in DISTRO layer .bbappend (e.g. tzdata with
webOS
https://github.com/webosose/meta-webosose/blob/06e5298d9f5c47679b679081d9930f8d1c776142/meta-webos/recipes-extended/tzdata/tzdata.bbappend#L10)

This do_patch issue is caused by:
https://git.savannah.nongnu.org/cgit/quilt.git/commit/?id=8b39a960afcf45cd4f5804ae62b6b0656bdb191d
introduced in kirkstone with:
https://git.openembedded.org/openembedded-core/commit/?h=kirkstone&id=fa71afcee9ab42198c619333b77a15bd2ae02b20

The shortest sequence to reproduce this is just
bitbake keymaps -c patch
bitbake keymaps -c unpack -f
bitbake keymaps -c patch
with
https://git.openembedded.org/openembedded-core/commit/?id=17d981005a0c0c97702ad88602b7181b69bcc9eb
reverted.

And the change in quilt behavior is causing QuiltTree.Clean (quilt pop -a -f) in:
https://git.openembedded.org/openembedded-core/tree/meta/lib/oe/patch.py?id=17d981005a0c0c97702ad88602b7181b69bcc9eb#n601

to silently fail with "No series file found" before undoing the
patches in ${S} and then quilt push failing, because all the
patches are _still_ applied in ${S}.

Removing ".pc" doesn't help, because we really
need quilt's help to undo the patches (in this case to delete COPYING
file from WORKDIR before applying the .patch which tries to add it
again), because do_unpack cannot just wipe S and start over (because S
== WORKDIR) - nor selectively removing the files listed in SRC_URI,
because COPYING file isn't listed there.

Using skip_series_check in 'quilt pop' (partially reverting the change
from upstream) does fix this as well and it's simple one line patch
(just adding skip_series_check=1 in pop.in), but might be difficult
to upstream, because it's this strange OE specific behavior that we
remove 'patches' directory and then still need quilt pop to work.

Signed-off-by: Martin Jansa <Martin.Jansa@...>
---
meta/lib/oe/patch.py | 2 ++
1 file changed, 2 insertions(+)

diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 9034fcae03..95b915a6ab 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -598,6 +598,8 @@ class QuiltTree(PatchSet):

def Clean(self):
try:
+ # make sure that patches/series file exists before quilt pop to keep quilt-0.67 happy
+ open(os.path.join(self.dir, "patches","series"), 'a').close()
self._runcmd(["pop", "-a", "-f"])
oe.path.remove(os.path.join(self.dir, "patches","series"))
except Exception:
--
2.35.1