public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: "cygwin-apps@cygwin.com" <cygwin-apps@cygwin.com>
Subject: Re: [PATCH 1/2 v2] Filter newlines from BUILD_REQUIRES
Date: Sat, 3 Dec 2022 18:07:50 +0000	[thread overview]
Message-ID: <a25e7053-08e2-deea-2bd0-db54c470c48b@dronecode.org.uk> (raw)
In-Reply-To: <20221203161909.2337873-1-corinna-cygwin@cygwin.com>

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

On 03/12/2022 16:19, Corinna Vinschen via Cygwin-apps wrote:
> From: Corinna Vinschen <corinna-fFDxGeQsSAIb1SvskN2V4Q@public.gmane.org>
> 
> BUILD_REQUIRES is added verbatim to the build-depends: line in
> the *-src.hint file.  If the cygport file defines BUILD_REQUIRES
> with newlines, e. g.
> 
>    BUILD_REQUIRES="
>      a
>      b
>    "
> 
> The -src.hint file is broken.  Avoid this by filtering out any
> newline's from BUILD_REQUIRES before using it in the subsequent
> expression building the -src.hint file.

Thanks.

Attached is a patch I wrote taking a slightly more general approach.

[-- Attachment #2: 0001-Canonicalize-whitespace-appropriately-in-.hint-file-.patch --]
[-- Type: text/plain, Size: 3207 bytes --]

From e9bb659b591e6983266153766a28cf737375c706 Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Tue, 29 Nov 2022 23:02:08 +0000
Subject: [PATCH cygport] Canonicalize whitespace appropriately in .hint file
 values

People like to insert extra whitespace (including newlines) into the
variables which control these, for clarity and formatting in the cygport
file. This is a resonable thing to do.

Canonicalize any whitespace in the values of .hint file keys which are
single-line, space-separated lists, to avoid those newlines leaking
through into the .hint file, making the value multi-line, and hence
invalid.

Update tests where the expected hints currently contain excess
whitespace (usually at the end of the line) appropriately.
---
 lib/pkg_pkg.cygpart | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/pkg_pkg.cygpart b/lib/pkg_pkg.cygpart
index 82112e1..6f02f7e 100644
--- a/lib/pkg_pkg.cygpart
+++ b/lib/pkg_pkg.cygpart
@@ -459,6 +459,10 @@ __gpg_sign() {
 	gpg --detach-sign ${1};
 }
 
+__squeeze_whitespace() {
+	echo -n "$*" | tr -s '[:space:]' ' '
+}
+
 __pkg_srcpkg() {
 	local src;
 	local pkg_tag=${1};
@@ -545,8 +549,8 @@ __pkg_srcpkg() {
 			-a -n "${!pkg_summary_var:-${SUMMARY}}${!pkg_description_var:-${DESCRIPTION}}" ]
 		then
 			cat > ${distdir}/${PN}/${PN}-${PVR}-src.hint <<-_EOF
-category: ${!pkg_category_var:-${CATEGORY}}
-build-depends: cygport ${BUILD_REQUIRES}
+category: $(__squeeze_whitespace ${!pkg_category_var:-${CATEGORY}})
+build-depends: cygport $(__squeeze_whitespace ${BUILD_REQUIRES})
 sdesc: "${!pkg_summary_var:-${SUMMARY}}"
 ldesc: "${!pkg_description_var:-${DESCRIPTION:-${!pkg_summary_var:-${SUMMARY}}}}"
 skip:
@@ -820,29 +824,29 @@ __pkg_dist() {
 			fi
 
 			cat > ${distdir}/${PN}/${distsubdir}/${pkg_name[${n}]}-${PVR}.hint <<-_EOF
-category: ${!pkg_category_var:-${CATEGORY}}
-requires: ${pkg_bin_requires} ${!pkg_requires_var}
+category: $(__squeeze_whitespace ${!pkg_category_var:-${CATEGORY}})
+requires: $(__squeeze_whitespace ${pkg_bin_requires} ${!pkg_requires_var})
 sdesc: "${!pkg_summary_var:-${SUMMARY}}"
 ldesc: "${!pkg_description_var:-${DESCRIPTION:-${!pkg_summary_var:-${SUMMARY}}}}"
 _EOF
 			if [ -n "${!pkg_obsoletes_var}" ]
 			then
 				cat >> ${distdir}/${PN}/${distsubdir}/${pkg_name[${n}]}-${PVR}.hint <<-_EOF
-obsoletes: ${!pkg_obsoletes_var}
+obsoletes: $(__squeeze_whitespace ${!pkg_obsoletes_var})
 _EOF
 			fi
 
 			if [ -n "${!pkg_provides_var}" ]
 			then
 				cat >> ${distdir}/${PN}/${distsubdir}/${pkg_name[${n}]}-${PVR}.hint <<-_EOF
-provides: ${!pkg_provides_var}
+provides: $(__squeeze_whitespace ${!pkg_provides_var})
 _EOF
 			fi
 
 			if [ -n "${!pkg_conflicts_var}" ]
 			then
 				cat >> ${distdir}/${PN}/${distsubdir}/${pkg_name[${n}]}-${PVR}.hint <<-_EOF
-conflicts: ${!pkg_conflicts_var}
+conflicts: $(__squeeze_whitespace ${!pkg_conflicts_var})
 _EOF
 			fi
 
@@ -893,7 +897,7 @@ _EOF
 			if [ -n "${!dbg_obsoletes_var}" ]
 			then
 				cat >> ${distdir}/${PN}/${PN}-debuginfo/${PN}-debuginfo-${PVR}.hint <<-_EOF
-obsoletes: ${!dbg_obsoletes_var}
+obsoletes: $(__squeeze_whitespace ${!dbg_obsoletes_var})
 _EOF
 			fi
 		fi
-- 
2.38.1


  reply	other threads:[~2022-12-03 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-03 16:19 Corinna Vinschen
2022-12-03 18:07 ` Jon Turney [this message]
2022-12-03 19:39   ` Corinna Vinschen
2022-12-07  7:59   ` Brian Inglis

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=a25e7053-08e2-deea-2bd0-db54c470c48b@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-apps@cygwin.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).