* [PATCH] classes/package: Clean up getstatusoutput
@ 2018-08-20 2:43 Joshua Watt
2018-08-20 8:19 ` richard.purdie
2018-08-20 15:54 ` [PATCH v2] " Joshua Watt
0 siblings, 2 replies; 6+ messages in thread
From: Joshua Watt @ 2018-08-20 2:43 UTC (permalink / raw)
To: openembedded-core
Replaces usage of the deprecated oe.utils.getstatusoutput() with Python
subprocess calls.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
meta/classes/package.bbclass | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 4ce9de2f573..b05d2858281 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -380,6 +380,7 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
# sourcefile is also generated containing a list of debugsources
import stat
+ import subprocess
src = file[len(dvar):]
dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend
@@ -409,16 +410,18 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
bb.utils.mkdirhier(os.path.dirname(debugfile))
- cmd = "'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ cmd = (objcopy, '--only-keep-debug', file, debugfile)
+ try:
+ subprocess.check_output(cmd)
+ except subprocess.CalledProcessError as e:
+ bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (e.returncode, ' '.join(cmd), ":\n%s" % output.decode('utf-8') if e.output else ""))
# Set the debuglink to have the view of the file path on the target
- cmd = "'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ cmd = (objcopy, '--add-gnu-debuglink', debugfile, file)
+ try:
+ subprocess.check_output(cmd)
+ except subprocess.CalledProcessError as e:
+ bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (e.returncode, ' '.join(cmd), ":\n%s" % output.decode('utf-8') if e.output else ""))
if newmode:
os.chmod(file, origmode)
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] classes/package: Clean up getstatusoutput
2018-08-20 2:43 [PATCH] classes/package: Clean up getstatusoutput Joshua Watt
@ 2018-08-20 8:19 ` richard.purdie
2018-08-20 15:54 ` [PATCH v2] " Joshua Watt
1 sibling, 0 replies; 6+ messages in thread
From: richard.purdie @ 2018-08-20 8:19 UTC (permalink / raw)
To: Joshua Watt, openembedded-core
On Sun, 2018-08-19 at 21:43 -0500, Joshua Watt wrote:
> Replaces usage of the deprecated oe.utils.getstatusoutput() with Python
> subprocess calls.
>
> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
> ---
> meta/classes/package.bbclass | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index 4ce9de2f573..b05d2858281 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -380,6 +380,7 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
> # sourcefile is also generated containing a list of debugsources
>
> import stat
> + import subprocess
>
> src = file[len(dvar):]
> dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend
> @@ -409,16 +410,18 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
>
> bb.utils.mkdirhier(os.path.dirname(debugfile))
>
> - cmd = "'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile)
> - (retval, output) = oe.utils.getstatusoutput(cmd)
> - if retval:
> - bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
> + cmd = (objcopy, '--only-keep-debug', file, debugfile)
> + try:
> + subprocess.check_output(cmd)
> + except subprocess.CalledProcessError as e:
> + bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (e.returncode, ' '.join(cmd), ":\n%s" % output.decode('utf-8') if e.output else ""))
>
> # Set the debuglink to have the view of the file path on the target
> - cmd = "'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file)
> - (retval, output) = oe.utils.getstatusoutput(cmd)
> - if retval:
> - bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
> + cmd = (objcopy, '--add-gnu-debuglink', debugfile, file)
> + try:
> + subprocess.check_output(cmd)
> + except subprocess.CalledProcessError as e:
> + bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (e.returncode, ' '.join(cmd), ":\n%s" % output.decode('utf-8') if e.output else ""))
>
> if newmode:
> os.chmod(file, origmode)
I appreciate this is a direct replacement and functionally equivalent
but are these custom exceptions any real use? Its hard to actually get
them right and I suspect we may be better off without them using the
standard formatter?
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] classes/package: Clean up getstatusoutput
2018-08-20 2:43 [PATCH] classes/package: Clean up getstatusoutput Joshua Watt
2018-08-20 8:19 ` richard.purdie
@ 2018-08-20 15:54 ` Joshua Watt
2018-08-20 16:56 ` richard.purdie
2018-08-22 2:21 ` [PATCH v3] " Joshua Watt
1 sibling, 2 replies; 6+ messages in thread
From: Joshua Watt @ 2018-08-20 15:54 UTC (permalink / raw)
To: openembedded-core
Replaces usage of the deprecated oe.utils.getstatusoutput() with Python
subprocess calls.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
meta/classes/package.bbclass | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 4ce9de2f573..3976811d19f 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -380,6 +380,7 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
# sourcefile is also generated containing a list of debugsources
import stat
+ import subprocess
src = file[len(dvar):]
dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend
@@ -409,16 +410,10 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
bb.utils.mkdirhier(os.path.dirname(debugfile))
- cmd = "'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ subprocess.check_output([objcopy, '--only-keep-debug', file, debugfile])
# Set the debuglink to have the view of the file path on the target
- cmd = "'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ subprocess.check_output([objcopy, '--add-gnu-debuglink', debugfile, file])
if newmode:
os.chmod(file, origmode)
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] classes/package: Clean up getstatusoutput
2018-08-20 15:54 ` [PATCH v2] " Joshua Watt
@ 2018-08-20 16:56 ` richard.purdie
2018-08-22 2:21 ` [PATCH v3] " Joshua Watt
1 sibling, 0 replies; 6+ messages in thread
From: richard.purdie @ 2018-08-20 16:56 UTC (permalink / raw)
To: Joshua Watt, openembedded-core
On Mon, 2018-08-20 at 10:54 -0500, Joshua Watt wrote:
> Replaces usage of the deprecated oe.utils.getstatusoutput() with
> Python
> subprocess calls.
>
> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
> ---
> meta/classes/package.bbclass | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/meta/classes/package.bbclass
> b/meta/classes/package.bbclass
> index 4ce9de2f573..3976811d19f 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -380,6 +380,7 @@ def splitdebuginfo(file, dvar, debugdir,
> debuglibdir, debugappend, debugsrcdir,
> # sourcefile is also generated containing a list of debugsources
>
> import stat
> + import subprocess
>
> src = file[len(dvar):]
> dest = debuglibdir + os.path.dirname(src) + debugdir + "/" +
> os.path.basename(src) + debugappend
> @@ -409,16 +410,10 @@ def splitdebuginfo(file, dvar, debugdir,
> debuglibdir, debugappend, debugsrcdir,
>
> bb.utils.mkdirhier(os.path.dirname(debugfile))
>
> - cmd = "'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile)
> - (retval, output) = oe.utils.getstatusoutput(cmd)
> - if retval:
> - bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
> + subprocess.check_output([objcopy, '--only-keep-debug', file, debugfile])
Sorry, I just realised it needs a stderr=subprocess.STDOUT in there to
ensure the right things happen with logging...
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] classes/package: Clean up getstatusoutput
2018-08-20 15:54 ` [PATCH v2] " Joshua Watt
2018-08-20 16:56 ` richard.purdie
@ 2018-08-22 2:21 ` Joshua Watt
2018-08-22 2:28 ` [PATCH v4] " Joshua Watt
1 sibling, 1 reply; 6+ messages in thread
From: Joshua Watt @ 2018-08-22 2:21 UTC (permalink / raw)
To: openembedded-core
Replaces usage of the deprecated oe.utils.getstatusoutput() with Python
subprocess calls.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
meta/classes/package.bbclass | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 4ce9de2f573..3976811d19f 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -380,6 +380,7 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
# sourcefile is also generated containing a list of debugsources
import stat
+ import subprocess
src = file[len(dvar):]
dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend
@@ -409,16 +410,10 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
bb.utils.mkdirhier(os.path.dirname(debugfile))
- cmd = "'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ subprocess.check_output([objcopy, '--only-keep-debug', file, debugfile])
# Set the debuglink to have the view of the file path on the target
- cmd = "'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ subprocess.check_output([objcopy, '--add-gnu-debuglink', debugfile, file])
if newmode:
os.chmod(file, origmode)
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4] classes/package: Clean up getstatusoutput
2018-08-22 2:21 ` [PATCH v3] " Joshua Watt
@ 2018-08-22 2:28 ` Joshua Watt
0 siblings, 0 replies; 6+ messages in thread
From: Joshua Watt @ 2018-08-22 2:28 UTC (permalink / raw)
To: openembedded-core
Replaces usage of the deprecated oe.utils.getstatusoutput() with Python
subprocess calls.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
meta/classes/package.bbclass | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 4ce9de2f573..323ba051ae0 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -380,6 +380,7 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
# sourcefile is also generated containing a list of debugsources
import stat
+ import subprocess
src = file[len(dvar):]
dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend
@@ -409,16 +410,10 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir,
bb.utils.mkdirhier(os.path.dirname(debugfile))
- cmd = "'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ subprocess.check_output([objcopy, '--only-keep-debug', file, debugfile], stderr=subprocess.STDOUT)
# Set the debuglink to have the view of the file path on the target
- cmd = "'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file)
- (retval, output) = oe.utils.getstatusoutput(cmd)
- if retval:
- bb.fatal("objcopy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
+ subprocess.check_output([objcopy, '--add-gnu-debuglink', debugfile, file], stderr=subprocess.STDOUT)
if newmode:
os.chmod(file, origmode)
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-08-22 2:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-20 2:43 [PATCH] classes/package: Clean up getstatusoutput Joshua Watt
2018-08-20 8:19 ` richard.purdie
2018-08-20 15:54 ` [PATCH v2] " Joshua Watt
2018-08-20 16:56 ` richard.purdie
2018-08-22 2:21 ` [PATCH v3] " Joshua Watt
2018-08-22 2:28 ` [PATCH v4] " Joshua Watt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox