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
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables
Date: Wed, 26 May 2021 20:06:37 +0100	[thread overview]
Message-ID: <20210526190637.30456-1-jon.turney@dronecode.org.uk> (raw)

Since variables in a .cygport file can be computed from arbitrary shell
expressions, perhaps containing variables that cygport itself defines,
other programs can't determine their value just by parsing the .cygport
file.

Add 'vars' command to output arbitrary variables defined by the .cygport
file.

The idea is that the output from this should be eval-able in a shell to
be further used, but it probably needs some additional escaping (of
newlines?) to be completely right in all cases.

e.g

> $ cygport libX11.cygport vars PVR BUILD_REQUIRES
> PVR='1.7.1-1'
> BUILD_REQUIRES='xtrans xorgproto libxcb-devel xmlto xorg-sgml-doctools docbook-xml43'

> eval $(cygport libX11.cygport vars BUILD_REQUIRES) ; for r in ${BUILD_REQUIRES} ; do echo $r; done
> xtrans
> xorgproto
> libxcb-devel
> xmlto
> xorg-sgml-doctools
> docbook-xml43
---

Notes:
    This is a generalization of the idea in [1], for querying the
    build-depends of a package.
    
    https://cygwin.com/pipermail/cygwin-apps/2021-January/041006.html

 bin/cygport.in               |  5 +++++
 data/cygport-bash-completion |  2 +-
 lib/pkg_info.cygpart         | 10 +++++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/bin/cygport.in b/bin/cygport.in
index afc6f7e..e9295be 100755
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -623,6 +623,11 @@ do
 			__show_info;
 			_status=$?;
 			;;
+		vars)
+			__show_vars ${argv[@]:$((++arg_n))};
+			_status=$?;
+			arg_n=$argc;  # consumed all remaining args
+			;;
 		homepage|web*|www*)
 			__show_web;
 			_status=$?;
diff --git a/data/cygport-bash-completion b/data/cygport-bash-completion
index 86df238..9085e19 100644
--- a/data/cygport-bash-completion
+++ b/data/cygport-bash-completion
@@ -12,7 +12,7 @@ _cygport()
 		check test inst install list dep depends \
 		package pkg package-test pkg-test diff mkdiff mkpatch \
 		upload stage announce almostall all all-test clean finish \
-		help info version homepage website'
+		help info version homepage website vars'
 
 	if [[ $COMP_CWORD -eq 1 ]] ; then
 		# first arg: source file completion
diff --git a/lib/pkg_info.cygpart b/lib/pkg_info.cygpart
index 4b18993..a5475cc 100644
--- a/lib/pkg_info.cygpart
+++ b/lib/pkg_info.cygpart
@@ -658,5 +658,13 @@ __show_web() {
 	${mybrowser} ${mywww} &>/dev/null &
 }
 
+__show_vars() {
+	for v in "$@"
+	do
+		echo "${v}='${!v}'"
+	done
+}
+
 readonly -f __list_files __list_debug_files __list_deps \
-	    __show_deps __show_info __show_web __pager
+	    __show_deps __show_info __show_web __pager \
+	    __show_vars
-- 
2.31.1


             reply	other threads:[~2021-05-26 19:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 19:06 Jon Turney [this message]
2021-05-28 16:06 ` Brian Inglis
2021-05-31 16:14   ` Jon Turney
2021-05-31 23:46     ` Brian Inglis
2021-06-04 12:56       ` Jon Turney

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=20210526190637.30456-1-jon.turney@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).