summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-selftest/recipes-test/devtool/devtool-test-patch-gz.bb16
-rw-r--r--meta-selftest/recipes-test/devtool/devtool-test-patch-gz/readme.patch.gzbin0 -> 449 bytes
-rw-r--r--meta/classes/patch.bbclass9
-rw-r--r--meta/lib/oe/recipeutils.py6
-rw-r--r--meta/lib/oeqa/selftest/devtool.py24
-rw-r--r--scripts/lib/devtool/standard.py55
6 files changed, 85 insertions, 25 deletions
diff --git a/meta-selftest/recipes-test/devtool/devtool-test-patch-gz.bb b/meta-selftest/recipes-test/devtool/devtool-test-patch-gz.bb
new file mode 100644
index 0000000000..719a5f1c9e
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-test-patch-gz.bb
@@ -0,0 +1,16 @@
1LICENSE = "GPLv2+"
2LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
3
4DEPENDS = "libxres libxext virtual/libx11 ncurses"
5
6SRC_URI = "http://downloads.yoctoproject.org/releases/xrestop/xrestop-0.4.tar.gz \
7 file://readme.patch.gz \
8 "
9
10S = "${WORKDIR}/xrestop-0.4"
11
12SRC_URI[md5sum] = "d8a54596cbaf037e62b80c4585a3ca9b"
13SRC_URI[sha256sum] = "67c2fc94a7ecedbaae0d1837e82e93d1d98f4a6d759828860e552119af3ce257"
14
15inherit autotools pkgconfig
16
diff --git a/meta-selftest/recipes-test/devtool/devtool-test-patch-gz/readme.patch.gz b/meta-selftest/recipes-test/devtool/devtool-test-patch-gz/readme.patch.gz
new file mode 100644
index 0000000000..4752492ccd
--- /dev/null
+++ b/meta-selftest/recipes-test/devtool/devtool-test-patch-gz/readme.patch.gz
Binary files differ
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 1f6927be04..2c1f58cbdc 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -10,13 +10,13 @@ PATCH_GIT_USER_EMAIL ?= "oe.patch@oe"
10 10
11inherit terminal 11inherit terminal
12 12
13def src_patches(d, all = False ): 13def src_patches(d, all=False, expand=True):
14 workdir = d.getVar('WORKDIR', True) 14 workdir = d.getVar('WORKDIR', True)
15 fetch = bb.fetch2.Fetch([], d) 15 fetch = bb.fetch2.Fetch([], d)
16 patches = [] 16 patches = []
17 sources = [] 17 sources = []
18 for url in fetch.urls: 18 for url in fetch.urls:
19 local = patch_path(url, fetch, workdir) 19 local = patch_path(url, fetch, workdir, expand)
20 if not local: 20 if not local:
21 if all: 21 if all:
22 local = fetch.localpath(url) 22 local = fetch.localpath(url)
@@ -55,13 +55,14 @@ def src_patches(d, all = False ):
55 55
56 return patches 56 return patches
57 57
58def patch_path(url, fetch, workdir): 58def patch_path(url, fetch, workdir, expand=True):
59 """Return the local path of a patch, or None if this isn't a patch""" 59 """Return the local path of a patch, or None if this isn't a patch"""
60 60
61 local = fetch.localpath(url) 61 local = fetch.localpath(url)
62 base, ext = os.path.splitext(os.path.basename(local)) 62 base, ext = os.path.splitext(os.path.basename(local))
63 if ext in ('.gz', '.bz2', '.Z'): 63 if ext in ('.gz', '.bz2', '.Z'):
64 local = os.path.join(workdir, base) 64 if expand:
65 local = os.path.join(workdir, base)
65 ext = os.path.splitext(base)[1] 66 ext = os.path.splitext(base)[1]
66 67
67 urldata = fetch.ud[url] 68 urldata = fetch.ud[url]
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index 6caae5f7d4..ab4177aa81 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -397,7 +397,7 @@ def get_recipe_local_files(d, patches=False):
397 for uri in uris: 397 for uri in uris:
398 if fetch.ud[uri].type == 'file': 398 if fetch.ud[uri].type == 'file':
399 if (not patches and 399 if (not patches and
400 bb.utils.exec_flat_python_func('patch_path', uri, fetch, '')): 400 bb.utils.exec_flat_python_func('patch_path', uri, fetch, '', expand=False)):
401 continue 401 continue
402 # Skip files that are referenced by absolute path 402 # Skip files that are referenced by absolute path
403 fname = fetch.ud[uri].basepath 403 fname = fetch.ud[uri].basepath
@@ -418,7 +418,7 @@ def get_recipe_patches(d):
418 patchfiles = [] 418 patchfiles = []
419 # Execute src_patches() defined in patch.bbclass - this works since that class 419 # Execute src_patches() defined in patch.bbclass - this works since that class
420 # is inherited globally 420 # is inherited globally
421 patches = bb.utils.exec_flat_python_func('src_patches', d) 421 patches = bb.utils.exec_flat_python_func('src_patches', d, expand=False)
422 for patch in patches: 422 for patch in patches:
423 _, _, local, _, _, parm = bb.fetch.decodeurl(patch) 423 _, _, local, _, _, parm = bb.fetch.decodeurl(patch)
424 patchfiles.append(local) 424 patchfiles.append(local)
@@ -437,7 +437,7 @@ def get_recipe_patched_files(d):
437 import oe.patch 437 import oe.patch
438 # Execute src_patches() defined in patch.bbclass - this works since that class 438 # Execute src_patches() defined in patch.bbclass - this works since that class
439 # is inherited globally 439 # is inherited globally
440 patches = bb.utils.exec_flat_python_func('src_patches', d) 440 patches = bb.utils.exec_flat_python_func('src_patches', d, expand=False)
441 patchedfiles = {} 441 patchedfiles = {}
442 for patch in patches: 442 for patch in patches:
443 _, _, patchfile, _, _, parm = bb.fetch.decodeurl(patch) 443 _, _, patchfile, _, _, parm = bb.fetch.decodeurl(patch)
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index f6226c1ad9..92dc5e5869 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -948,6 +948,30 @@ class DevtoolTests(DevtoolBase):
948 expected_status = [(' M', '.*/%s/file2$' % testrecipe)] 948 expected_status = [(' M', '.*/%s/file2$' % testrecipe)]
949 self._check_repo_status(os.path.dirname(recipefile), expected_status) 949 self._check_repo_status(os.path.dirname(recipefile), expected_status)
950 950
951 def test_devtool_update_recipe_local_patch_gz(self):
952 # First, modify the recipe
953 testrecipe = 'devtool-test-patch-gz'
954 recipefile = get_bb_var('FILE', testrecipe)
955 src_uri = get_bb_var('SRC_URI', testrecipe)
956 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
957 self.track_for_cleanup(tempdir)
958 self.track_for_cleanup(self.workspacedir)
959 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
960 # (don't bother with cleaning the recipe on teardown, we won't be building it)
961 result = runCmd('devtool modify %s' % testrecipe)
962 # Modify one file
963 srctree = os.path.join(self.workspacedir, 'sources', testrecipe)
964 runCmd('echo "Another line" >> README', cwd=srctree)
965 runCmd('git commit -a --amend --no-edit', cwd=srctree)
966 self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile)))
967 result = runCmd('devtool update-recipe %s' % testrecipe)
968 expected_status = [(' M', '.*/%s/readme.patch.gz$' % testrecipe)]
969 self._check_repo_status(os.path.dirname(recipefile), expected_status)
970 patch_gz = os.path.join(os.path.dirname(recipefile), testrecipe, 'readme.patch.gz')
971 result = runCmd('file %s' % patch_gz)
972 if 'gzip compressed data' not in result.output:
973 self.fail('New patch file is not gzipped - file reports:\n%s' % result.output)
974
951 @testcase(1163) 975 @testcase(1163)
952 def test_devtool_extract(self): 976 def test_devtool_extract(self):
953 tempdir = tempfile.mkdtemp(prefix='devtoolqa') 977 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 1511641099..af0d467985 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1128,7 +1128,7 @@ def _remove_source_files(append, files, destpath):
1128 raise 1128 raise
1129 1129
1130 1130
1131def _export_patches(srctree, rd, start_rev, destdir): 1131def _export_patches(srctree, rd, start_rev, destdir, changed_revs=None):
1132 """Export patches from srctree to given location. 1132 """Export patches from srctree to given location.
1133 Returns three-tuple of dicts: 1133 Returns three-tuple of dicts:
1134 1. updated - patches that already exist in SRCURI 1134 1. updated - patches that already exist in SRCURI
@@ -1157,18 +1157,44 @@ def _export_patches(srctree, rd, start_rev, destdir):
1157 # revision This does assume that people are using unique shortlog 1157 # revision This does assume that people are using unique shortlog
1158 # values, but they ought to be anyway... 1158 # values, but they ought to be anyway...
1159 new_basename = seqpatch_re.match(new_patch).group(2) 1159 new_basename = seqpatch_re.match(new_patch).group(2)
1160 found = False 1160 match_name = None
1161 for old_patch in existing_patches: 1161 for old_patch in existing_patches:
1162 old_basename = seqpatch_re.match(old_patch).group(2) 1162 old_basename = seqpatch_re.match(old_patch).group(2)
1163 if new_basename == old_basename: 1163 old_basename_splitext = os.path.splitext(old_basename)
1164 updated[new_patch] = existing_patches.pop(old_patch) 1164 if old_basename.endswith(('.gz', '.bz2', '.Z')) and old_basename_splitext[0] == new_basename:
1165 found = True 1165 old_patch_noext = os.path.splitext(old_patch)[0]
1166 # Rename patch files 1166 match_name = old_patch_noext
1167 if new_patch != old_patch:
1168 os.rename(os.path.join(destdir, new_patch),
1169 os.path.join(destdir, old_patch))
1170 break 1167 break
1171 if not found: 1168 elif new_basename == old_basename:
1169 match_name = old_patch
1170 break
1171 if match_name:
1172 # Rename patch files
1173 if new_patch != match_name:
1174 os.rename(os.path.join(destdir, new_patch),
1175 os.path.join(destdir, match_name))
1176 # Need to pop it off the list now before checking changed_revs
1177 oldpath = existing_patches.pop(old_patch)
1178 if changed_revs is not None:
1179 # Avoid updating patches that have not actually changed
1180 with open(os.path.join(destdir, match_name), 'r') as f:
1181 firstlineitems = f.readline().split()
1182 # Looking for "From <hash>" line
1183 if len(firstlineitems) > 1 and len(firstlineitems[1]) == 40:
1184 if not firstlineitems[1] in changed_revs:
1185 continue
1186 # Recompress if necessary
1187 if oldpath.endswith(('.gz', '.Z')):
1188 bb.process.run(['gzip', match_name], cwd=destdir)
1189 if oldpath.endswith('.gz'):
1190 match_name += '.gz'
1191 else:
1192 match_name += '.Z'
1193 elif oldpath.endswith('.bz2'):
1194 bb.process.run(['bzip2', match_name], cwd=destdir)
1195 match_name += '.bz2'
1196 updated[match_name] = oldpath
1197 else:
1172 added[new_patch] = None 1198 added[new_patch] = None
1173 return (updated, added, existing_patches) 1199 return (updated, added, existing_patches)
1174 1200
@@ -1415,7 +1441,7 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1415 # Get updated patches from source tree 1441 # Get updated patches from source tree
1416 patches_dir = tempfile.mkdtemp(dir=tempdir) 1442 patches_dir = tempfile.mkdtemp(dir=tempdir)
1417 upd_p, new_p, del_p = _export_patches(srctree, rd, update_rev, 1443 upd_p, new_p, del_p = _export_patches(srctree, rd, update_rev,
1418 patches_dir) 1444 patches_dir, changed_revs)
1419 updatefiles = False 1445 updatefiles = False
1420 updaterecipe = False 1446 updaterecipe = False
1421 destpath = None 1447 destpath = None
@@ -1453,13 +1479,6 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1453 updatefiles = True 1479 updatefiles = True
1454 for basepath, path in upd_p.items(): 1480 for basepath, path in upd_p.items():
1455 patchfn = os.path.join(patches_dir, basepath) 1481 patchfn = os.path.join(patches_dir, basepath)
1456 if changed_revs is not None:
1457 # Avoid updating patches that have not actually changed
1458 with open(patchfn, 'r') as f:
1459 firstlineitems = f.readline().split()
1460 if len(firstlineitems) > 1 and len(firstlineitems[1]) == 40:
1461 if not firstlineitems[1] in changed_revs:
1462 continue
1463 logger.info('Updating patch %s' % basepath) 1482 logger.info('Updating patch %s' % basepath)
1464 _move_file(patchfn, path) 1483 _move_file(patchfn, path)
1465 updatefiles = True 1484 updatefiles = True