From: classabbyamp <classabbyamp@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] common/xbps-src/shutils/show.sh: display `$license` one-per-line
Date: Fri, 16 Dec 2022 04:29:45 +0100 [thread overview]
Message-ID: <20221216032945.VfvlfZJZobgo25VdlJnpKQl-sy4IAQ3ac8md6JYJ-cQ@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-41032@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]
There is an updated pull request by classabbyamp against master on the void-packages repository
https://github.com/classabbyamp/void-packages license-show
https://github.com/void-linux/void-packages/pull/41032
common/xbps-src/shutils/show.sh: display `$license` one-per-line
previously, if there was a newline in `$license`, it would not format
properly in `xbps-src show`. This fixes it by splitting it by word and
removing commas and displaying it like some other variables.
fixes #40996
Example:
```
$ ./xbps-src show keepassxc
pkgname: keepassxc
...
License(s): GPL-3.0-or-later
License(s): BSD-3-Clause
License(s): CC0-1.0
License(s): LGPL-2.0-only
License(s): LGPL-2.1-only
License(s): LGPL-3.0-or-later
License(s): Nokia-Qt-exception-1.1
License(s): MIT
License(s): BSL-1.0
```
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **YES**
A patch file from https://github.com/void-linux/void-packages/pull/41032.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-license-show-41032.patch --]
[-- Type: text/x-diff, Size: 4572 bytes --]
From 1678ac811ec270d066abf447e255523326a15e4c Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Mon, 12 Dec 2022 01:21:29 -0500
Subject: [PATCH] common/xbps-src/shutils/show.sh: make show display consistent
previously, if there was a newline in some variables, it would not format
properly in `xbps-src show`. This fixes it by always splitting it by word
in some cases, like if there is a new line in the variable's value, and
removing internal commas in some cases.
This logic was split into a function for consistency.
fixes #40996
Example:
```
$ ./xbps-src show keepassxc
pkgname: keepassxc
...
License(s): GPL-3.0-or-later
License(s): BSD-3-Clause
License(s): CC0-1.0
License(s): LGPL-2.0-only
License(s): LGPL-2.1-only
License(s): LGPL-3.0-or-later
License(s): Nokia-Qt-exception-1.1
License(s): MIT
License(s): BSL-1.0
```
---
common/xbps-src/shutils/show.sh | 87 ++++++++++++++++-----------------
1 file changed, 42 insertions(+), 45 deletions(-)
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index d781d07aae86..d639d7c12324 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,49 +1,27 @@
# vim: set ts=4 sw=4 et:
show_pkg() {
- local i=
-
- echo "pkgname: $pkgname"
- echo "version: $version"
- echo "revision: $revision"
- for i in ${distfiles}; do
- [ -n "$i" ] && echo "distfiles: $i"
- done
- for i in ${checksum}; do
- [ -n "$i" ] && echo "checksum: $i"
- done
- for i in ${archs}; do
- [ -n "$i" ] && echo "archs: $i"
- done
- echo "maintainer: $maintainer"
- [ -n "$homepage" ] && echo "Upstream URL: $homepage"
- [ -n "$license" ] && echo "License(s): $license"
- [ -n "$changelog" ] && echo "Changelog: $changelog"
- [ -n "$build_style" ] && echo "build_style: $build_style"
- for i in $build_helper; do
- [ -n "$i" ] && echo "build_helper: $i"
- done
- for i in ${configure_args}; do
- [ -n "$i" ] && echo "configure_args: $i"
- done
- echo "short_desc: $short_desc"
- for i in ${subpackages}; do
- [ -n "$i" ] && echo "subpackages: $i"
- done
+ show_pkg_var "pkgname" "$pkgname"
+ show_pkg_var "version" "$version"
+ show_pkg_var "revision" "$revision"
+ show_pkg_var "distfiles" "$distfiles" 1
+ show_pkg_var "checksum" "$checksum" 1
+ show_pkg_var "archs" "$archs" 1
+ show_pkg_var "maintainer" "${maintainer}"
+ show_pkg_var "Upstream URL" "$homepage"
+ show_pkg_var "License(s)" "${license//,/ }" 1
+ show_pkg_var "Changelog" "$changelog"
+ show_pkg_var "build_style" "$build_style"
+ show_pkg_var "build_helper" "$build_helper" 1
+ show_pkg_var "configure_args" "$configure_args" 1
+ show_pkg_var "short_desc" "$short_desc"
+ show_pkg_var "subpackages" "$subpackages" 1
set -f
- for i in ${conf_files}; do
- [ -n "$i" ] && echo "conf_files: $i"
- done
+ show_pkg_var "conf_files" "$conf_files" 1
set +f
- for i in ${replaces}; do
- [ -n "$i" ] && echo "replaces: $i"
- done
- for i in ${provides}; do
- [ -n "$i" ] && echo "provides: $i"
- done
- for i in ${conflicts}; do
- [ -n "$i" ] && echo "conflicts: $i"
- done
+ show_pkg_var "replaces" "$replaces" 1
+ show_pkg_var "provides" "$provides" 1
+ show_pkg_var "conflicts" "$conflicts" 1
local OIFS="$IFS"
IFS=','
for var in $1; do
@@ -51,11 +29,9 @@ show_pkg() {
if [ ${var} != ${var/'*'} ]
then
var="${var/'*'}"
- [ -n "${!var}" ] && echo "$var: ${!var//$'\n'/' '}"
+ show_pkg_var "$var" "${!var//$'\n'/' '}"
else
- for val in ${!var}; do
- [ -n "$val" ] && echo "$var: $val"
- done
+ show_pkg_var "$var" "${!var}" 1
fi
done
IFS="$OIFS"
@@ -63,6 +39,27 @@ show_pkg() {
return 0
}
+show_pkg_var() {
+ local _sep i=
+ local _label="$1"
+ local _value="$2"
+ local _always_split="$3"
+ if [ -n "$_value" ] && [ -n "$_label" ]; then
+ if [ "${#_label}" -lt 7 ]; then
+ sep=" "
+ else
+ sep=" "
+ fi
+ if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
+ for i in ${_value}; do
+ [ -n "$i" ] && echo "${_label}:${sep}${i}"
+ done
+ else
+ echo "${_label}:${sep}${_value}"
+ fi
+ fi
+}
+
show_pkg_deps() {
[ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
}
next prev parent reply other threads:[~2022-12-16 3:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 6:25 [PR PATCH] " classabbyamp
2022-12-15 20:50 ` meator
2022-12-15 21:52 ` meator
2022-12-15 21:55 ` classabbyamp
2022-12-16 3:29 ` classabbyamp [this message]
2022-12-16 3:44 ` [PR REVIEW] common/xbps-src/shutils/show.sh: make show display consistent CameronNemo
2022-12-16 3:45 ` classabbyamp
2022-12-16 3:46 ` [PR PATCH] [Updated] " classabbyamp
2022-12-16 3:49 ` [PR REVIEW] " CameronNemo
2022-12-16 3:51 ` [PR PATCH] [Updated] " classabbyamp
2022-12-16 4:26 ` CameronNemo
2022-12-19 0:27 ` [PR PATCH] [Merged]: " classabbyamp
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=20221216032945.VfvlfZJZobgo25VdlJnpKQl-sy4IAQ3ac8md6JYJ-cQ@z \
--to=classabbyamp@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).