Patchwork [RFC] package.py: use subprocess.Popen for rpmdeps call

login
register
mail settings
Submitter Martin Jansa
Date Feb. 23, 2014, 10:44 a.m.
Message ID <1393152262-30469-1-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/67177/
State Accepted
Commit ff8d8fbc9e49bf9a6e7499a9550b343f5bf4942a
Headers show

Comments

Martin Jansa - Feb. 23, 2014, 10:44 a.m.
* I've noticed errors like this in log.do_package:

  DEBUG: Executing python function package_do_filedeps
  sh: 1: Syntax error: "(" unexpected
  sh: 1: Syntax error: "(" unexpected
  DEBUG: Python function package_do_filedeps finished

  which are actually caused by some filenames included in package
  containing '()' characters

  Maybe we should change meta/classes/package.bbclass to
  fail when some filedeprunner call fails like this and fix
  filedeprunner to escape '()' and other possibly dangerous chars
  it's called like this:
  processed = list(pool.imap(oe.package.filedeprunner, pkglist))

* don't use shell=True
* show the command when it fails and let do_package task to fail

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/lib/oe/package.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 9a0ddb8..f8b5322 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -54,7 +54,7 @@  def file_translate(file):
     return ft
 
 def filedeprunner(arg):
-    import re
+    import re, subprocess, shlex
 
     (pkg, pkgfiles, rpmdeps, pkgdest) = arg
     provides = {}
@@ -89,8 +89,11 @@  def filedeprunner(arg):
 
         return provides, requires
 
-    dep_pipe = os.popen(rpmdeps + " " + " ".join(pkgfiles))
-
-    provides, requires = process_deps(dep_pipe, pkg, pkgdest, provides, requires)
+    try:
+        dep_popen = subprocess.Popen(shlex.split(rpmdeps) + pkgfiles, stdout=subprocess.PIPE)
+        provides, requires = process_deps(dep_popen.stdout, pkg, pkgdest, provides, requires)
+    except OSError as e:
+        bb.error("rpmdeps: '%s' command failed, '%s'" % (shlex.split(rpmdeps) + pkgfiles, e))
+        raise e
 
     return (pkg, provides, requires)