make DESCRIPTION support newline
v2 cover make DESCRIPTION support newline
Changes of V2:
* Do not auto wrap when there is "\n" in the DESCRIPTION, let the user do the manual wrap.
// Robert
The following changes since commit dc86293f0444384e8ae5131fdd10b6cb077164b0:
bitbake: HOB:Proper handle of SIGINT (2013-07-05 15:52:48 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib robert/newline
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=robert/newline
Robert Yang (3):
package_rpm.bbclass: make DESCRIPTION support newline package_ipk.bbclass: make DESCRIPTION support newline package_deb.bbclass: make DESCRIPTION support newline
meta/classes/package_deb.bbclass | 14 ++++++++++++-- meta/classes/package_ipk.bbclass | 13 +++++++++++-- meta/classes/package_rpm.bbclass | 20 +++++++++++++++----- 3 files changed, 38 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v2 1/3 package_rpm.bbclass: make DESCRIPTION support newline
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]
--- meta/classes/package_rpm.bbclass | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
meta/classes/package_rpm.bbclass +15 -5
@@ -534,7 +534,6 @@ def write_rpm_perfiledata(srcname, d): python write_specfile () { - import textwrap import oe.packagedata # append information for logs and patches to %prep
@@ -668,6 +667,19 @@ python write_specfile () { deps.append(depends) return " ".join(deps) + def append_description(spec_preamble, text): + """ + Add the description to the spec file. + """ + import textwrap + dedent_text = textwrap.dedent(text).strip() + # Bitbake saves "\n" as "\\n" + if '\\n' in dedent_text: + for t in dedent_text.split('\\n'): + spec_preamble.append(t.strip()) + else: + spec_preamble.append('%s' % textwrap.fill(dedent_text, width=75)) + packages = d.getVar('PACKAGES', True) if not packages or packages == '': bb.debug(1, "No packages; nothing to do")
@@ -868,8 +880,7 @@ python write_specfile () { spec_preamble_bottom.append('') spec_preamble_bottom.append('%%description -n %s' % splitname) - dedent_text = textwrap.dedent(splitdescription).strip() - spec_preamble_bottom.append('%s' % textwrap.fill(dedent_text, width=75)) + append_description(spec_preamble_bottom, splitdescription) spec_preamble_bottom.append('')
@@ -975,8 +986,7 @@ python write_specfile () { spec_preamble_top.append('') spec_preamble_top.append('%description') - dedent_text = textwrap.dedent(srcdescription).strip() - spec_preamble_top.append('%s' % textwrap.fill(dedent_text, width=75)) + append_description(spec_preamble_top, srcdescription) spec_preamble_top.append('')
Signature · 1 line
1.7.10.4
PATCH v2 2/3 package_ipk.bbclass: make DESCRIPTION support newline
In reply to Robert YangThe 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]
--- meta/classes/package_ipk.bbclass | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
meta/classes/package_ipk.bbclass +11 -2
@@ -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:
Signature · 1 line
1.7.10.4
PATCH v2 3/3 package_deb.bbclass: make DESCRIPTION support newline
In reply to Robert YangThe 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]
--- meta/classes/package_deb.bbclass | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
meta/classes/package_deb.bbclass +12 -2
@@ -279,10 +279,20 @@ python do_package_deb () { # Special behavior for description... if 'DESCRIPTION' in fs: summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "." + ctrlfile.write('Description: %s\n' % unicode(summary)) description = localdata.getVar('DESCRIPTION', True) or "." description = textwrap.dedent(description).strip() - ctrlfile.write('Description: %s\n' % unicode(summary)) - ctrlfile.write('%s\n' % unicode(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' % unicode(textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '))) + else: + # Auto indent + ctrlfile.write('%s\n' % unicode(textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '))) + else: ctrlfile.write(unicode(c % tuple(pullData(fs, localdata)))) except KeyError:
Signature · 1 line
1.7.10.4