Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v3 1/2] image.bbclass: add prohibited-paths QA test
@ 2017-11-15 15:10 Martyn Welch
  2017-11-15 15:10 ` [PATCH v3 2/2] ref-manual: Add documentation for prohibited-path " Martyn Welch
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Martyn Welch @ 2017-11-15 15:10 UTC (permalink / raw)
  To: yocto, openembedded-core

Sometimes we wish to ensure that files or directories are not installed
somewhere that may prove detrimental to the operation of the system. For
example, this may be the case if files are placed in a directory that is
utilised as a mount point at run time, thus making them inaccessible once
when the mount point is being utilised.

Implement the prohibited paths QA test, which enables such locations to be
specified in a "PROHIBITED_PATHS" variable. This implementation allows for
a colon separated list of paths to be provided. Shell style wildcards can
be used.

Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>
Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
---
Changes since v1:
 - Correcting author and SOB.

Changes since v2:
 - Reimplemented as image rather than package level QA test.
 - Changed variable from PROHIBITED_PATH to PROHIBITED_PATHS to better
   reflect its use.

 meta/classes/image.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index d93de02..bebb363 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -296,6 +296,26 @@ python do_image_complete_setscene () {
 }
 addtask do_image_complete_setscene
 
+python image_check_prohibited_paths () {
+    import glob
+    from oe.utils import ImageQAFailed
+
+    rootfs = d.getVar('IMAGE_ROOTFS')
+
+    path = d.getVar('PROHIBITED_PATHS')
+    if path != None and path != "":
+        for p in path.split(':'):
+            if p[0] != '/':
+                raise ImageQAFailed("PROHIBITED_PATHS \"%s\" must be an absolute path" % p, image_check_prohibited_paths)
+
+            match = glob.glob("%s%s" % (rootfs, p))
+            if match:
+                loc = ", ".join(item.replace(rootfs, '') for item in match)
+                raise ImageQAFailed("Match(es) for PROHIBITED_PATHS \"%s\": %s" % (p, loc), image_check_prohibited_paths)
+}
+
+IMAGE_QA_COMMANDS += "image_check_prohibited_paths"
+
 # Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
 #
 # IMAGE_QA_COMMANDS += " \
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-11-16 10:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-15 15:10 [PATCH v3 1/2] image.bbclass: add prohibited-paths QA test Martyn Welch
2017-11-15 15:10 ` [PATCH v3 2/2] ref-manual: Add documentation for prohibited-path " Martyn Welch
2017-11-15 15:35 ` ✗ patchtest: failure for "[v3] image.bbclass: add prohib..." and 1 more Patchwork
2017-11-15 20:46 ` [PATCH v3 1/2] image.bbclass: add prohibited-paths QA test Otavio Salvador
2017-11-16  9:40   ` Martyn Welch
2017-11-16 10:19   ` Martyn Welch
2017-11-16 10:32 ` Alexander Kanavin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox