Github messages for voidlinux
 help / color / mirror / Atom feed
From: sgn <sgn@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] 99-pkglint-subpkgs: simplify and correct
Date: Thu, 10 Dec 2020 01:39:56 +0100	[thread overview]
Message-ID: <20201210003956.O4JFoYyMj_JKb-0TaXT9xpOEDr7Sf6vvc7n5IYin0fc@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-26950@inbox.vuxu.org>

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

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages 99-pkglint-subpkgs-fix
https://github.com/void-linux/void-packages/pull/26950

99-pkglint-subpkgs: simplify and correct
As discussing in [1], on template with "subpackages" as multilines will
report false positive on some packages will never be built.

There're multiple problems here:

- expanded "subpackages" will have an empty line if it has a newline
  inside template
- "sed" expression couldn't work with multilines "subpackages"

Let's not quote "$subpkgs" and "$subpackages" in "printf" to let the
shell do expansion and trim the empty lines for us. And rewrite the
"sed" expression to work with multilines "subpackages"

[1]: https://github.com/void-linux/void-packages/pull/26939#issuecomment-739098547

A patch file from https://github.com/void-linux/void-packages/pull/26950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-99-pkglint-subpkgs-fix-26950.patch --]
[-- Type: text/x-diff, Size: 2692 bytes --]

From f33a44f8a3ea572f746101b2ef5952cd9328bd31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sat, 5 Dec 2020 08:13:56 +0700
Subject: [PATCH] 99-pkglint-subpkgs: correct for multiline subpackages

As discussing in [1], on template with "subpackages" as multilines will
report false positive on some packages will never be built.

There're multiple problems here:

- expanded "subpackages" will have an empty line if it has a newline
  inside template
- "sed" expression couldn't work with multilines "subpackages"

Let's not quote "$subpkgs" and "$subpackages" in "printf" to let the
shell do expansion and trim the empty lines for us. And rewrite the
"sed" expression to work with multilines "subpackages"

[1]: https://github.com/void-linux/void-packages/pull/26939#issuecomment-739098547
---
 common/hooks/pre-pkg/99-pkglint-subpkgs.sh | 24 ++++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh
index add7fdd4a07..fd1fee6c445 100644
--- a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh
+++ b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh
@@ -18,21 +18,27 @@ hook() {
 
     subpkgs=$(get_subpkgs)
 
-    subpackages="${subpackages// /$'\n'}"
-
     # Sort the strings so they can be compare for equality
-    subpkgs="$(printf "%s\\n" "$subpkgs" | sort)"
-    subpackages="$(printf "%s\\n" "$subpackages" | sort)"
+    subpkgs="$(printf '%s\n' $subpkgs | sort)"
+    subpackages="$(printf '%s\n' $subpackages | sort)"
 
     if [ "$subpackages" = "$subpkgs" ]; then
         return 0
     fi
 
-    # XXX: Make the sed call work when subpackages has multiple lines
-    # this can be done with grep with perl regexp (-P) but chroot-grep
-    # is compiled without it
-    matches="$(sed -n 's/subpackages.*"\(.*\)"[^"]*$/\1/p' $XBPS_SRCPKGDIR/$pkgname/template \
-        | tr " " "\n" | sort)"
+    # sed supports comment but let's put them here
+    # 1: print everything between pairs of <""> in subpackages[+]?="..."
+    # 2: multiline subpackages="...\n..."
+    # 2.1: For any line in the middle, i.e. no <"> exists, print it
+    # 2.2: For the first line, print everything after <">
+    # 2.3: For last line, print everything before <">
+    matches="$(sed -n -e 's/subpackages.*"\(.*\)"[^"]*$/\1/p' \
+            -e '/subpackages[^"]*"[^"]*$/,/"/{
+                /"/!p
+                /subpackages/s/.*"//p
+                s/".*//p
+            }' $XBPS_SRCPKGDIR/$pkgname/template |
+        tr ' ' '\n' | sort)"
 
     for s in $subpkgs; do
         grep -q "^$s$" <<< "$matches" ||

  parent reply	other threads:[~2020-12-10  0:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-05  1:41 [PR PATCH] " sgn
2020-12-05  3:44 ` [PR PATCH] [Updated] " sgn
2020-12-07  0:03 ` [PR PATCH] [Closed]: " sgn
2020-12-07  9:03 ` [PR REVIEW] " Piraty
2020-12-07  9:03 ` Piraty
2020-12-07 11:29 ` sgn
2020-12-07 11:34 ` [PR PATCH] [Updated] " sgn
2020-12-07 12:59 ` sgn
2020-12-07 12:59 ` sgn
2020-12-09 18:29 ` [PR REVIEW] " ericonr
2020-12-10  0:13 ` [PR PATCH] [Updated] " sgn
2020-12-10  0:14 ` [PR REVIEW] " sgn
2020-12-10  0:27 ` ericonr
2020-12-10  0:39 ` sgn [this message]
2020-12-10 14:23 ` sgn
2020-12-14  2:35 ` [PR PATCH] [Merged]: " sgn

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=20201210003956.O4JFoYyMj_JKb-0TaXT9xpOEDr7Sf6vvc7n5IYin0fc@z \
    --to=sgn@users.noreply.github.com \
    --cc=ml@inbox.vuxu.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;
as well as URLs for NNTP newsgroup(s).