pkgsrc-wip/pkg_summary-utils/files/pkg_summary4view

116 lines
2.4 KiB
Text
Raw Normal View History

#!/usr/bin/awk -f
# Copyright (c) 2007-2008 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
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function spaces (n, ret){
ret = ""
while (n-- > 0){
ret = ret " "
}
return ret
}
BEGIN {
special ["DESCRIPTION"] = 0
special ["PLIST"] = 0
special ["PROVIDES"] = 0
special ["REQUIRES"] = 0
depends_like ["BUILD_DEPENDS"] = 0
depends_like ["DEPENDS"] = 0
depends_like ["CONFLICTS"] = 0
offset = 16
}
NF == 0 {
print
last_field = ""
printf "%s", accu
accu = ""
to_be_printed = 0
next
}
/^PKGNAME=/ {
print "-----------------------------------------------------------"
to_be_printed = 1
}
{
#
field = $0
sub(/=.*$/, "", field)
#
sub(/^[^=]*=/, "")
if (NF == 0){
prev_field = field
next
}
#
if (field in depends_like){
if (field != prev_field) {
field1 = field ":"
accu = accu field1
}else{
field1 = ""
}
if (NF > 0)
accu = accu spaces(offset - length(field1))
accu = accu $1 "\n"
for (i=2; i <= NF; ++i){
accu = accu spaces(offset)
accu = accu $i "\n"
}
prev_field = field
next
}else if (field in special) {
if (field != prev_field) {
accu = accu field ":\n"
}
accu = accu " "
}else{
accu = accu field ":"
if ($0 !~ /^( |\t)*$/)
accu = accu spaces(offset - length(field) - 1)
}
#
prev_field = field
}
{
accu = accu $0 "\n"
if (to_be_printed){
printf "%s", accu
accu = ""
}
}