meta: Cleanup getstatusoutput usage
cover meta: Cleanup getstatusoutput usage
The following changes since commit 1314a6953aa647706107557faaba8574e307d2bd:
patch: fix CVE-2018-6952 (2018-08-23 07:45:32 +0100)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib rbt/subprocess
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/subprocess
Robert Yang (5):
lib/oe/gpg_sign.py: Clean up getstatusoutput usage lib/oe/patch.py: Clean up getstatusoutput usage kernel-yocto.bbclass: Clean up getstatusoutput usage
psplash: Clean up getstatusoutput usage compress_doc.bbclass: Clean up getstatusoutput usage
meta/classes/compress_doc.bbclass | 7 ++++--- meta/classes/kernel-yocto.bbclass | 5 +++-- meta/lib/oe/gpg_sign.py | 15 +++++---------- meta/lib/oe/patch.py | 3 ++- meta/recipes-core/psplash/psplash_git.bb | 5 +++-- 5 files changed, 17 insertions(+), 18 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/5 lib/oe/gpg_sign.py: Clean up getstatusoutput usage
Replace usage of oe.utils.getstatusoutput() with direct subprocess calls.
--- meta/lib/oe/gpg_sign.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
meta/lib/oe/gpg_sign.py +5 -10
@@ -3,6 +3,8 @@ import os import bb import oe.utils +import subprocess +import shlex class LocalSigner(object): """Class for handling local (on the build host) signing"""
@@ -23,10 +25,7 @@ class LocalSigner(object): if armor: cmd += "--armor " cmd += keyid - status, output = oe.utils.getstatusoutput(cmd) - if status: - raise bb.build.FuncFailed('Failed to export gpg public key (%s): %s' % - (keyid, output)) + subprocess.check_output(shlex.split(cmd), stderr=subprocess.STDOUT) def sign_rpms(self, files, keyid, passphrase, digest, sign_chunk, fsk=None, fsk_password=None): """Sign RPM files"""
@@ -48,13 +47,10 @@ class LocalSigner(object): # Sign in chunks for i in range(0, len(files), sign_chunk): - status, output = oe.utils.getstatusoutput(cmd + ' '.join(files[i:i+sign_chunk])) - if status: - raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output) + subprocess.check_output(shlex.split(cmd + ' '.join(files[i:i+sign_chunk])), stderr=subprocess.STDOUT) def detach_sign(self, input_file, keyid, passphrase_file, passphrase=None, armor=True): """Create a detached signature of a file""" - import subprocess if passphrase_file and passphrase: raise Exception("You should use either passphrase_file of passphrase, not both")
@@ -100,7 +96,6 @@ class LocalSigner(object): def get_gpg_version(self): """Return the gpg version as a tuple of ints""" - import subprocess try: ver_str = subprocess.check_output((self.gpg_bin, "--version", "--no-permission-warning")).split()[2].decode("utf-8") return tuple([int(i) for i in ver_str.split("-")[0].split('.')])
@@ -114,7 +109,7 @@ class LocalSigner(object): if self.gpg_path: cmd += "--homedir %s " % self.gpg_path cmd += sig_file - status, _ = oe.utils.getstatusoutput(cmd) + status = subprocess.call(shlex.split(cmd)) ret = False if status else True return ret
Signature · 1 line
2.7.4
PATCH 2/5 lib/oe/patch.py: Clean up getstatusoutput usage
In reply to Robert YangWe can't use subprocess.check_output() or subprocess.call() here since the one who invokes runcmd() needs handle CmdError() exception (error out or ignore it).
--- meta/lib/oe/patch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/lib/oe/patch.py +2 -1
@@ -21,6 +21,7 @@ class CmdError(bb.BBHandledException): def runcmd(args, dir = None): import pipes + import subprocess if dir: olddir = os.path.abspath(os.curdir)
@@ -33,7 +34,7 @@ def runcmd(args, dir = None): args = [ pipes.quote(str(arg)) for arg in args ] cmd = " ".join(args) # print("cmd: %s" % cmd) - (exitstatus, output) = oe.utils.getstatusoutput(cmd) + (exitstatus, output) = subprocess.getstatusoutput(cmd) if exitstatus != 0: raise CmdError(cmd, exitstatus >> 8, output) if " fuzz " in output:
Signature · 1 line
2.7.4
PATCH 3/5 kernel-yocto.bbclass: Clean up getstatusoutput usage
In reply to Robert YangReplace usage of oe.utils.getstatusoutput() with direct subprocess calls.
--- meta/classes/kernel-yocto.bbclass | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
meta/classes/kernel-yocto.bbclass +3 -2
@@ -322,6 +322,7 @@ addtask kernel_configme before do_configure after do_patch python do_kernel_configcheck() { import re, string, sys + import subprocess # if KMETA isn't set globally by a recipe using this routine, we need to # set the default to 'meta'. Otherwise, kconf_check is not passed a valid
@@ -333,10 +334,10 @@ python do_kernel_configcheck() { pathprefix = "export PATH=%s:%s; " % (d.getVar('PATH'), "${S}/scripts/util/") cmd = d.expand("scc --configs -o ${S}/.kernel-meta") - ret, configs = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd)) + configs = subprocess.getoutput("%s%s" % (pathprefix, cmd)) cmd = d.expand("cd ${S}; kconf_check --report -o ${S}/%s/cfg/ ${B}/.config ${S} %s" % (kmeta,configs)) - ret, result = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd)) + result = subprocess.getoutput("%s%s" % (pathprefix, cmd)) config_check_visibility = int(d.getVar("KCONF_AUDIT_LEVEL") or 0) bsp_check_visibility = int(d.getVar("KCONF_BSP_AUDIT_LEVEL") or 0)
Signature · 1 line
2.7.4
Re: [PATCH 3/5] kernel-yocto.bbclass: Clean up getstatusoutput usage
ignore this patch. I already have a more complete version that was sent previously and is in my queue I'll send later today.
Bruce
Quoted 40 lines · Robert Yang
Replace usage of
oe.utils.getstatusoutput()with direct subprocess calls.Signed-off-by Robert Yang <[email protected]>--- meta/classes/kernel-yocto.bbclass | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)meta/classes/kernel-yocto.bbclass +3
-3@@ -322,6 +322,7 @@ addtask kernel_configme before do_configure after do_patch python do_kernel_configcheck() { import re, string, sys + import subprocess # if KMETA isn't set globally by a recipe using this routine, we need to # set the default to 'meta'. Otherwise, kconf_check is not passed a valid@@ -333,10 +334,10 @@ python do_kernel_configcheck() { pathprefix = "export PATH=%s:%s; " % (d.getVar('PATH'), "${S}/scripts/util/") cmd = d.expand("scc --configs -o ${S}/.kernel-meta") - ret, configs = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd)) + configs = subprocess.getoutput("%s%s" % (pathprefix, cmd)) cmd = d.expand("cd ${S}; kconf_check --report -o ${S}/%s/cfg/ ${B}/.config ${S} %s" % (kmeta,configs)) - ret, result = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd)) + result = subprocess.getoutput("%s%s" % (pathprefix, cmd)) config_check_visibility = int(d.getVar("KCONF_AUDIT_LEVEL") or 0) bsp_check_visibility = int(d.getVar("KCONF_BSP_AUDIT_LEVEL") or 0) --2.7.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
PATCH 4/5 psplash: Clean up getstatusoutput usage
In reply to Robert YangReplace usage of oe.utils.getstatusoutput() with direct subprocess calls.
--- meta/recipes-core/psplash/psplash_git.bb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-core/psplash/psplash_git.bb +3 -2
@@ -73,6 +73,8 @@ ALTERNATIVE_LINK_NAME[psplash] = "${bindir}/psplash" python do_compile () { import shutil + import subprocess + import shlex # Build a separate executable for each splash image workdir = d.getVar('WORKDIR')
@@ -82,8 +84,7 @@ python do_compile () { outputfiles = d.getVar('SPLASH_INSTALL').split() for localfile, outputfile in zip(localfiles, outputfiles): if localfile.endswith(".png"): - outp = oe.utils.getstatusoutput('%s %s POKY' % (convertscript, os.path.join(workdir, localfile))) - print(outp[1]) + subprocess.call(shlex.split('%s %s POKY' % (convertscript, os.path.join(workdir, localfile)))) fbase = os.path.splitext(localfile)[0] shutil.copyfile("%s-img.h" % fbase, destfile) else:
Signature · 1 line
2.7.4
PATCH 5/5 compress_doc.bbclass: Clean up getstatusoutput usage
In reply to Robert YangReplace usage of oe.utils.getstatusoutput() with direct subprocess calls.
--- meta/classes/compress_doc.bbclass | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
meta/classes/compress_doc.bbclass +4 -3
@@ -79,6 +79,7 @@ def _collect_hardlink(hardlink_dict, file): return hardlink_dict def _process_hardlink(hardlink_dict, compress_mode, shell_cmds, decompress=False): + import subprocess for target in hardlink_dict: if decompress: compress_format = _get_compress_format(target, shell_cmds.keys())
@@ -87,7 +88,7 @@ def _process_hardlink(hardlink_dict, compress_mode, shell_cmds, decompress=False else: cmd = "%s -f %s" % (shell_cmds[compress_mode], target) bb.note('compress hardlink %s' % target) - (retval, output) = oe.utils.getstatusoutput(cmd) + (retval, output) = subprocess.getstatusoutput(cmd) if retval: bb.warn("de/compress file failed %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else "")) return
@@ -176,7 +177,7 @@ def compress_doc(topdir, compress_mode, compress_cmds): # Normal file elif os.path.isfile(file): cmd = "%s %s" % (compress_cmds[compress_mode], file) - (retval, output) = oe.utils.getstatusoutput(cmd) + (retval, output) = subprocess.getstatusoutput(cmd) if retval: bb.warn("compress failed %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else "")) continue
@@ -206,7 +207,7 @@ def decompress_doc(topdir, compress_mode, decompress_cmds): # Normal file elif os.path.isfile(file): cmd = "%s %s" % (decompress_cmds[compress_format], file) - (retval, output) = oe.utils.getstatusoutput(cmd) + (retval, output) = subprocess.getstatusoutput(cmd) if retval: bb.warn("decompress failed %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else "")) continue
Signature · 1 line
2.7.4