Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] 99-pkglint-subpkgs: simplify and correct
@ 2020-12-05  1:41 sgn
  2020-12-05  3:44 ` [PR PATCH] [Updated] " sgn
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: sgn @ 2020-12-05  1:41 UTC (permalink / raw)
  To: ml

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

There is a new 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: 2323 bytes --]

From 19d6ecf481f071313e9819490b3c931a32a0d9c3 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: 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
---
 common/hooks/pre-pkg/99-pkglint-subpkgs.sh | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh
index add7fdd4a07..0bfc72d11f0 100644
--- a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh
+++ b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh
@@ -18,21 +18,22 @@ 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)"
+    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" ||

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

end of thread, other threads:[~2020-12-14  2:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-05  1:41 [PR PATCH] 99-pkglint-subpkgs: simplify and correct 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 ` [PR PATCH] [Updated] " sgn
2020-12-10 14:23 ` sgn
2020-12-14  2:35 ` [PR PATCH] [Merged]: " sgn

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