Mail Archives: cygwin/2004/12/02/14:56:10
--=====Cut=====
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8Bit
Hallo,
Sometimes one wants to read a description for one or more packages.
I wrote following script to retrieve that info from the locally
installed setup-inis. It's parameters are anchored regexes if
the first one is not ``-r'', after which they are plain text:
$ cyg-desc '.*ss[hl]' '.*x11.*'
or
$ cyg-desc -r gtk+ gcc-g++
The script requires /bin/sh, cat, awk, true, false, cygpath, a package-
dir left by setup, /etc/setup/last-mirror and /etc/setup/last-cache.
I hope this is of use to anybody.
L8r,
Buzz.
--
) | | ---/ ---/ Yes, this | This message consists of true | I do not
-- | | / / really is | and false bits entirely. | mail for
) | | / / a 72 by 4 +-------------------------------+ any1 but
-- \--| /--- /--- .sigfile. | |perl -pe "s.u(z)\1.as." | me. 4^re
--=====Cut=====
Content-Type: text/plain; name="cyg-desc"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="cyg-desc"
#!/bin/sh
# Copyright (C) Bas van Gompel 2004.
# All rights reserved. No warranties.
# This software may not be used for aggressive purposes.
RCS_ID="$Id: cyg-desc.sh,v 1.11 2004/12/02 18:25:30 Buzz Exp Buzz $"
cache_files=""
if test "$1"x = "-r"x; then
regex=false
shift
else
regex=true
fi
if test -f /etc/setup/last-mirror; then
for f in $(cat /etc/setup/last-mirror); do
cache_files="${cache_files}$(
cygpath -u $(
cat /etc/setup/last-cache
)
)/$(
echo "$f"|sed 's,:,%3a,g;s,/,%2f,g'
)/setup.ini
"
done
until test -z "$1"; do
echo "${cache_files}" |until
read cache_file
if test -z "${cache_file}"; then
echo "$0: desc for $1 not found."
true
elif test -f "${cache_file}"; then
if ${regex}; then
reg_op='~ /^'$1'$/'
else
reg_op='== "'$1'"'
fi
awk -f - ${cache_file} <<-EOA
BEGIN {rv = 1}
/^@/ {
if (ib == 1) {
if (!hd && sd) {
print gensub (/^sdesc/, pn, 1, sd)
sd = ""
rv = 0
}
print ""
}
hd = 0
if (\$2 ${reg_op}) {
ib = 1
pn = \$2
next
} else {
ib = 0
} }
/^sdesc: "/ {if (ib) {sd = \$0; next}}
/^ldesc: ".*"/ {if (ib) {print gensub (/^ldesc/, pn, 1); hd = 1; rv = 0; next}}
/^ldesc: "/ {if (ib) {id = 1; print gensub (/^ldesc/, pn, 1); hd = 1; next}}
/"\$/ {if (id) {id = 0; print \$0; rv = 0}}
/.*/ {if (id) {print \$0}}
END {exit rv}
EOA
else
false
fi
do
:
done
shift
done
else
echo "$0: Can not read mirror-file /etc/setup/last-mirror" >&2
fi
--=====Cut=====
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--=====Cut=====--
- Raw text -