[oe-commits] [openembedded-core] 05/11: lib/oe/utils: add eol to format_pkg_list()

git at git.openembedded.org git at git.openembedded.org
Wed Oct 10 22:31:28 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 80b00fe9c4922d2d2aa9d703ec6e7eab02f336df
Author: grygorii tertychnyi via Openembedded-core <openembedded-core at lists.openembedded.org>
AuthorDate: Wed Oct 10 19:26:24 2018 +0300

    lib/oe/utils: add eol to format_pkg_list()
    
    Append '\n' to the non-empty formatted string before return. If you
    write it to the (manifest) file, it will ensure file ends with a newline.
    
    Many GNU utilities have problems processing the last line of a file
    if it is not '\n' terminated. E.g. if the last line is not terminated
    by a newline character, then "read" will read it but return false,
    leaving the broken partial line in the read variable(s).
    It can also break or adversely affect some text processing tools,
    that operate on the file.
    
    Signed-off-by: grygorii tertychnyi <gtertych at cisco.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/rootfs-postcommands.bbclass | 1 -
 meta/lib/oe/utils.py                     | 8 +++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index e816824..bde58ad 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -253,7 +253,6 @@ python write_image_manifest () {
     pkgs = image_list_installed_packages(d)
     with open(manifest_name, 'w+') as image_manifest:
         image_manifest.write(format_pkg_list(pkgs, "ver"))
-        image_manifest.write("\n")
 
     if os.path.exists(manifest_name):
         manifest_link = deploy_dir + "/" + link_name + ".manifest"
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 93b0763..d05f517 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -347,7 +347,13 @@ def format_pkg_list(pkg_dict, ret_format=None):
         for pkg in sorted(pkg_dict):
             output.append(pkg)
 
-    return '\n'.join(output)
+    output_str = '\n'.join(output)
+
+    if output_str:
+        # make sure last line is newline terminated
+        output_str += '\n'
+
+    return output_str
 
 def host_gcc_version(d, taskcontextonly=False):
     import re, subprocess

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list