Update to 0.43.0:

Regression tests framework has been completely reworked.

  All tool using short options conform to POSIX Utility Syntax Guidelines.

  pkg_summary4view:
     - reworked
     - content of DEPENDS, BUILD_DEPENDS etc. is sorted alphabetically.

  pkg_src_summary:
     - fix in PSS_PPERS
     - new artificial field ALLDISTFILES, list of distfiles with
       their sizes separated by colon
This commit is contained in:
Aleksey Cheusov 2010-10-10 20:34:02 +00:00 committed by Thomas Klausner
parent a359443f59
commit 08686e3f58
17 changed files with 2471 additions and 2587 deletions

View file

@ -1,7 +1,6 @@
# $NetBSD: Makefile,v 1.34 2010/10/10 18:23:39 cheusov Exp $
# $NetBSD: Makefile,v 1.35 2010/10/10 20:34:02 cheusov Exp $
DISTNAME= pkg_summary-utils-${VERSION}
PKGREVISION= 1
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@ -12,7 +11,7 @@ COMMENT= Utilities for manipulating pkg_summary(5) files
LICENSE= mit
DEPENDS+= runawk>=0.16.0:../../wip/runawk
DEPENDS+= runawk>=1.1.0:../../wip/runawk
DEPENDS+= awk-pkgsrc-dewey>=0.5.6:../../wip/awk-pkgsrc-dewey
DEPENDS+= pipestatus-[0-9]*:../../devel/pipestatus
#DEPENDS+= getopt-[0-9]*:../../misc/getopt

View file

@ -116,14 +116,9 @@ DIFF_PROG?= diff -U10
.PHONY : test
test : all
@echo 'running tests...'; \
if cd ${.CURDIR}/tests && \
env PATH="${.OBJDIR}:$$PATH" OBJDIR=${.OBJDIR} \
BMAKE=${BMAKE} ./test.sh \
> ${.OBJDIR}/_test.res && \
${DIFF_PROG} ${.CURDIR}/tests/test.out ${.OBJDIR}/_test.res; \
then echo ' succeeded'; \
else echo ' failed'; false; \
fi
set -e; cd ${.CURDIR}/tests; \
env PATH="${.OBJDIR}:$$PATH" OBJDIR=${.OBJDIR} \
BMAKE=${BMAKE} ./test.sh
############################################################

View file

@ -1,9 +1,5 @@
TODO list and thoughts
------------------------
0) pkg_summary4view
-----------------------
existing tools:
cvs_checksum:
@ -18,6 +14,7 @@ existing tools:
- -f <n> use pkgbase only for comparison
- -f <pn> use pkgbase and pkgpath for comparison
- automatic removal of #-comments
- output ! if DEPENDS or BUILD_DEPENDS differ
pkg_grep_summary:
- -f <fields> output only specified fields, this
@ -49,7 +46,6 @@ existing tools:
pkg_summary2deps:
pkg_summary4view:
- resort tokens inside DEPENDS, BUILD_DEPENDS and CONFLICTS
- another format for DEPENDS, BUILD_DEPENDS and CONFLICTS,
(convertors for RHEL yum, Debian apt, OpenSolaris IPS)

View file

@ -45,21 +45,15 @@ OPTIONS:
EOF
}
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-l|--list)
list_only=1;;
-*)
echo "Unrecognized option " $1 ". Type --help to see usage" 1>&2
exit 1;;
*)
break;;
esac
shift
done
process_args (){
alt_getopt \
'h help' 'usage; exit 0' \
'l list' list_only=1 \
-- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
if test "$list_only"; then
for i in "$@"; do
@ -67,7 +61,7 @@ if test "$list_only"; then
if test -r "$efn"; then
awk -F/ -v d="$i" '$1 == "" {print d "/" $2, $3}' "$efn"
subdirs="`awk -F/ -v d="$i" '$1 == "D" && NF > 1 {print d "/" $2}' "$efn" `"
subdirs=`awk -F/ -v d="$i" '$1 == "D" && NF > 1 {print d "/" $2}' "$efn" `
$0 -l $subdirs
else
echo "$i/CVS/Entries files is not readable" 1>&2

View file

@ -59,31 +59,17 @@ Samples of use:
EOF
}
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-a)
add_fields="$add_fields $2"
shift;;
-r)
rem_fields="$rem_fields $2"
shift;;
-f)
only_fields="$only_fields $2"
shift;;
--)
shift
break;;
-*)
echo "Bad option $1" 1>&2
exit 1;;
*)
break
esac
shift
done
process_args (){
alt_getopt \
'h help' 'usage; exit 0' \
=a add_fields= \
=r rem_fields= \
=f only_fields= \
-- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
if test $# -eq 0; then
pkg_info_opts=-XBa

View file

@ -48,24 +48,15 @@ EOF
}
delete=''
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-r)
delete=1;;
--)
shift
break;;
-*)
echo "Bad option $1" 1>&2
exit 1;;
*)
break
esac
shift
done
process_args (){
alt_getopt \
'h help' 'usage; exit 0' \
r delete=1 \
-- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
DISTDIR=${DISTDIR:=@DISTDIR@}
cd "$DISTDIR"

View file

@ -37,22 +37,12 @@ OPTIONS:
EOF
}
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
--)
shift
break;;
-*)
echo "Unrecognized option " $1 ". Type --help to see usage" 1>&2
exit 1;;
*)
break;;
esac
shift
done
process_args (){
alt_getopt 'h help' 'usage; exit 0' -- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
############################################################
# user settable variables

View file

@ -47,40 +47,26 @@ about source packages
usage: pkg_micro_src_summary [OPTIONS] [pkgpath1 pkgpath2 ...]
OPTIONS:
-h|--help display this help message
-f|--fields <filename>
-f|--fields=<filename> fields to be included to summary,
PKGNAME and PKGPATH by default
-f|--fields <fields> fields to be included to summary,
PKGNAME and PKGPATH is the default
EOF
}
fields='PKGNAME PKGPATH'
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-f|--fields)
fields="`echo $2 | tr , ' '`"
shift;;
-f=*)
printf '%s\n' '-f= is not allowed' 1>&2
exit 1;;
--fields=*)
fields="$(echo $1 | cut -f2 -d= | tr , ' ')";;
-f*)
fields="$(echo $1 | cut -b 3- | tr , ' ')";;
--)
shift
break;;
-*)
echo "Unrecognized option " $1 ". Type --help to see usage" 1>&2
exit 1;;
*)
break;;
esac
shift
done
set_fields (){
fields=$(echo "$@" | tr , ' ')
}
process_args (){
alt_getopt \
'h help' 'usage; exit 0' \
'=f fields' 'set_fields ' \
-- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
############################################################
cd $PKGSRCDIR

View file

@ -38,24 +38,14 @@ OPTIONS:
EOF
}
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-o)
print_older=1;;
--)
shift
break;;
-*)
echo "Bad option $1" 1>&2
exit 1;;
*)
break
esac
shift
done
process_args (){
alt_getopt \
'h help' 'usage; exit 0' \
o print_older=1 \
-- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
############################################################

View file

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_src_summary.1,v 1.24 2010/05/30 19:29:40 cheusov Exp $
.\" $NetBSD: pkg_src_summary.1,v 1.25 2010/10/10 20:34:03 cheusov Exp $
.\"
.\" Copyright (c) 2008 by Aleksey Cheusov (vle@gmx.net)
.\" Absolutely no warranty.
@ -40,9 +40,13 @@ A list of fields (separated by space character or comma) to be generated. By
default the following fields are generated: PKGNAME, PKGPATH, DEPENDS,
BUILD_DEPENDS, CONFLICTS, HOMEPAGE, COMMENT, LICENSE, ONLYFOR, NOTFOR,
MAINTAINER, CATEGORIES, NO_BIN_ON_FTP, NO_SRC_ON_FTP,
NO_BIN_ON_CDROM, NO_SRC_ON_CDROM, ALLSRCFILES
NO_BIN_ON_CDROM, NO_SRC_ON_CDROM, ALLSRCFILES, ALLDISTFILES,
DESCRIPTION (multiline), PLIST(multiline).
The following fields are NOT generated by default: CVS_CHECKSUM.
The following fields are NOT generated by default: CVS_CHECKSUM,
ALLDISTFILES. ALLDISTFILES value lists distfiles with their
sizes (obtained from distinfo file) separated by colon.
ALLSRCFILES value lists distfiles with relative directory (if any)
under ${DISTDIR}.
.TP
.BI "-a|--add-fields" " fields"
Add the specified fields to the list of fields generated by default

View file

@ -78,21 +78,27 @@ EOF
# list of fields for default pkg_src_summary
if test -z "$PSS_FIELDS"; then
PSS_FIELDS='PKGNAME PKGPATH DEPENDS BUILD_DEPENDS CONFLICTS HOMEPAGE COMMENT LICENSE ONLYFOR NOTFOR MAINTAINER CATEGORIES NO_BIN_ON_FTP NO_SRC_ON_FTP NO_BIN_ON_CDROM NO_SRC_ON_CDROM LICENSE ALLSRCFILES DESCRIPTION PLIST' # CVS_CHECKSUM'
PSS_FIELDS='PKGNAME PKGPATH DEPENDS BUILD_DEPENDS CONFLICTS HOMEPAGE COMMENT LICENSE ONLYFOR NOTFOR MAINTAINER CATEGORIES NO_BIN_ON_FTP NO_SRC_ON_FTP NO_BIN_ON_CDROM NO_SRC_ON_CDROM LICENSE ALLSRCFILES DESCRIPTION PLIST' # CVS_CHECKSUM ALLDISTFILES
fi
if test -z "$PSS_PPERS"; then
PSS_PPERS=10
fi
set_fields (){
PSS_FIELDS=$(echo $* | tr , ' ')
}
add_fields (){
rem_fields "$@"
for f in "$@"; do
__fields=$(echo $* | tr , ' ')
rem_fields $__fields
for f in $__fields; do
PSS_FIELDS="$PSS_FIELDS $f"
done
}
rem_fields (){
__fields=$(echo $* | tr , ' ')
PSS_FIELDS=`awk '
BEGIN {
for (i=1; i < ARGC; ++i){
@ -105,86 +111,33 @@ BEGIN {
}
}
}
' "$@" - $PSS_FIELDS`
' $__fields - $PSS_FIELDS`
}
process_options (){
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-f|--fields)
PSS_FIELDS="$(echo $2 | tr , ' ')"
shift;;
-f=*)
printf '%s\n' '-f= is not allowed' 1>&2
exit 1;;
-a=*)
printf '%s\n' '-a= is not allowed' 1>&2
exit 1;;
-r=*)
printf '%s\n' '-r= is not allowed' 1>&2
exit 1;;
--fields=*)
PSS_FIELDS="$(echo $1 | cut -f2 -d= | tr , ' ')";;
-f*)
PSS_FIELDS="$(echo $1 | cut -b 3- | tr , ' ')";;
-a|--add-fields)
add_fields $(echo $2 | tr , ' ')
shift;;
--add-fields=*)
add_fields $(echo $1 | cut -f2 -d= | tr , ' ');;
-a*)
add_fields $(echo $1 | cut -b 3- | tr , ' ');;
-r|--rem-fields)
rem_fields $(echo $2 | tr , ' ')
shift;;
--rem-fields=*)
rem_fields $(echo $1 | cut -f2 -d= | tr , ' ');;
-r*)
rem_fields $(echo $1 | cut -b 3- | tr , ' ');;
-s|--slave-mode)
slave=1;;
-p|--make-plist)
make_plist='-p';;
-b)
add_fields BOOTSTRAP_DEPENDS BUILD_DEPENDS
with_bootstrap=-b;;
-l)
with_libdeps=-l;;
-d|--with-deps)
with_dep=-d;;
-D|--with-bdeps)
with_bdep=-D;;
-A|--with-alldeps)
add_fields DEPENDS BUILD_DEPENDS
with_dep=-d
with_bdep=-D;;
-m)
multi_var=1;;
-M)
multi_var=2;;
-i|--installed)
installed_pkgs=1;;
-G)
debug=1;;
--)
shift
break;;
-*)
echo "Unrecognized option " $1 ". Type --help to see usage" 1>&2
exit 1;;
*)
break;;
esac
shift
done
pkgpaths="$@"
alt_getopt \
'h help' 'usage; exit 0' \
'=f fields' 'set_fields ' \
'=a add-fields' 'add_fields ' \
'=r rem-fields' 'rem_fields ' \
's slave-mode' slave=1 \
'p make-plist' make_plist='-p' \
b 'add_fields BOOTSTRAP_DEPENDS BUILD_DEPENDS; with_bootstrap=-b' \
l 'with_libdeps=-l' \
'd with-deps' with_dep=-d \
'D with-bdeps' with_bdep=-D \
'A with-alldeps' 'add_fields DEPENDS BUILD_DEPENDS;
with_dep=-d; with_bdep=-D' \
m multi_var=1 \
M multi_var=2 \
'i installed' installed_pkgs=1 \
G debug=1 \
-- "$@"
}
cmds=`process_options $PSS_OPTIONS "$@"`
eval "$cmds"
process_options $PSS_OPTIONS "$@"
pkgpaths="$*"
with_xxx="$with_bootstrap $with_libdeps"
@ -207,6 +160,9 @@ fi
if echo "$PSS_FIELDS" | grep PLIST > /dev/null; then
field_plist=1
fi
if echo "$PSS_FIELDS" | grep ALLDISTFILES > /dev/null; then
field_alldistfiles=1
fi
if echo "$PSS_FIELDS" | grep CVS_CHECKSUM > /dev/null; then
field_cvs_checksum=1
fi
@ -284,6 +240,13 @@ pkgpath2multivar_opts (){
sed -e 's|^[^:]*:||' -e 's|,| |g' -e "s|[^ ][^ ]*|'&'|g" -e 's|~| |g'
}
get_alldistfiles (){
awk -F'[ =()]*' \
'$1 == "Size" {printf " %s:%s", $2, $3}
END {print ""}
' "$@"
}
cd_and_print_summary (){
# $1 - pkgpath
real_pkgpath="`echo $1 | cut -d: -f1`"
@ -314,6 +277,14 @@ cd_and_print_summary (){
printf "CVS_CHECKSUM=%s\n" "$cksum" >>"$summaryfn" || return 1
fi
# alldistfiles
if test "$field_alldistfiles"; then
distinfo_fns="$(cd $real_pkgpath && ${BMAKE} show-var VARNAME=DISTINFO_FILE)"
# /dev/null is a protection against distinfo_fns emptyness
alldistfiles=$(get_alldistfiles $distinfo_fns /dev/null)
printf "ALLDISTFILES=%s\n" "$alldistfiles" >>"$summaryfn" || return 1
fi
# PLIST
if test "$field_plist"; then
if test -n "$make_plist" && \
@ -382,7 +353,7 @@ packages2stdout__1per_line (){
installed_packages2stdout
elif test $# -eq 0; then
# processing stdin
cat
awk '{for (i=1; i <= NF; ++i) {print $i}}' "$@"
else
# processing arguments
for pkgpath in "$@"; do
@ -397,11 +368,11 @@ packages2stdout (){
{
printf " %s", $0
}
(NR % pss_ppers) == 0 {
((NR-1) % pss_ppers) == 0 {
printf "\n"
}
END {
if ((NR % pss_ppers) != 0){
if (((NR-1) % pss_ppers) != 0){
printf "\n"
}
}'

View file

@ -1,6 +1,6 @@
#!/usr/bin/env runawk
# Copyright (c) 2007-2008 Aleksey Cheusov <vle@gmx.net>
# Copyright (c) 2007-2010 Aleksey Cheusov <vle@gmx.net>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@ -28,6 +28,7 @@
#use "alt_getopt.awk"
#use "abort.awk"
#use "power_getopt.awk"
#use "heapsort.awk"
############################################################
#.begin-str help
@ -46,6 +47,16 @@ function spaces (n, ret){
return ret
}
function resort_D0 (arr, remap, i){
for (i=1; i <= NF; ++i){
arr [i] = $i
}
heapsort(arr, remap, 1, NF)
for (i=1; i <= NF; ++i){
$i = arr [remap [i]]
}
}
BEGIN {
special ["DESCRIPTION"] = 0
special ["PLIST"] = 0
@ -56,21 +67,32 @@ BEGIN {
depends_like ["DEPENDS"] = 0
depends_like ["CONFLICTS"] = 0
# single or multiple line
s_or_m ["ALLDISTFILES"] = 0
s_or_m ["ALLSRCFILES"] = 0
offset = 16
}
BEGIN {
for (i in s_or_m){
depends_like [i] = 0
}
}
NF == 0 {
print
last_field = ""
printf "%s", accu
accu = ""
to_be_printed = 0
prev_field = ""
print ""
next
}
/^PKGNAME=/ {
function get_alldistfiles (tok, idx){
idx = index(tok, ":")
return substr(tok, 1, idx-1) " " spaces(45-idx) substr(tok, idx+1)
}
NF > 0 && prev_field == "" {
print "-----------------------------------------------------------"
to_be_printed = 1
}
{
@ -81,52 +103,48 @@ NF == 0 {
#
sub(/^[^=]*=/, "")
if (NF == 0){
prev_field = field
if (NF == 0)
next
}
field_alldistfiles = (field == "ALLDISTFILES")
#
if (field in depends_like){
resort_D0()
if (field != prev_field) {
field1 = field ":"
accu = accu field1
printf "%s", field1
}else{
field1 = ""
}
if (NF > 0)
accu = accu spaces(offset - length(field1))
printf "%s", spaces(offset - length(field1))
accu = accu $1 "\n"
if (field_alldistfiles){
printf "%s\n", get_alldistfiles($1)
}else{
printf "%s\n", $1
}
for (i=2; i <= NF; ++i){
accu = accu spaces(offset)
accu = accu $i "\n"
printf "%s", spaces(offset)
if (field_alldistfiles){
printf "%s\n", get_alldistfiles($i)
}else{
printf "%s\n", $i
}
}
prev_field = field
next
}else if (field in special) {
if (field != prev_field) {
accu = accu field ":\n"
printf "%s:\n", field
}
accu = accu " "
printf " %s\n", $0
}else{
accu = accu field ":"
if ($0 !~ /^( |\t)*$/)
accu = accu spaces(offset - length(field) - 1)
printf "%s:%s%s\n", field, spaces(offset - length(field) - 1), $0
}
#
prev_field = field
}
{
accu = accu $0 "\n"
if (to_be_printed){
printf "%s", accu
accu = ""
}
}

View file

@ -42,8 +42,7 @@ OPTIONS:
-h|--help display this help message
-f|--file <filename> obtain package names from
a specified file, - for stdin
-i|--fields <filename>
-i|--fields=<filename> list of fields (separated by space character
-i|--fields <fields> list of fields (separated by space character
or comma) to be included to the summary,
full summary is generated by default
EOF
@ -51,46 +50,15 @@ EOF
pkgs_fn=''
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-f=*)
printf '%s\n' '-f= is not allowed' 1>&2
exit 1;;
-i=*)
printf '%s\n' '-f= is not allowed' 1>&2
exit 1;;
-f|--file)
pkgs_fn="$2"
shift;;
--file=*)
pkgs_fn="`printf '%s\n' \"$1\" | sed 's,^[^=]*=,,'`";;
-f*)
pkgs_fn="`printf '%s\n' \"$1\" | cut -b3-`";;
-i|--fields)
fields="-f '$2'"
shift;;
--fields=*)
fields="-f '`echo $1 | cut -f2 -d=`'";;
-i*)
fields="-f '`printf '%s\n' \"$1\" | cut -b 3-`'";;
--)
shift
break;;
-*)
echo "Bad option $1" 1>&2
exit 1;;
*)
break
esac
shift
done
process_args (){
alt_getopt \
'h help' 'usage; exit 0' \
'=f file' pkgs_fn= \
'=i fields' fields= \
-- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
if test $# -ne 1; then
usage

View file

@ -38,24 +38,14 @@ EOF
}
refresh=cat
while test $# -ne 0; do
case "$1" in
-h|--help)
usage
exit 0;;
-r|--refresh)
refresh=pkg_refresh_summary;;
--)
shift
break;;
-*)
echo "Bad option $1" 1>&2
exit 1;;
*)
break
esac
shift
done
process_args (){
alt_getopt \
'h help' 'usage; exit 0' \
'r refresh' 'refresh=pkg_refresh_summary' \
-- "$@"
}
cmds=`process_args "$@"`
eval "$cmds"
PKG_SUFX=${PKG_SUFX:=@PKG_SUFX@}
PKG_SUFX_RE="`echo $PKG_SUFX | sed 's,[.],[.],g'`"

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1 +1 @@
VERSION= 0.42.2
VERSION= 0.43.0