Cleanup subprocess calls
PATCH v2 1/1 Cleanup subprocess calls
Changed since V1:
changed smart_opt to an array and fixed the effected functions cleaned up _invoke_smart calls to use arrays
Note that there is still some work to do on this file in terms of subprocess calls, which I will create a bug for, but that this is a good stopping point for M4.
Stephano Cetola (1):
subprocess: remove strings and migrate to direct arrays
meta/lib/oe/distro_check.py | 2 +- meta/lib/oe/package.py | 13 +-- meta/lib/oe/package_manager.py | 218 ++++++++++++++++++++--------------------- 3 files changed, 114 insertions(+), 119 deletions(-)
Signature · 1 line
2.10.0
PATCH v2 1/1 subprocess: remove strings and migrate to direct arrays
When using subprocess call and check_output, it is better to use arrays rather than strings when possible to avoid whitespace and quoting problems.
[ YOCTO #9342 ]
--- meta/lib/oe/distro_check.py | 2 +- meta/lib/oe/package.py | 13 +-- meta/lib/oe/package_manager.py | 218 ++++++++++++++++++++--------------------- 3 files changed, 114 insertions(+), 119 deletions(-)
meta/lib/oe/distro_check.py +1 -1
@@ -359,7 +359,7 @@ def create_log_file(d, logname): slogfile = os.path.join(logpath, logname) if os.path.exists(slogfile): os.remove(slogfile) - subprocess.call("touch %s" % logfile, shell=True) + subprocess.call(["touch", logfile]) os.symlink(logfile, slogfile) d.setVar('LOG_FILE', logfile) return logfile
meta/lib/oe/package.py +7 -6
@@ -18,23 +18,24 @@ def runstrip(arg): newmode = origmode | stat.S_IWRITE | stat.S_IREAD os.chmod(file, newmode) - extraflags = "" + stripcmd = [strip] # kernel module if elftype & 16: - extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" + stripcmd.extend(["--strip-debug", "--remove-section=.comment", + "--remove-section=.note", "--preserve-dates"]) # .so and shared library elif ".so" in file and elftype & 8: - extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" + stripcmd.extend(["--remove-section=.comment", "--remove-section=.note", "--strip-unneeded"]) # shared or executable: elif elftype & 8 or elftype & 4: - extraflags = "--remove-section=.comment --remove-section=.note" + stripcmd.extend(["--remove-section=.comment", "--remove-section=.note"]) - stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) + stripcmd.append(file) bb.debug(1, "runstrip: %s" % stripcmd) try: - output = subprocess.check_output(stripcmd, stderr=subprocess.STDOUT, shell=True) + output = subprocess.check_output(stripcmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: bb.error("runstrip: '%s' strip command failed with %s (%s)" % (stripcmd, e.returncode, e.output))
meta/lib/oe/package_manager.py +106 -112
416 lines not on this page · raw message
Signature · 1 line
2.10.0
Re: [PATCH V2] subprocess: remove strings and migrate to direct arrays
Quoted 7 lines · Stephano Cetola
When using subprocess call and
check_output, it is better to use arrays
rather than strings when possible to avoid whitespace and quoting problems.[ YOCTO #9342 ]
Quoted 7 lines
Signed-off-by Stephano Cetola <[email protected]>---
meta/lib/oe/distro_check.py | 2 +- meta/lib/oe/package.py | 13 +--meta/lib/oe/package_manager.py| 218 ++++++++++++++++++++-----------
----------3 files changed, 114 insertions(+), 119 deletions(-)
This triggered a lot of errors on the autobuilder:
http://autobuilder.yocto.io:8010/builders/build-appliance/builds/70
http://autobuilder.yocto.io:8010/builders/nightly-x86/builds/75
http://autobuilder.yocto.io:8010/builders/nightly-x86-64/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-x86-64-lsb/builds/72
http://autobuilder.yocto.io:8010/builders/nightly-x86-lsb/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-wic/builds/73
Re: [PATCH V2] subprocess: remove strings and migrate to direct arrays
In reply to Stephano CetolaQuoted 8 lines · Stephano Cetola
When using subprocess call and
check_output, it is better to use arrays
rather than strings when possible to avoid whitespace and quoting problems.[ YOCTO #9342 ]
Quoted 7 lines
Signed-off-by Stephano Cetola <[email protected]>---
meta/lib/oe/distro_check.py | 2 +- meta/lib/oe/package.py | 13 +--meta/lib/oe/package_manager.py| 218 ++++++++++++++++++++-----------
----------3 files changed, 114 insertions(+), 119 deletions(-)
This triggered a lot of errors on the autobuilder:
http://autobuilder.yocto.io:8010/builders/build-appliance/builds/70
http://autobuilder.yocto.io:8010/builders/nightly-x86/builds/75
http://autobuilder.yocto.io:8010/builders/nightly-x86-64/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-x86-64-lsb/builds/72
http://autobuilder.yocto.io:8010/builders/nightly-x86-lsb/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-wic/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-qa-extras/builds/55
http://autobuilder.yocto.io:8010/builders/nightly-oe-selftest/builds/70
http://autobuilder.yocto.io:8010/builders/nightly-multilib/builds/78
and similar errors on the main AB. I've confirmed it is this patch which causes the issue. Presumably some errors are occurring but are currently silently being ignored?
Its probably worth looking into what is going on in case there is some real issue here but at this point given the complexity of the changes I'm leaning towwards deferring this for 2.3.
Cheers,
Richard
Re: [PATCH V2] subprocess: remove strings and migrate to direct arrays
Quoted 28 lines · Richard Purdie
Quoted 8 lines · Stephano Cetola
When using subprocess call and
check_output, it is better to use arrays
rather than strings when possible to avoid whitespace and quoting problems.[ YOCTO #9342 ]
Quoted 7 lines
Signed-off-by Stephano Cetola <[email protected]>---
meta/lib/oe/distro_check.py | 2 +- meta/lib/oe/package.py | 13 +--meta/lib/oe/package_manager.py| 218 ++++++++++++++++++++-----------
----------3 files changed, 114 insertions(+), 119 deletions(-)This triggered a lot of errors on the autobuilder:
http://autobuilder.yocto.io:8010/builders/build-appliance/builds/70
http://autobuilder.yocto.io:8010/builders/nightly-x86/builds/75
http://autobuilder.yocto.io:8010/builders/nightly-x86-64/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-x86-64-lsb/builds/72
http://autobuilder.yocto.io:8010/builders/nightly-x86-lsb/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-wic/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-qa-extras/builds/55
http://autobuilder.yocto.io:8010/builders/nightly-oe-selftest/builds/70
http://autobuilder.yocto.io:8010/builders/nightly-multilib/builds/78
Quoted 3 lines
and similar errors on the main AB. I've confirmed it is this patch which causes the issue. Presumably some errors are occurring but are currently silently being ignored?
The solution here is probably to write a thorough test for package_manager.py. I imagine that is the culprit. I'm fine with moving this to 2.3 and I'll add a bug to create a robust set of tests.
Quoted 8 lines
Its probably worth looking into what is going on in case there is some real issue here but at this point given the complexity of the changes I'm leaning towwards deferring this for 2.3.
Cheers,
Richard
Re: [PATCH V2] subprocess: remove strings and migrate to direct arrays
In reply to Richard PurdieQuoted 28 lines · Richard Purdie
Quoted 8 lines · Stephano Cetola
When using subprocess call and
check_output, it is better to use arrays
rather than strings when possible to avoid whitespace and quoting problems.[ YOCTO #9342 ]
Quoted 7 lines
Signed-off-by Stephano Cetola <[email protected]>--- meta/lib/oe/distro_check.py | 2 +- meta/lib/oe/package.py | 13 +-- meta/lib/oe/package_manager.py | 218 ++++++++++++++++++++----------- ---------- 3 files changed, 114 insertions(+), 119 deletions(-)This triggered a lot of errors on the autobuilder:
http://autobuilder.yocto.io:8010/builders/build-appliance/builds/70
http://autobuilder.yocto.io:8010/builders/nightly-x86/builds/75
http://autobuilder.yocto.io:8010/builders/nightly-x86-64/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-x86-64-lsb/builds/72
http://autobuilder.yocto.io:8010/builders/nightly-x86-lsb/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-wic/builds/73
http://autobuilder.yocto.io:8010/builders/nightly-qa-extras/builds/55
http://autobuilder.yocto.io:8010/builders/nightly-oe-selftest/builds/70
http://autobuilder.yocto.io:8010/builders/nightly-multilib/builds/78
Quoted 7 lines
and similar errors on the main AB. I've confirmed it is this patch which causes the issue. Presumably some errors are occurring but are currently silently being ignored?
Its probably worth looking into what is going on in case there is some real issue here but at this point given the complexity of the changes I'm leaning towwards deferring this for 2.3.
I’m a bit curious about why this was queued for 2.2 anyway, given it’s not a clear bugfix. Are we not past the feature freeze date?
Signature · 5 lines
Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics