Skip to contentSkip to conversation

wic: plugins: rawcopy: Fixed wrong variable type

PATCH New Daniel Schultz 1 participant 2 messages Mar 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wic: plugins: rawcopy: Fixed wrong variable type

Without the int() function this variable will be a string. This will led to a error in Filemap on line 545 due wrong types.

Quoted 5 lines

[...]
File
".../poky/scripts/lib/wic/filemap.py", line 545, in sparse_copy
if start < skip < end:
TypeError: unorderable types: int() < str()

---
 scripts/lib/wic/plugins/source/rawcopy.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lib/wic/plugins/source/rawcopy.py +1 -1
index 5bd22fd..618dd44 100644
@@ -71,7 +71,7 @@ class RawCopyPlugin(SourcePlugin):
         dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno))
 
         if 'skip' in source_params:
-            sparse_copy(src, dst, skip=source_params['skip'])
+            sparse_copy(src, dst, skip=int(source_params['skip']))
         else:
             sparse_copy(src, dst)
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 wic: filemap: Fixed spared_copy skip

This patches removes the empty space in front of the copied file which was skipped. Without this reduction it's not possible to place a partition with rawcopy and skip parameter on a desired alignment.

---
 scripts/lib/wic/filemap.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/lib/wic/filemap.py +3 -3
index f3240ba..162603e 100644
@@ -543,9 +543,9 @@ def sparse_copy(src_fname, dst_fname, offset=0, skip=0):
         end = (last + 1) * fmap.block_size
 
         if start < skip < end:
-            start = skip
-
-        fmap._f_image.seek(start, os.SEEK_SET)
+            fmap._f_image.seek(skip, os.SEEK_SET)
+        else:
+            fmap._f_image.seek(start, os.SEEK_SET)
         dst_file.seek(offset + start, os.SEEK_SET)
 
         chunk_size = 1024 * 1024
Signature · 1 line
1.9.1