All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3 V2] make DESCRIPTION support newline
@ 2013-07-08  3:17 Robert Yang
  2013-07-08  3:17 ` [PATCH 1/3] package_rpm.bbclass: " Robert Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Robert Yang @ 2013-07-08  3:17 UTC (permalink / raw)
  To: openembedded-core

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(-)

-- 
1.7.10.4



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] package_rpm.bbclass: make DESCRIPTION support newline
  2013-07-08  3:17 [PATCH 0/3 V2] make DESCRIPTION support newline Robert Yang
@ 2013-07-08  3:17 ` Robert Yang
  2013-07-08  3:17 ` [PATCH 2/3] package_ipk.bbclass: " Robert Yang
  2013-07-08  3:17 ` [PATCH 3/3] package_deb.bbclass: " Robert Yang
  2 siblings, 0 replies; 4+ messages in thread
From: Robert Yang @ 2013-07-08  3:17 UTC (permalink / raw)
  To: openembedded-core

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_rpm.bbclass |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index c654cdb..fa928ce 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -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('')
 
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] package_ipk.bbclass: make DESCRIPTION support newline
  2013-07-08  3:17 [PATCH 0/3 V2] make DESCRIPTION support newline Robert Yang
  2013-07-08  3:17 ` [PATCH 1/3] package_rpm.bbclass: " Robert Yang
@ 2013-07-08  3:17 ` Robert Yang
  2013-07-08  3:17 ` [PATCH 3/3] package_deb.bbclass: " Robert Yang
  2 siblings, 0 replies; 4+ messages in thread
From: Robert Yang @ 2013-07-08  3:17 UTC (permalink / raw)
  To: openembedded-core

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(-)

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:
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] package_deb.bbclass: make DESCRIPTION support newline
  2013-07-08  3:17 [PATCH 0/3 V2] make DESCRIPTION support newline Robert Yang
  2013-07-08  3:17 ` [PATCH 1/3] package_rpm.bbclass: " Robert Yang
  2013-07-08  3:17 ` [PATCH 2/3] package_ipk.bbclass: " Robert Yang
@ 2013-07-08  3:17 ` Robert Yang
  2 siblings, 0 replies; 4+ messages in thread
From: Robert Yang @ 2013-07-08  3:17 UTC (permalink / raw)
  To: openembedded-core

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_deb.bbclass |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 949432e..663f646 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -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:
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-08  3:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-08  3:17 [PATCH 0/3 V2] make DESCRIPTION support newline Robert Yang
2013-07-08  3:17 ` [PATCH 1/3] package_rpm.bbclass: " Robert Yang
2013-07-08  3:17 ` [PATCH 2/3] package_ipk.bbclass: " Robert Yang
2013-07-08  3:17 ` [PATCH 3/3] package_deb.bbclass: " Robert Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.