Re: [PATCH 1/2 v2] Filter newlines from BUILD_REQUIRES

2022-12-03 Thread Corinna Vinschen via Cygwin-apps
On Dec  3 18:07, Jon Turney via Cygwin-apps wrote:
> On 03/12/2022 16:19, Corinna Vinschen via Cygwin-apps wrote:
> > From: Corinna Vinschen 
> > 
> > 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.

Yeah, that looks much better to me.


Thanks,
Corinna


Re: [PATCH 2/2] Default to x86_64 build on non-Cygwin hosts

2022-12-03 Thread Jon Turney via Cygwin-apps

On 03/12/2022 16:14, Corinna Vinschen via Cygwin-apps wrote:

From: Corinna Vinschen 

Given x86 has been deprecated, we only have a single target for
the time being.  Default to this target for now, basically to
safe my lazy ass when building on Linux.

Thanks, applied.



Re: [PATCH 1/2 v2] Filter newlines from BUILD_REQUIRES

2022-12-03 Thread Jon Turney via Cygwin-apps

On 03/12/2022 16:19, Corinna Vinschen via Cygwin-apps wrote:

From: Corinna Vinschen 

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.
From e9bb659b591e6983266153766a28cf737375c706 Mon Sep 17 00:00:00 2001
From: Jon Turney 
Date: Tue, 29 Nov 2022 23:02:08 +
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



[PATCH 1/2 v2] Filter newlines from BUILD_REQUIRES

2022-12-03 Thread Corinna Vinschen via Cygwin-apps
From: Corinna Vinschen 

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.

Signed-off-by: Corinna Vinschen 
---
 lib/pkg_pkg.cygpart | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/pkg_pkg.cygpart b/lib/pkg_pkg.cygpart
index 82112e1cfc79..eb06a08dd562 100644
--- a/lib/pkg_pkg.cygpart
+++ b/lib/pkg_pkg.cygpart
@@ -544,6 +544,10 @@ __pkg_srcpkg() {
elif [ -n "${!pkg_category_var:-${CATEGORY}}" \
-a -n 
"${!pkg_summary_var:-${SUMMARY}}${!pkg_description_var:-${DESCRIPTION}}" ]
then
+   # BUILD_REQUIRES is added to the build-depends: line
+   # in the hint file written below.  Convert LFs to
+   # spaces to make sure it's actually a single line.
+   BUILD_REQUIRES=$(echo -n "$BUILD_REQUIRES" | tr '\n' ' 
')
cat > ${distdir}/${PN}/${PN}-${PVR}-src.hint <<-_EOF
 category: ${!pkg_category_var:-${CATEGORY}}
 build-depends: cygport ${BUILD_REQUIRES}
-- 
2.38.1



[PATCH 2/2] Default to x86_64 build on non-Cygwin hosts

2022-12-03 Thread Corinna Vinschen via Cygwin-apps
From: Corinna Vinschen 

Given x86 has been deprecated, we only have a single target for
the time being.  Default to this target for now, basically to
safe my lazy ass when building on Linux.

Signed-off-by: Corinna Vinschen 
---
 NEWS  | 3 +++
 lib/compilers.cygpart | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 976237d88d54..e3dc83c3f5a4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+0.35.5:
+   * Default to x86_64-pc-cygwin target on Linux.
+
 0.35.4:
* Replace 'egrep' with 'grep -E' throughout
* xorg: Default LICENSE to 'MIT'
diff --git a/lib/compilers.cygpart b/lib/compilers.cygpart
index f9b8c69532e2..35e6fe2886f9 100644
--- a/lib/compilers.cygpart
+++ b/lib/compilers.cygpart
@@ -213,7 +213,7 @@ case ${CBUILD} in
 # https://sourceware.org/legacy-ml/cygwin-developers/2013-02/msg00132.html
 x86_64-unknown-cygwin)  CBUILD="x86_64-pc-cygwin" ;&
 *-cygwin)  CHOST="${_host_arch:-${CBUILD%%-*}}-pc-cygwin" ;;
-*) defined _host_arch || error "Either --32 or --64 flags MUST be 
passed to cygport"
+*) defined _host_arch || _host_arch="x86_64"
CHOST="${_host_arch}-pc-cygwin" ;;
 esac
 unset _host_arch
-- 
2.38.1



[PATCH 1/2] Filter newlines from BUILD_REQUIRES

2022-12-03 Thread Corinna Vinschen via Cygwin-apps
From: Corinna Vinschen 

BUILD_REQUIRES is added verbatim to the build-depends: line in
the *-src.hint file.  If the cygport file defines BUILD_REQUIRES
with spaces, 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.

Signed-off-by: Corinna Vinschen 
---
 lib/pkg_pkg.cygpart | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/pkg_pkg.cygpart b/lib/pkg_pkg.cygpart
index 82112e1cfc79..eb06a08dd562 100644
--- a/lib/pkg_pkg.cygpart
+++ b/lib/pkg_pkg.cygpart
@@ -544,6 +544,10 @@ __pkg_srcpkg() {
elif [ -n "${!pkg_category_var:-${CATEGORY}}" \
-a -n 
"${!pkg_summary_var:-${SUMMARY}}${!pkg_description_var:-${DESCRIPTION}}" ]
then
+   # BUILD_REQUIRES is added to the build-depends: line
+   # in the hint file written below.  Convert LFs to
+   # spaces to make sure it's actually a single line.
+   BUILD_REQUIRES=$(echo -n "$BUILD_REQUIRES" | tr '\n' ' 
')
cat > ${distdir}/${PN}/${PN}-${PVR}-src.hint <<-_EOF
 category: ${!pkg_category_var:-${CATEGORY}}
 build-depends: cygport ${BUILD_REQUIRES}
-- 
2.38.1