Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Julien Stephan <jstephan@baylibre.com>
To: openembedded-core@lists.openembedded.org
Cc: Julien Stephan <jstephan@baylibre.com>
Subject: [PATCH 3/7] recipetool: create: add trailing newlines
Date: Fri, 17 Nov 2023 12:12:14 +0100	[thread overview]
Message-ID: <20231117111218.3344066-4-jstephan@baylibre.com> (raw)
In-Reply-To: <20231117111218.3344066-1-jstephan@baylibre.com>

create_recipe() function relies on oe.recipeutils.patch_recipe_lines()
which relies on bb.utils.edit_metadata(). edit_metada expect lines to
have trailing newlines, so add it to each line before calling
patch_recipe_lines, otherwise edit_metadata will not be able to squash
blank line if there are two consecutive blanks after a removal

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
 scripts/lib/recipetool/create.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 293198d1c88..f5d541eb6c1 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -873,8 +873,10 @@ def create_recipe(args):
         outlines.append('')
     outlines.extend(lines_after)
 
+    outlines = [ line.rstrip('\n') +"\n" for line in outlines]
+
     if extravalues:
-        _, outlines = oe.recipeutils.patch_recipe_lines(outlines, extravalues, trailing_newline=False)
+        _, outlines = oe.recipeutils.patch_recipe_lines(outlines, extravalues, trailing_newline=True)
 
     if args.extract_to:
         scriptutils.git_convert_standalone_clone(srctree)
@@ -890,7 +892,7 @@ def create_recipe(args):
         log_info_cond('Source extracted to %s' % args.extract_to, args.devtool)
 
     if outfile == '-':
-        sys.stdout.write('\n'.join(outlines) + '\n')
+        sys.stdout.write(''.join(outlines) + '\n')
     else:
         with open(outfile, 'w') as f:
             lastline = None
@@ -898,7 +900,7 @@ def create_recipe(args):
                 if not lastline and not line:
                     # Skip extra blank lines
                     continue
-                f.write('%s\n' % line)
+                f.write('%s' % line)
                 lastline = line
         log_info_cond('Recipe %s has been created; further editing may be required to make it fully functional' % outfile, args.devtool)
         tinfoil.modified_files()
-- 
2.42.0



  parent reply	other threads:[~2023-11-17 11:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 11:12 [PATCH 0/7] Devtool/Recipetool: adding pypi support Julien Stephan
2023-11-17 11:12 ` [PATCH 1/7] bitbake: utils: remove spaces on empty lines Julien Stephan
2023-11-17 11:12 ` [PATCH 2/7] recipetool: create_buildsys_python.py: initialize metadata Julien Stephan
2023-11-17 11:12 ` Julien Stephan [this message]
2023-11-17 11:12 ` [PATCH 4/7] recipetool: create: add new optional process_url callback for plugins Julien Stephan
2023-11-17 11:12 ` [PATCH 5/7] recipetool: create_buildsys_python: add pypi support Julien Stephan
2023-11-17 11:12 ` [PATCH 6/7] oeqa/selftest/recipetool: remove spaces on empty lines Julien Stephan
2023-11-17 11:12 ` [PATCH 7/7] oeqa/selftest/recipetool/devtool: add test for pypi class Julien Stephan
2023-11-18 10:10 ` [OE-core] [PATCH 0/7] Devtool/Recipetool: adding pypi support Alexandre Belloni
     [not found] ` <1798AFE6117EC794.26894@lists.openembedded.org>
2023-11-18 13:48   ` Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231117111218.3344066-4-jstephan@baylibre.com \
    --to=jstephan@baylibre.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox