Patchwork [3/6] scripts/oe-pkgdata-util: check path arguments to ensure they exist

login
register
mail settings
Submitter Paul Eggleton
Date Oct. 28, 2013, 5:11 p.m.
Message ID <eff2690f7976664e6257c1c19c89feea9152eb9e.1382980153.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/60591/
State Accepted
Commit 4ec1f8c0181b7f50214e64c39f0f69e991b49194
Headers show

Comments

Paul Eggleton - Oct. 28, 2013, 5:11 p.m.
Show an error if the specified paths don't exist.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 scripts/oe-pkgdata-util | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch

diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index e34fcbe..01fccd2 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -37,6 +37,14 @@  def glob(args, usage):
     pkglist_file = args[1]
     globs = args[2].split()
 
+    if not os.path.exists(pkgdata_dir):
+        print('ERROR: Unable to find pkgdata directory %s' % pkgdata_dir)
+        sys.exit(1)
+
+    if not os.path.exists(pkglist_file):
+        print('ERROR: Unable to find package list file %s' % pkglist_file)
+        sys.exit(1)
+
     skipregex = re.compile("-locale-|^locale-base-|-dev$|-doc$|-dbg$|-staticdev$|^kernel-module-")
 
     mappedpkgs = set()
@@ -148,6 +156,10 @@  def read_value(args, usage):
     var = args[1]
     packages = args[2].split()
 
+    if not os.path.exists(pkgdata_dir):
+        print('ERROR: Unable to find pkgdata directory %s' % pkgdata_dir)
+        sys.exit(1)
+
     def readvar(pkgdata_file, var):
         val = ""
         with open(pkgdata_file, 'r') as f: