Skip to contentSkip to conversation

package_ipk.bbclass: Add check for empty lines in DESCRIPTION

PATCH In review [email protected] 3 participants 4 messages Jan 24, 2017 – Jan 26, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 package_ipk.bbclass: Add check for empty lines in DESCRIPTION

From: Mariano Lopez <[email protected]>

opkg uses empty lines as separator for next package and if an ipk file was packaged with empty lines in DESCRIPTION opkg won't be able to handle such ipk file, this happens at execution time.

This commit will add a check for empty lines in DESCRIPTION when generating to ipk package to avoid this issue.

[YOCTO #10677]

---
 meta/classes/package_ipk.bbclass | 7 +++++++
 1 file changed, 7 insertions(+)
meta/classes/package_ipk.bbclass +7 -0
index a76b235..a8a4ddc 100644
@@ -32,6 +32,13 @@ python do_package_ipk () {
         bb.error("Variables incorrectly set, unable to package")
         return
 
+    # opkg won't allow empty lines in package's description at execution
+    # time, so is better to fail at build time instead when trying to install.
+    description = d.getVar('DESCRIPTION').encode('UTF-8', 'ignore')
+    description = description.decode('unicode_escape')
+    if ([line for line in description.splitlines() if not line.strip()]):
+        bb.fatal("opkg won't allow empty lines in DESCRIPTION")
+
     packages = d.getVar('PACKAGES')
     if not packages or packages == '':
         bb.debug(1, "No packages; nothing to do")
Signature · 1 line
2.6.6
#2 lore raw
Quoted 6 lines · On Tue, Jan 24, 2017 at 1:37 AM, <[email protected]> wrote:

From: Mariano Lopez <[email protected]>

opkg uses empty lines as separator for next package and if an ipk file was packaged with empty lines in DESCRIPTION opkg won't be able to handle such ipk file, this happens at execution time.

Quoted 7 lines

This commit will add a check for empty lines in DESCRIPTION when generating to ipk package to avoid this issue.

[YOCTO #10677]

Could it handle a line with just a space, or a period? Could you not replace the lines with that instead, rather than aborting?

Signature · 4 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
#3 lore raw
Quoted 12 lines · Christopher Larson
Quoted 9 lines · On Tue, Jan 24, 2017 at 1:37 AM, <[email protected]> wrote:

From: Mariano Lopez <[email protected]>

opkg uses empty lines as separator for next package and if an ipk file was packaged with empty lines in DESCRIPTION opkg won't be able to handle such ipk file, this happens at execution time.

This commit will add a check for empty lines in DESCRIPTION when generating to ipk package to avoid this issue.

Quoted 6 lines
Quoted 4 lines

[YOCTO #10677]

Could it handle a line with just a space, or a period? Could you not replace the lines with that instead, rather than aborting?

FWIW package_deb uses ".".

Also, please use bb.fatal() calls with caution, I just removed several from that class. In this case its perhaps ok but often the correct thing to do is raise an exception of some kind. This means bitbake will generate a usable traceback rather than simply printing the fatal message. In this case the message is probably fine but there were several cases where a traceback was a much better idea as the fatal message wasn't enough to debug with.

Cheers,

Richard

#4 lore raw
Quoted 12 lines · Richard Purdie
Quoted 11 lines · Christopher Larson
Quoted 9 lines · On Tue, Jan 24, 2017 at 1:37 AM, <[email protected]> wrote:

From: Mariano Lopez <[email protected]>

opkg uses empty lines as separator for next package and if an ipk file was packaged with empty lines in DESCRIPTION opkg won't be able to handle such ipk file, this happens at execution time.

This commit will add a check for empty lines in DESCRIPTION when generating to ipk package to avoid this issue.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

[YOCTO #10677]

Could it handle a line with just a space, or a period? Could you not replace the lines with that instead, rather than aborting?

FWIW package_deb uses ".".

Also opkg will strip() the lines, so an empty space is not a option here.

Quoted 8 lines

Also, please use bb.fatal() calls with caution, I just removed several from that class. In this case its perhaps ok but often the correct thing to do is raise an exception of some kind. This means bitbake will generate a usable traceback rather than simply printing the fatal message. In this case the message is probably fine but there were several cases where a traceback was a much better idea as the fatal message wasn't enough to debug with.

Fair enough, I will consider this advice when using bb.fatal()

Regards,
Mariano