* [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables
@ 2021-05-26 19:06 Jon Turney
2021-05-28 16:06 ` Brian Inglis
0 siblings, 1 reply; 5+ messages in thread
From: Jon Turney @ 2021-05-26 19:06 UTC (permalink / raw)
To: cygwin-apps; +Cc: Jon Turney
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables
2021-05-26 19:06 [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables Jon Turney
@ 2021-05-28 16:06 ` Brian Inglis
2021-05-31 16:14 ` Jon Turney
0 siblings, 1 reply; 5+ messages in thread
From: Brian Inglis @ 2021-05-28 16:06 UTC (permalink / raw)
To: cygwin-apps
On 2021-05-26 13:06, Jon Turney wrote:
> 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
bash "declare -p NAME..." seems to do what you want and produce .source-able output:
$ ( . mingw64-x86_64-nghttp2/mingw64-x86_64-nghttp2.cygport; declare -p BUILD_REQUIRES DESCRIPTION; echo echo
\$BUILD_REQUIRES \$DESCRIPTION) | bash -svx
-bash: inherit: command not found
declare -- BUILD_REQUIRES="mingw64-x86_64-c-ares mingw64-x86_64-libevent mingw64-x86_64-win-iconv mingw64-x86_64-libxml2
mingw64-x86_64-openssl mingw64-x86_64-zlib libev-devel mingw64-x86_64-binutils mingw64-x86_64-CUnit
mingw64-x86_64-gcc-core mingw64-x86_64-gcc-g++ autoconf automake libtool pkg-config python3-sphinx"
+ declare -- 'BUILD_REQUIRES=mingw64-x86_64-c-ares mingw64-x86_64-libevent mingw64-x86_64-win-iconv
mingw64-x86_64-libxml2 mingw64-x86_64-openssl mingw64-x86_64-zlib libev-devel mingw64-x86_64-binutils
mingw64-x86_64-CUnit mingw64-x86_64-gcc-core mingw64-x86_64-gcc-g++ autoconf automake libtool pkg-config python3-sphinx'
declare -- DESCRIPTION="HTTP/2 and its header compression algorithm HPACK implementation.
The framing layer of HTTP/2 is implemented as a reusable library.
Also included are an HTTP/2 client, server, proxy, load test and
benchmarking tool, and Python modules.
Package provides Mingw MS VC RT-linked binaries, NOT Cygwin binaries,
for use with the mingw64-x86_64-gcc cross compiler, installed in
/usr/x86_64-w64-mingw32/sys-root/mingw/{bin,lib,include}/."
+ declare -- 'DESCRIPTION=HTTP/2 and its header compression algorithm HPACK implementation.
The framing layer of HTTP/2 is implemented as a reusable library.
Also included are an HTTP/2 client, server, proxy, load test and
benchmarking tool, and Python modules.
Package provides Mingw MS VC RT-linked binaries, NOT Cygwin binaries,
for use with the mingw64-x86_64-gcc cross compiler, installed in
/usr/x86_64-w64-mingw32/sys-root/mingw/{bin,lib,include}/.'
echo $BUILD_REQUIRES $DESCRIPTION
+ echo mingw64-x86_64-c-ares mingw64-x86_64-libevent mingw64-x86_64-win-iconv mingw64-x86_64-libxml2
mingw64-x86_64-openssl mingw64-x86_64-zlib libev-devel mingw64-x86_64-binutils mingw64-x86_64-CUnit
mingw64-x86_64-gcc-core mingw64-x86_64-gcc-g++ autoconf automake libtool pkg-config python3-sphinx HTTP/2 and its header
compression algorithm HPACK implementation. The framing layer of HTTP/2 is implemented as a reusable library. Also
included are an HTTP/2 client, server, proxy, load test and benchmarking tool, and Python modules. Package provides
Mingw MS VC RT-linked binaries, NOT Cygwin binaries, for use with the mingw64-x86_64-gcc cross compiler, installed in
'/usr/x86_64-w64-mingw32/sys-root/mingw/{bin,lib,include}/.'
mingw64-x86_64-c-ares mingw64-x86_64-libevent mingw64-x86_64-win-iconv mingw64-x86_64-libxml2 mingw64-x86_64-openssl
mingw64-x86_64-zlib libev-devel mingw64-x86_64-binutils mingw64-x86_64-CUnit mingw64-x86_64-gcc-core
mingw64-x86_64-gcc-g++ autoconf automake libtool pkg-config python3-sphinx HTTP/2 and its header compression algorithm
HPACK implementation. The framing layer of HTTP/2 is implemented as a reusable library. Also included are an HTTP/2
client, server, proxy, load test and benchmarking tool, and Python modules. Package provides Mingw MS VC RT-linked
binaries, NOT Cygwin binaries, for use with the mingw64-x86_64-gcc cross compiler, installed in
/usr/x86_64-w64-mingw32/sys-root/mingw/{bin,lib,include}/.
but eval dislikes the "declare --"!
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables
2021-05-28 16:06 ` Brian Inglis
@ 2021-05-31 16:14 ` Jon Turney
2021-05-31 23:46 ` Brian Inglis
0 siblings, 1 reply; 5+ messages in thread
From: Jon Turney @ 2021-05-31 16:14 UTC (permalink / raw)
To: cygwin-apps
On 28/05/2021 17:06, Brian Inglis wrote:
> On 2021-05-26 13:06, Jon Turney wrote:
>> 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
>
> bash "declare -p NAME..." seems to do what you want and produce
> .source-able output:
>
> $ ( . mingw64-x86_64-nghttp2/mingw64-x86_64-nghttp2.cygport; declare -p
> BUILD_REQUIRES DESCRIPTION; echo echo \$BUILD_REQUIRES \$DESCRIPTION) |
> bash -svx
Yeah, I should probably use 'declare -p'.
But just sourcing the .cygport is not adequate, as this can't determine
variables which are generated by cygport itself (e.g. VR, 'inherit' for
some cygclasses sets ARCH=noarch, etc.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables
2021-05-31 16:14 ` Jon Turney
@ 2021-05-31 23:46 ` Brian Inglis
2021-06-04 12:56 ` Jon Turney
0 siblings, 1 reply; 5+ messages in thread
From: Brian Inglis @ 2021-05-31 23:46 UTC (permalink / raw)
To: cygwin-apps
On 2021-05-31 10:14, Jon Turney wrote:
> On 28/05/2021 17:06, Brian Inglis wrote:
>> On 2021-05-26 13:06, Jon Turney wrote:
>>> 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
>> bash "declare -p NAME..." seems to do what you want and produce
>> .source-able output:
>> $ ( . mingw64-x86_64-nghttp2/mingw64-x86_64-nghttp2.cygport; declare
>> -p BUILD_REQUIRES DESCRIPTION; echo echo \$BUILD_REQUIRES
>> \$DESCRIPTION) | bash -svx
> Yeah, I should probably use 'declare -p'.
> But just sourcing the .cygport is not adequate, as this can't determine
> variables which are generated by cygport itself (e.g. VR, 'inherit' for
> some cygclasses sets ARCH=noarch, etc.)
I meant 'declare -p' solely as a means of getting properly escaped shell
values (like other shell command -p option flags) out of cygport in
statements which can be safely executed in other bash shell contexts.
The ./source was only a q&d means of setting the vars.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables
2021-05-31 23:46 ` Brian Inglis
@ 2021-06-04 12:56 ` Jon Turney
0 siblings, 0 replies; 5+ messages in thread
From: Jon Turney @ 2021-06-04 12:56 UTC (permalink / raw)
To: cygwin-apps; +Cc: Jon Turney
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 source-able in a shell
to be further used. 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'
> $ source <(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
v2: use 'declare -p'
---
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..5d42ab4 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
+ declare -p "${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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-06-04 12:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 19:06 [PATCH cygport] Add 'vars' command to output arbitrary .cygport variables Jon Turney
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
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).