]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
lib/oe/utils: add eol to format_pkg_list()
authorgrygorii tertychnyi via Openembedded-core <openembedded-core@lists.openembedded.org>
Wed, 10 Oct 2018 16:26:24 +0000 (19:26 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 11 Oct 2018 09:36:42 +0000 (10:36 +0100)
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@cisco.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/rootfs-postcommands.bbclass
meta/lib/oe/utils.py

index e816824f281d723216b54270fdcbf0faf4228b6f..bde58ad6cd3670986d616201095708b32fd22f63 100644 (file)
@@ -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"
index 93b0763b0a9ad9c3b4b0f4358e7281bd6060ed89..d05f517a70264d9ddc67274412c092266663a4ea 100644 (file)
@@ -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