* [PATCH 0/5] meta: Cleanup getstatusoutput usage
@ 2018-08-23 8:07 Robert Yang
2018-08-23 8:07 ` [PATCH 1/5] lib/oe/gpg_sign.py: Clean up " Robert Yang
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Robert Yang @ 2018-08-23 8:07 UTC (permalink / raw)
To: openembedded-core
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] lib/oe/gpg_sign.py: Clean up getstatusoutput usage
2018-08-23 8:07 [PATCH 0/5] meta: Cleanup getstatusoutput usage Robert Yang
@ 2018-08-23 8:07 ` Robert Yang
2018-08-23 8:07 ` [PATCH 2/5] lib/oe/patch.py: " Robert Yang
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Robert Yang @ 2018-08-23 8:07 UTC (permalink / raw)
To: openembedded-core
Replace usage of oe.utils.getstatusoutput() with direct subprocess calls.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/lib/oe/gpg_sign.py | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index b172729..ccd5aee 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -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
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] lib/oe/patch.py: Clean up getstatusoutput usage
2018-08-23 8:07 [PATCH 0/5] meta: Cleanup getstatusoutput usage Robert Yang
2018-08-23 8:07 ` [PATCH 1/5] lib/oe/gpg_sign.py: Clean up " Robert Yang
@ 2018-08-23 8:07 ` Robert Yang
2018-08-23 8:07 ` [PATCH 3/5] kernel-yocto.bbclass: " Robert Yang
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Robert Yang @ 2018-08-23 8:07 UTC (permalink / raw)
To: openembedded-core
We 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).
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/lib/oe/patch.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index af7aa52..e0f0604 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -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:
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] kernel-yocto.bbclass: Clean up getstatusoutput usage
2018-08-23 8:07 [PATCH 0/5] meta: Cleanup getstatusoutput usage Robert Yang
2018-08-23 8:07 ` [PATCH 1/5] lib/oe/gpg_sign.py: Clean up " Robert Yang
2018-08-23 8:07 ` [PATCH 2/5] lib/oe/patch.py: " Robert Yang
@ 2018-08-23 8:07 ` Robert Yang
2018-08-23 12:18 ` Bruce Ashfield
2018-08-23 8:07 ` [PATCH 4/5] psplash: " Robert Yang
2018-08-23 8:07 ` [PATCH 5/5] compress_doc.bbclass: " Robert Yang
4 siblings, 1 reply; 7+ messages in thread
From: Robert Yang @ 2018-08-23 8:07 UTC (permalink / raw)
To: openembedded-core
Replace usage of oe.utils.getstatusoutput() with direct subprocess calls.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/kernel-yocto.bbclass | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
index 077a1ab..8c5667d 100644
--- a/meta/classes/kernel-yocto.bbclass
+++ b/meta/classes/kernel-yocto.bbclass
@@ -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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] psplash: Clean up getstatusoutput usage
2018-08-23 8:07 [PATCH 0/5] meta: Cleanup getstatusoutput usage Robert Yang
` (2 preceding siblings ...)
2018-08-23 8:07 ` [PATCH 3/5] kernel-yocto.bbclass: " Robert Yang
@ 2018-08-23 8:07 ` Robert Yang
2018-08-23 8:07 ` [PATCH 5/5] compress_doc.bbclass: " Robert Yang
4 siblings, 0 replies; 7+ messages in thread
From: Robert Yang @ 2018-08-23 8:07 UTC (permalink / raw)
To: openembedded-core
Replace usage of oe.utils.getstatusoutput() with direct subprocess calls.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/recipes-core/psplash/psplash_git.bb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/meta/recipes-core/psplash/psplash_git.bb b/meta/recipes-core/psplash/psplash_git.bb
index aab2c03..3ad1ef4 100644
--- a/meta/recipes-core/psplash/psplash_git.bb
+++ b/meta/recipes-core/psplash/psplash_git.bb
@@ -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:
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] compress_doc.bbclass: Clean up getstatusoutput usage
2018-08-23 8:07 [PATCH 0/5] meta: Cleanup getstatusoutput usage Robert Yang
` (3 preceding siblings ...)
2018-08-23 8:07 ` [PATCH 4/5] psplash: " Robert Yang
@ 2018-08-23 8:07 ` Robert Yang
4 siblings, 0 replies; 7+ messages in thread
From: Robert Yang @ 2018-08-23 8:07 UTC (permalink / raw)
To: openembedded-core
Replace usage of oe.utils.getstatusoutput() with direct subprocess calls.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/compress_doc.bbclass | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/meta/classes/compress_doc.bbclass b/meta/classes/compress_doc.bbclass
index 069d534..45bb8ff 100644
--- a/meta/classes/compress_doc.bbclass
+++ b/meta/classes/compress_doc.bbclass
@@ -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
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/5] kernel-yocto.bbclass: Clean up getstatusoutput usage
2018-08-23 8:07 ` [PATCH 3/5] kernel-yocto.bbclass: " Robert Yang
@ 2018-08-23 12:18 ` Bruce Ashfield
0 siblings, 0 replies; 7+ messages in thread
From: Bruce Ashfield @ 2018-08-23 12:18 UTC (permalink / raw)
To: Robert Yang; +Cc: Patches and discussions about the oe-core layer
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
On Thu, Aug 23, 2018 at 4:07 AM, Robert Yang <liezhi.yang@windriver.com> wrote:
> Replace usage of oe.utils.getstatusoutput() with direct subprocess calls.
>
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
> meta/classes/kernel-yocto.bbclass | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
> index 077a1ab..8c5667d 100644
> --- a/meta/classes/kernel-yocto.bbclass
> +++ b/meta/classes/kernel-yocto.bbclass
> @@ -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
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
--
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-08-23 12:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23 8:07 [PATCH 0/5] meta: Cleanup getstatusoutput usage Robert Yang
2018-08-23 8:07 ` [PATCH 1/5] lib/oe/gpg_sign.py: Clean up " Robert Yang
2018-08-23 8:07 ` [PATCH 2/5] lib/oe/patch.py: " Robert Yang
2018-08-23 8:07 ` [PATCH 3/5] kernel-yocto.bbclass: " Robert Yang
2018-08-23 12:18 ` Bruce Ashfield
2018-08-23 8:07 ` [PATCH 4/5] psplash: " Robert Yang
2018-08-23 8:07 ` [PATCH 5/5] compress_doc.bbclass: " Robert Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox