Two new option was added to pkg_grep_summary: -s and -m
which make it easier for use Manual page was updated. More regression tests for pkg_grep_summary.
This commit is contained in:
parent
f596be3e97
commit
eb572c2d1b
4 changed files with 143 additions and 26 deletions
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: pkg_grep_summary.1,v 1.7 2008/11/07 17:55:46 cheusov Exp $
|
||||
.\" $NetBSD: pkg_grep_summary.1,v 1.8 2009/03/31 18:48:01 cheusov Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2008 by Aleksey Cheusov (vle@gmx.net)
|
||||
.\" Absolutely no warranty.
|
||||
|
@ -24,6 +24,10 @@ pkg_grep_summary \- tool for grepping pkgsrc summary file
|
|||
.br
|
||||
.BI "pkg_grep_summary -e" " field"
|
||||
.br
|
||||
.BI "pkg_grep_summary -m" " field regexp"
|
||||
.br
|
||||
.BI "pkg_grep_summary -s" " field string"
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
.B pkg_grep_summary
|
||||
outputs a summary information about packages that matches
|
||||
|
@ -45,10 +49,24 @@ display help message
|
|||
.TP
|
||||
.BI "-e" " field"
|
||||
outputs summaries in which
|
||||
.B "field"
|
||||
.I "field"
|
||||
is either empty or absent
|
||||
.TP
|
||||
.BI "-m" " field regexp"
|
||||
outputs summary if
|
||||
.I "regexp"
|
||||
matches the
|
||||
.I "field"
|
||||
.TP
|
||||
.BI "-s" " field string"
|
||||
outputs summary if
|
||||
.I "field"
|
||||
is equal to
|
||||
.I "string"
|
||||
.SH EXAMPLES
|
||||
.VB
|
||||
pkg_grep_summary -s 'PKGPATH' 'devel/libjudy'
|
||||
pkg_grep_summary -m 'PKGPATH' '^wip/'
|
||||
pkg_grep_summary 'PKGNAME' 'fvalue ~ /judy/' \\
|
||||
< /usr/pkgsrc/packages/pkg_summary.txt
|
||||
pkg_grep_summary 'PKGPATH' 'fvalue ~ /^lang\\//' \\
|
||||
|
|
|
@ -30,26 +30,32 @@ pkg_grep_summary - output summaries about packages that matches
|
|||
the specified condition.
|
||||
|
||||
USAGE: pkg_grep_summary -h
|
||||
pkg_grep_summary <FIELD> <AWK_CONDITION>
|
||||
pkg_grep_summary -e <FIELD>
|
||||
<FIELD> - PKGNAME, PKGPATH, DEPENDS etc.
|
||||
<AWK_CONDITION> - boolean expression written in AWK language
|
||||
pkg_grep_summary -e <field>
|
||||
pkg_grep_summary -m <field> <regexp>
|
||||
pkg_grep_summary -s <field> <string>
|
||||
pkg_grep_summary <field> <awk_condition>
|
||||
<field> - PKGNAME, PKGPATH, DEPENDS etc.
|
||||
<awk_condition> - boolean expression written in AWK language
|
||||
<regexp> - AWK regular expression
|
||||
<string> - text string
|
||||
|
||||
OPTIONS:
|
||||
-h|--help display this message
|
||||
-e|--empty <field> matches empty and absent fields only
|
||||
-h|--help display this message
|
||||
-e|--empty matches empty and absent fields only
|
||||
(equivalent to '<field>' 'fvalue == ""')
|
||||
-m matches <field> against regular expression <regexp>
|
||||
-s matches <field> equal to <string>
|
||||
EXAMPLES:
|
||||
pkg_grep_summary -s 'PKGPATH' 'devel/libjudy'
|
||||
pkg_grep_summary -m 'PKGPATH' '^wip/'
|
||||
pkg_grep_summary 'PKGNAME' 'fvalue ~ /judy/' \\
|
||||
< /usr/pkgsrc/packages/pkg_summary.txt
|
||||
pkg_grep_summary 'PKGPATH' 'fvalue ~ /^lang\//' \\
|
||||
< /usr/pkgsrc/packages/pkg_summary.txt
|
||||
pkg_grep_summary 'DEPENDS' 'fvalue ~ /libX/' \\
|
||||
< /usr/pkgsrc/pkg_src_summary.txt
|
||||
pkg_grep_summary 'COMMENT' 'toupper(fvalue) ~ /DNS/' \\
|
||||
< /usr/pkgsrc/pkg_src_summary.txt
|
||||
pkg_grep_summary -e 'NO_BIN_ON_FTP' \\
|
||||
< /usr/pkgsrc/pkg_src_summary.txt
|
||||
pkg_grep_summary -e 'NO_BIN_ON_CDROM'
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -59,7 +65,18 @@ while test $# -ne 0; do
|
|||
usage
|
||||
exit 0;;
|
||||
-e|--empty)
|
||||
empty_field=$2
|
||||
empty=1
|
||||
field=$2
|
||||
shift;;
|
||||
-s)
|
||||
field=$2
|
||||
string=$3
|
||||
shift
|
||||
shift;;
|
||||
-m)
|
||||
field=$2
|
||||
regex=$3
|
||||
shift
|
||||
shift;;
|
||||
--)
|
||||
shift
|
||||
|
@ -73,21 +90,23 @@ while test $# -ne 0; do
|
|||
shift
|
||||
done
|
||||
|
||||
if test -z "$empty_field" -a $# -ne 2 ||
|
||||
test -n "$empty_field" -a $# -ne 0
|
||||
then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$empty_field"; then
|
||||
field=$1
|
||||
if test -n "$empty"; then
|
||||
condition='fvalue == ""'
|
||||
elif test -n "$string"; then
|
||||
condition="fvalue == \"$string\""
|
||||
elif test -n "$regex"; then
|
||||
re=`echo $regex | sed 's|/|\\\/|g'`
|
||||
condition="fvalue ~ /$re/"
|
||||
elif test $# -eq 2; then
|
||||
field="$1"
|
||||
condition="$2"
|
||||
shift
|
||||
shift
|
||||
else
|
||||
field="$empty_field"
|
||||
condition='fvalue == ""'
|
||||
fi
|
||||
|
||||
if test -z "$condition" -o $# -ne 0; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
runawk -e '
|
||||
|
|
|
@ -79,6 +79,82 @@ PKGNAME=png-1.2.32beta01
|
|||
PKGNAME=netcat-1.10nb2
|
||||
PKGNAME=pkg-config-0.23
|
||||
PKGNAME=jpeg-6bnb4
|
||||
------- args: 'pkg_grep_summary' '-m' 'MAINTAINER' 'cheusov|vle@gmx.net'
|
||||
PKGNAME=distbb-0.22.0
|
||||
PKGPATH=wip/distbb
|
||||
COMMENT=DISTributed Bulk Build tool for pkgsrc
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGPATH=textproc/dictem
|
||||
COMMENT=Dictionary client (RFC-2229) for [X]Emacs
|
||||
MAINTAINER=cheusov@tut.by
|
||||
PKGNAME=dictem-0.82
|
||||
|
||||
COMMENT=Client/Server search in pkgsrc packages
|
||||
MAINTAINER=cheusov@tut.by
|
||||
PKGNAME=pkg_online-0.5.0nb2
|
||||
PKGPATH=wip/pkg_online
|
||||
|
||||
PKGNAME=dict-server-1.10.11nb2
|
||||
PKGPATH=wip/dict-server
|
||||
COMMENT=Dictionary Service Protocol server
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=pkg_online-server-0.5.0
|
||||
PKGPATH=wip/pkg_online-server
|
||||
COMMENT=Client/Server search in pkgsrc packages (server tools)
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=pkg_online-client-0.5.0
|
||||
PKGPATH=wip/pkg_online-client
|
||||
COMMENT=Client/Server search in pkgsrc packages (client tools)
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=libmaa-1.0.1nb1
|
||||
PKGPATH=devel/libmaa
|
||||
COMMENT=Provides a few data structures and helpful functions
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=paexec-0.10.0nb1
|
||||
PKGPATH=wip/paexec
|
||||
COMMENT=Parallel executor, distributes tasks over network
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=runawk-0.14.3
|
||||
PKGPATH=wip/runawk
|
||||
COMMENT=Wrapper that impelements modules for AWK
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=pkg_summary-utils-0.18.1
|
||||
PKGPATH=wip/pkg_summary-utils
|
||||
COMMENT=Utilities for manipulating pkg_summary(5) files
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=dict-client-1.10.11nb2
|
||||
PKGPATH=wip/dict-client
|
||||
COMMENT=Dictionary Service Protocol client
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=pipestatus-0.4.0
|
||||
PKGPATH=wip/pipestatus
|
||||
COMMENT=UNIX/POSIX shell helper for running pipes safely
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
PKGNAME=awk-pkgsrc-dewey-0.5.6
|
||||
PKGPATH=wip/awk-pkgsrc-dewey
|
||||
COMMENT=Pkgsrc dewey module for AWK programming language
|
||||
MAINTAINER=cheusov@tut.by
|
||||
|
||||
--------------------------------------------------
|
||||
------- args: 'pkg_grep_summary' '-s' 'PKGPATH' 'graphics/png'
|
||||
PKGNAME=png-1.2.32beta01
|
||||
PKGPATH=graphics/png
|
||||
BUILD_DEPENDS= libtool-base>=1.5.18nb5:../../devel/libtool-base checkperms>=1.1:../../sysutils/checkperms
|
||||
HOMEPAGE=http://www.libpng.org/pub/png/
|
||||
COMMENT=Library for manipulating PNG images
|
||||
MAINTAINER=wiz@NetBSD.org
|
||||
CATEGORIES=graphics
|
||||
|
||||
--------------------------------------------------
|
||||
------- pkg_cmp_summary #1.1
|
||||
= awk-pkgsrc-dewey 0.5.6 0.5.6
|
||||
|
|
|
@ -49,6 +49,10 @@ runtest pkg_grep_summary COMMENT \
|
|||
grep -E 'PKGNAME|---'
|
||||
runtest pkg_grep_summary -e EXFIELD < src_summary.txt | \
|
||||
grep -E 'PKGNAME|---'
|
||||
runtest pkg_grep_summary -m MAINTAINER 'cheusov|vle@gmx.net' < src_summary.txt |
|
||||
grep -E 'PKGNAME|PKGPATH|^$|MAINTAINER|COMMENT'
|
||||
|
||||
runtest pkg_grep_summary -s PKGPATH graphics/png < src_summary.txt
|
||||
|
||||
# pkg_cmp_summary
|
||||
echo '--------------------------------------------------'
|
||||
|
@ -123,7 +127,7 @@ grep -v '^='
|
|||
# pkg_summary4view
|
||||
echo '--------------------------------------------------'
|
||||
echo '------- pkg_summary4view #8'
|
||||
pkg_grep_summary PKGPATH 'fvalue == "wip/pkg_summary-utils"' \
|
||||
pkg_grep_summary -s PKGPATH 'wip/pkg_summary-utils' \
|
||||
< src_summary.txt | pkg_summary4view
|
||||
|
||||
echo '--------------------------------------------------'
|
||||
|
@ -168,7 +172,7 @@ echo '------- pkg_src_summary #11'
|
|||
pkg_src_summary -A -f PKGNAME,PKGPATH \
|
||||
graphics/py-cairo:PYTHON_VERSION_REQD=25 |
|
||||
grep -v DEPENDS |
|
||||
pkg_grep_summary PKGPATH 'fvalue ~ /gmake|py-Numeric|py-cairo/' |
|
||||
pkg_grep_summary -m PKGPATH 'gmake|py-Numeric|py-cairo' |
|
||||
normalize_version
|
||||
|
||||
echo '--------------------------------------------------'
|
||||
|
|
Loading…
Reference in a new issue