summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py73
-rw-r--r--scripts/lib/wic/help.py10
-rw-r--r--scripts/lib/wic/ksparser.py1
-rw-r--r--scripts/lib/wic/partition.py1
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py7
5 files changed, 72 insertions, 20 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 3c5be2f501..46cd98b193 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -44,6 +44,24 @@ def only_for_arch(archs, image='core-image-minimal'):
44 return wrapped_f 44 return wrapped_f
45 return wrapper 45 return wrapper
46 46
47def extract_files(debugfs_output):
48 """
49 extract file names from the output of debugfs -R 'ls -p',
50 which looks like this:
51
52 /2/040755/0/0/.//\n
53 /2/040755/0/0/..//\n
54 /11/040700/0/0/lost+found^M//\n
55 /12/040755/1002/1002/run//\n
56 /13/040755/1002/1002/sys//\n
57 /14/040755/1002/1002/bin//\n
58 /80/040755/1002/1002/var//\n
59 /92/040755/1002/1002/tmp//\n
60 """
61 # NOTE the occasional ^M in file names
62 return [line.split('/')[5].strip() for line in \
63 debugfs_output.strip().split('/\n')]
64
47 65
48class WicTestCase(OESelftestTestCase): 66class WicTestCase(OESelftestTestCase):
49 """Wic test class.""" 67 """Wic test class."""
@@ -393,24 +411,6 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
393 runCmd("dd if=%s of=%s skip=%d count=%d" % 411 runCmd("dd if=%s of=%s skip=%d count=%d" %
394 (wicimg, part_file, start, length)) 412 (wicimg, part_file, start, length))
395 413
396 def extract_files(debugfs_output):
397 """
398 extract file names from the output of debugfs -R 'ls -p',
399 which looks like this:
400
401 /2/040755/0/0/.//\n
402 /2/040755/0/0/..//\n
403 /11/040700/0/0/lost+found^M//\n
404 /12/040755/1002/1002/run//\n
405 /13/040755/1002/1002/sys//\n
406 /14/040755/1002/1002/bin//\n
407 /80/040755/1002/1002/var//\n
408 /92/040755/1002/1002/tmp//\n
409 """
410 # NOTE the occasional ^M in file names
411 return [line.split('/')[5].strip() for line in \
412 debugfs_output.strip().split('/\n')]
413
414 # Test partition 1, should contain the normal root directories, except 414 # Test partition 1, should contain the normal root directories, except
415 # /usr. 415 # /usr.
416 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \ 416 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
@@ -451,6 +451,43 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
451 finally: 451 finally:
452 os.environ['PATH'] = oldpath 452 os.environ['PATH'] = oldpath
453 453
454 def test_include_path(self):
455 """Test --include-path wks option."""
456
457 oldpath = os.environ['PATH']
458 os.environ['PATH'] = get_bb_var("PATH", "wic-tools")
459
460 try:
461 include_path = os.path.join(self.resultdir, 'test-include')
462 os.makedirs(include_path)
463 with open(os.path.join(include_path, 'test-file'), 'w') as t:
464 t.write("test\n")
465 wks_file = os.path.join(include_path, 'temp.wks')
466 with open(wks_file, 'w') as wks:
467 rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal')
468 wks.write("""
469part /part1 --source rootfs --ondisk mmcblk0 --fstype=ext4
470part /part2 --source rootfs --ondisk mmcblk0 --fstype=ext4 --include-path %s"""
471 % (include_path))
472 runCmd("wic create %s -e core-image-minimal -o %s" \
473 % (wks_file, self.resultdir))
474
475 part1 = glob(os.path.join(self.resultdir, 'temp-*.direct.p1'))[0]
476 part2 = glob(os.path.join(self.resultdir, 'temp-*.direct.p2'))[0]
477
478 # Test partition 1, should not contain 'test-file'
479 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % (part1))
480 files = extract_files(res.output)
481 self.assertNotIn('test-file', files)
482
483 # Test partition 2, should not contain 'test-file'
484 res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % (part2))
485 files = extract_files(res.output)
486 self.assertIn('test-file', files)
487
488 finally:
489 os.environ['PATH'] = oldpath
490
454 def test_exclude_path_errors(self): 491 def test_exclude_path_errors(self):
455 """Test --exclude-path wks option error handling.""" 492 """Test --exclude-path wks option error handling."""
456 wks_file = 'temp.wks' 493 wks_file = 'temp.wks'
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 29c4e436d8..4d342fcf05 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -969,6 +969,16 @@ DESCRIPTION
969 is omitted, not the directory itself. This option only 969 is omitted, not the directory itself. This option only
970 has an effect with the rootfs source plugin. 970 has an effect with the rootfs source plugin.
971 971
972 --include-path: This option is specific to wic. It adds the contents
973 of the given path to the resulting image. The path is
974 relative to the directory in which wic is running not
975 the rootfs itself so use of an absolute path is
976 recommended. This option is most useful when multiple
977 copies of the rootfs are added to an image and it is
978 required to add extra content to only one of these
979 copies. This option only has an effect with the rootfs
980 source plugin.
981
972 --extra-space: This option is specific to wic. It adds extra 982 --extra-space: This option is specific to wic. It adds extra
973 space after the space filled by the content 983 space after the space filled by the content
974 of the partition. The final size can go 984 of the partition. The final size can go
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 6a643ba3af..707a2e8019 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -137,6 +137,7 @@ class KickStart():
137 part.add_argument('--active', action='store_true') 137 part.add_argument('--active', action='store_true')
138 part.add_argument('--align', type=int) 138 part.add_argument('--align', type=int)
139 part.add_argument('--exclude-path', nargs='+') 139 part.add_argument('--exclude-path', nargs='+')
140 part.add_argument('--include-path', nargs='+')
140 part.add_argument("--extra-space", type=sizetype) 141 part.add_argument("--extra-space", type=sizetype)
141 part.add_argument('--fsoptions', dest='fsopts') 142 part.add_argument('--fsoptions', dest='fsopts')
142 part.add_argument('--fstype', default='vfat', 143 part.add_argument('--fstype', default='vfat',
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index d809408e1a..2d95f78439 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -30,6 +30,7 @@ class Partition():
30 self.device = None 30 self.device = None
31 self.extra_space = args.extra_space 31 self.extra_space = args.extra_space
32 self.exclude_path = args.exclude_path 32 self.exclude_path = args.exclude_path
33 self.include_path = args.include_path
33 self.fsopts = args.fsopts 34 self.fsopts = args.fsopts
34 self.fstype = args.fstype 35 self.fstype = args.fstype
35 self.label = args.label 36 self.label = args.label
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index e26e95b991..705aeb5563 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -71,7 +71,7 @@ class RootfsPlugin(SourcePlugin):
71 71
72 new_rootfs = None 72 new_rootfs = None
73 # Handle excluded paths. 73 # Handle excluded paths.
74 if part.exclude_path is not None: 74 if part.exclude_path or part.include_path:
75 # We need a new rootfs directory we can delete files from. Copy to 75 # We need a new rootfs directory we can delete files from. Copy to
76 # workdir. 76 # workdir.
77 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) 77 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno))
@@ -81,7 +81,10 @@ class RootfsPlugin(SourcePlugin):
81 81
82 copyhardlinktree(part.rootfs_dir, new_rootfs) 82 copyhardlinktree(part.rootfs_dir, new_rootfs)
83 83
84 for orig_path in part.exclude_path: 84 for path in part.include_path or []:
85 copyhardlinktree(path, new_rootfs)
86
87 for orig_path in part.exclude_path or []:
85 path = orig_path 88 path = orig_path
86 if os.path.isabs(path): 89 if os.path.isabs(path):
87 logger.error("Must be relative: --exclude-path=%s" % orig_path) 90 logger.error("Must be relative: --exclude-path=%s" % orig_path)