Patchwork [2/3] package_ipk.bbclass: make DESCRIPTION support newline

login
register
mail settings
Submitter Robert Yang
Date July 8, 2013, 3:17 a.m.
Message ID <72802281f0ec44b670c0df29d5dddae4150f5673.1373253036.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/53261/
State Accepted
Commit 33cd81e18b797d4257e02622ac5ca3eaf886c6e2
Headers show

Comments

Robert Yang - July 8, 2013, 3:17 a.m.
The recipe's DESCRIPTION is wrapped automatically by textwrap, make it
support newline ("\n") to let the user can wrap it manually, e.g.:

DESCRIPTION = "Foo1\nFoo2"

In the past, it would be:
Foo1\nFoo2

Now:
Foo1
Foo2

[YOCTO #4348]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/classes/package_ipk.bbclass |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Patch

diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 55628e4..3305879 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -304,10 +304,19 @@  python do_package_ipk () {
                 # Special behavior for description...
                 if 'DESCRIPTION' in fs:
                     summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "."
+                    ctrlfile.write('Description: %s\n' % summary)
                     description = localdata.getVar('DESCRIPTION', True) or "."
                     description = textwrap.dedent(description).strip()
-                    ctrlfile.write('Description: %s\n' % summary)
-                    ctrlfile.write('%s\n' % textwrap.fill(description, width=74, initial_indent=' ', subsequent_indent=' '))
+                    if '\\n' in description:
+                        # Manually indent
+                        for t in description.split('\\n'):
+                            # We don't limit the width when manually indent, but we do
+                            # need the textwrap.fill() to set the initial_indent and
+                            # subsequent_indent, so set a large width
+                            ctrlfile.write('%s\n' % textwrap.fill(t.strip(), width=100000, initial_indent=' ', subsequent_indent=' '))
+                    else:
+                        # Auto indent
+                        ctrlfile.write('%s\n' % textwrap.fill(description, width=74, initial_indent=' ', subsequent_indent=' '))
                 else:
                     ctrlfile.write(c % tuple(pullData(fs, localdata)))
         except KeyError: