lib/oe/utils: add eol to format_pkg_list()
PATCH v3 1/1 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.
---
Changes in v3:
o write_image_manifest(): remove extra '\n'
PASS bitbake buildtools-tarball
PASS bitbake core-image-minimal
PASS bitbake core-image-sato -c do_populate_sdk_ext
PASS oe-selftest --run-tests manifest.VerifyManifest.test_image_manifest_entries
meta/classes/rootfs-postcommands.bbclass | 1 - meta/lib/oe/utils.py | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-)
meta/classes/rootfs-postcommands.bbclass +0 -1
@@ -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"
meta/lib/oe/utils.py +7 -1
@@ -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
Signature · 1 line
2.19.0
Grygorii,
Quoted 9 lines · grygorii tertychnyi via Openembedded-core
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.
is this needed for the cve patches?
- armin
Quoted 46 lines
Signed-off-by grygorii tertychnyi <[email protected]>---
Changes in v3:
owrite_image_manifest(): remove extra '\n'PASS bitbake buildtools-tarball
PASS bitbake core-image-minimal
PASS bitbake core-image-sato -cdo_populate_sdk_ext
PASS oe-selftest --run-tests manifest.VerifyManifest.test_image_manifest_entriesmeta/classes/rootfs-postcommands.bbclass | 1 - meta/lib/oe/utils.py | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-)meta/classes/rootfs-postcommands.bbclass +0
-1@@ -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"meta/lib/oe/utils.py +7
-1@@ -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
Quoted 7 lines · akuster808 writes:
Grygorii,
Quoted 3 lines · grygorii tertychnyi via Openembedded-core
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.
Quoted 8 lines
Quoted 6 lines
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.
is this needed for the cve patches?
No
Quoted 48 lines
- armin
Quoted 46 lines
Signed-off-by grygorii tertychnyi <[email protected]>---
Changes in v3:
owrite_image_manifest(): remove extra '\n'PASS bitbake buildtools-tarball
PASS bitbake core-image-minimal
PASS bitbake core-image-sato -cdo_populate_sdk_ext
PASS oe-selftest --run-tests manifest.VerifyManifest.test_image_manifest_entriesmeta/classes/rootfs-postcommands.bbclass | 1 - meta/lib/oe/utils.py | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-)meta/classes/rootfs-postcommands.bbclass +0
-1@@ -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"meta/lib/oe/utils.py +7
-1@@ -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