Bug 7427 - Image manifest file lacking newline char in last line
Summary: Image manifest file lacking newline char in last line
Status: RESOLVED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: 2.1 M2
Assignee: Mariano Lopez
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-03-09 09:38 UTC by Pau Espin Pedrol
Modified: 2016-01-29 17:39 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Patch which fixes the issue for me (847 bytes, patch)
2015-03-09 09:38 UTC, Pau Espin Pedrol
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pau Espin Pedrol 2015-03-09 09:38:31 UTC
Created attachment 2438 [details]
Patch which fixes the issue for me

I was having problems to generate automatically some information from the manifest file because a package was missing, until I discovered that it was actually the last package in the list and I noticed that that last line in that file doesn't have a newline character, which in my opinion is the usual case in most text files.

So I open this bug report in order to get that fixed, and I propose a patch I did which solves the issue for me at least. 

I am using deb packaging system, but I guess similar patches ar needed in the same file for other packaging system too.
Comment 1 Pau Espin Pedrol 2015-03-09 14:42:43 UTC
Forget about the patch, I found out it breaks other code which gets the package list with "arch" parameter.

Easiest solution is to implement it in image.bbclass by writing an newline at the end:

python write_image_manifest () {
    from oe.rootfs import image_list_installed_packages
    with open(d.getVar('IMAGE_MANIFEST', True), 'w+') as image_manifest:
        image_manifest.write(image_list_installed_packages(d, 'ver'))
        image_manifest.write("\n")
}


However, I feel the way the list is generated in image_list_installed_packages and how the code that uses it is kind of bad... imho or you use same output in all lines (meaning last one has also a newline char), or you convert those to python lists already inside image_list_installed_packages, but I wouldn't pass the current format and then go splitting in all the places this function is used.

What do you think about that?
Comment 2 Richard Purdie 2015-03-24 10:56:01 UTC
For what its worth I agree that the way the data is currently being passed around is horrible, we should use some better data structure.

At this point I'll merge a patch as you propose adding the newline character and then in 1.9 we should consider rewriting the structure of the code as an enhancement/cleanup.
Comment 3 Richard Purdie 2015-12-14 15:59:05 UTC
To be clear about the problems here, the format parameter to image_list_installed_packages() is ugly and we shouldn't be passing around several different formats of this data. A better solution would be to have one return data format which encompasses all the types and doesn't need string splitting in the callers.

Having a function called "list", a python keyword is also horrible.
Comment 4 Mariano Lopez 2015-12-14 20:41:08 UTC
I was checking where the image_list_installed_packages() is used and it seems it is only in OE-Core. Regarding the output it is very different based on the format, so a one size fits all solution won't work. What can be done is to return a list or dictionary to the callers and they can format the output as desired. Currently there are 5 defined formats and here is the sample output:

arch:

adwaita-icon-theme all
alsa-conf core2-64
alsa-conf-base core2-64
alsa-plugins-pulseaudio-conf core2-64

deps:

adwaita-icon-theme|hicolor-icon-theme
adwaita-icon-theme|hicolor-icon-theme
adwaita-icon-theme|hicolor-icon-theme
adwaita-icon-theme|busybox
adwaita-icon-theme|busybox
alsa-plugins-pulseaudio-conf|libasound-module-conf-pulse
alsa-plugins-pulseaudio-conf|libasound-module-ctl-pulse
alsa-plugins-pulseaudio-conf|libasound-module-pcm-pulse

file:

adwaita-icon-theme /path/to/tmp/deploy/rpm/all/adwaita-icon-theme-3.18.0-r0.all.rpm all
alsa-conf /path/to/tmp/deploy/rpm/core2_64/alsa-conf-1.0.29-r0.core2_64.rpm core2-64alsa-conf-base /home/mlopezva/repo/poky/bug7427/tmp/deploy/rpm/core2_64/alsa-conf-base-1.0.29-r0.core2_64.rpm core2-64
alsa-plugins-pulseaudio-conf /path/to/tmp/deploy/rpm/core2_64/alsa-plugins-pulseaudio-conf-1.0.29-r0.core2_64.rpm core2-64

ver:

adwaita-icon-theme all 3.18.0
alsa-conf core2-64 1.0.29
alsa-conf-base core2-64 1.0.29

default:

adwaita-icon-theme
alsa-conf
alsa-conf-base
alsa-plugins-pulseaudio-conf
Comment 5 Mariano Lopez 2016-01-08 15:11:38 UTC
Sent patch for review:

http://lists.openembedded.org/pipermail/openembedded-core/2016-January/115006.html