Skip to contentSkip to conversation

devtool: extract: remove patches when S=WORKDIR

PATCH Superseded Markus Lehtonen 2 participants 3 messages Apr 21, 2015 – Apr 22, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtool: extract: remove patches when S=WORKDIR

All local files from the layer, including patches, are added to to srctree repository when S==WORKDIR. The patch files are useless as they are automatically applied on top of the srctree by devtool.

This change causes devtool extract to remove these unnecessary (and possibly confusing) patch file(s). The patches will be removed in one single commit.

[YOCTO #7602]

---
 scripts/lib/devtool/standard.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
scripts/lib/devtool/standard.py +20 -0
index a50a771..41bcf86 100644
@@ -248,6 +248,26 @@ def _extract_source(srctree, keep_temp, devbranch, d):
             else:
                 os.rmdir(patchdir)
 
+        # Find local patches that were "unpacked" to srctree directory
+        patches = []
+        for uri in (crd.getVar('SRC_URI', True) or "").split():
+            if uri.startswith('file://'):
+                fname = os.path.basename(uri).split(';')[0]
+                # Take patch "basename" without the possible compression
+                # extension (.gz etc)
+                match = re.match(r'^(.+\.patch)(\..+)?$', fname)
+                if match:
+                    patches.append(match.group(1))
+        patches = [fname for fname in os.listdir(workdir) if fname in patches]
+
+        # Remove patches if S=WORKDIR so that the unneeded patch files are
+        # not committed into srctree (as they're applied later on)
+        if patches and srcsubdir == workdir:
+            logger.info('Removing patch files...')
+            for patch in patches:
+                os.unlink(os.path.join(workdir, patch))
+
+        # Set-up srctree repo
         if bb.data.inherits_class('kernel-yocto', d):
             (stdout, _) = bb.process.run('git --git-dir="%s" rev-parse HEAD' % crd.expand('${WORKDIR}/git'), cwd=srcsubdir)
             initial_rev = stdout.rstrip()
Signature · 1 line
2.1.4
#1 lore raw

Hi Markus,

Quoted 23 lines · On Tuesday 21 April 2015 17:49:54 Markus Lehtonen wrote:

All local files from the layer, including patches, are added to to srctree repository when S==WORKDIR. The patch files are useless as they are automatically applied on top of the srctree by devtool.

This change causes devtool extract to remove these unnecessary (and possibly confusing) patch file(s). The patches will be removed in one single commit.

[YOCTO #7602]

---
 scripts/lib/devtool/standard.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
(quoted diff) +0 -0

b/scripts/lib/devtool/standard.py index a50a771..41bcf86 100644

scripts/lib/devtool/standard.py +0 -0
@@ -248,6 +248,26 @@ def _extract_source(srctree, keep_temp, devbranch, d):
             else:
                 os.rmdir(patchdir)
 

scripts/lib/devtool/standard.py def _extract_source(srctree, keep_temp, devbranch, d): · line 260

Quoted 10 lines
scripts/lib/devtool/standard.py +10 -0
+        # Find local patches that were "unpacked" to srctree directory
+        patches = []
+        for uri in (crd.getVar('SRC_URI', True) or "").split():
+            if uri.startswith('file://'):
+                fname = os.path.basename(uri).split(';')[0]
+                # Take patch "basename" without the possible compression
+                # extension (.gz etc)
+                match = re.match(r'^(.+\.patch)(\..+)?$', fname)
+                if match:
+                    patches.append(match.group(1))

Could you please use get_recipe_patches() from recipeutils.py for this? There's some logic in there that I'd rather we didn't re-implement.

Thanks,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#2 lore raw

Hi Paul,

Quoted 26 lines · Paul Eggleton

Hi Markus,

Quoted 23 lines · On Tuesday 21 April 2015 17:49:54 Markus Lehtonen wrote:

All local files from the layer, including patches, are added to to srctree repository when S==WORKDIR. The patch files are useless as they are automatically applied on top of the srctree by devtool.

This change causes devtool extract to remove these unnecessary (and possibly confusing) patch file(s). The patches will be removed in one single commit.

[YOCTO #7602]

---
 scripts/lib/devtool/standard.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
(quoted diff) +0 -0

b/scripts/lib/devtool/standard.py index a50a771..41bcf86 100644

scripts/lib/devtool/standard.py +0 -0
@@ -248,6 +248,26 @@ def _extract_source(srctree, keep_temp, devbranch, d):
             else:
                 os.rmdir(patchdir)
 
Quoted 13 lines

scripts/lib/devtool/standard.py def _extract_source(srctree, keep_temp, devbranch, d): · line 260

Quoted 10 lines
scripts/lib/devtool/standard.py +10 -0
+        # Find local patches that were "unpacked" to srctree directory
+        patches = []
+        for uri in (crd.getVar('SRC_URI', True) or "").split():
+            if uri.startswith('file://'):
+                fname = os.path.basename(uri).split(';')[0]
+                # Take patch "basename" without the possible compression
+                # extension (.gz etc)
+                match = re.match(r'^(.+\.patch)(\..+)?$', fname)
+                if match:
+                    patches.append(match.group(1))

Could you please use get_recipe_patches() from recipeutils.py for this? There's some logic in there that I'd rather we didn't re-implement.

OK. Fixed in v2 of the patch.

Thanks,
Markus