pkgsrc-wip/pkg_summary-utils/files/pkg_summary2bb_pkgs.in
Aleksey Cheusov e8e3b59703 Update to 0.38.0
New mega tool -- pkg_subgraph_deps!

  pkg_src_summary:
    - Fix in adding ASSIGNMENTS inside DEPENDS and BUILD_DEPENDS.
    - Portions of this script were separated into individual scripts under
      libexec/ subdirectory.
    - Improvements for -G
    - New implementation for -A + -m. Speed-ups. Clean-ups.

  pkg_summary2deps:
    - FIX: no double removal of -version anymore.

  pkg_summary2bb_pkgs:
    - FIX: do not output two packages with the same PKGNAME if they
      both have non-empty ASSIGNMENTS, e.g
      net/nicotine:PYTHON_VERSION_REQD={24,25}

  Updates in manual pages.

  More regresion tests.

  Makefile:
    - Overridable DIFF_PROG that defaults to "diff -U10"
2010-05-01 21:06:44 +00:00

166 lines
3.5 KiB
Text
Executable file

#!/usr/bin/env runawk
# Copyright (c) 2008-2009 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.
############################################################
#env "LC_ALL=C"
#use "alt_getopt.awk"
#use "abort.awk"
#use "xgetline.awk"
#use "xclose.awk"
#use "min.awk"
#use "power_getopt.awk"
############################################################
#.begin-str help
# pkg_summary2bb_pkgs - extracts summaries for packages
# ready for bulk build (bb in the script name).
# That is, summaries for packages with not empty ASSIGNMENTS
# are removed if their PKGNAME (binary package basename) do not depend
# on ASSIGNMENTS.
# Input summary must be pkg_uniq_summary'ed!
# Duplications on input are not allowed
# usage: pkg_summary2bb_pkgs -h
# pkg_summary2bb_pkgs [OPTIONS] file1 [file2...]
# OPTIONS:
# -h|--help display this help
#.end-str
############################################################
BEGIN {
# find problematic packages
for (i=1; i < ARGC; ++i){
if (ARGV [i] == "") continue
while (xgetline0(ARGV [i])){
if ($0 ~ /^PKGNAME=/){
pkgname = substr($0, 9)
++conflicts [pkgname]
}else if ($0 ~ /^ASSIGNMENTS=/){
assigns = substr($0, 13)
}else if (match($0, /^PKGPATH=.*:/)) {
assigns = substr($0, RLENGTH+1)
# update()
}else if (NF == 0){
commas = assigns != "" ? 1+gsub(/,/, "", assigns) : 0
if (pkgname in cnt)
cnt [pkgname] = min(cnt [pkgname] + 0, commas + 0)
else
cnt [pkgname] = commas
assigns = pkgname = ""
}
}
xclose(ARGV [i])
}
# init
pkgname = assigns = ""
good_pkg = 0 # -1|0|1 - bad|unknown|good
count = 0
}
function print_lines (){
for (i=0; i < count; ++i){
print lines [i]
}
count = 0
}
NF == 0 {
if (good_pkg == 0){
assert(assigns == "")
good_pkg = 1
}
if (good_pkg == 1){
print_lines()
print ""
}
pkgname = assigns = ""
good_pkg = 0
count = 0
next
}
good_pkg == 1 {
print $0
next
}
good_pkg == -1 {
next
}
{
lines [count++] = $0
}
function update (){
if (pkgname == ""){
return
}
if (conflicts [pkgname] < 2){
print_lines()
good_pkg = 1
return
}
if (assigns == ""){
return
}
if (gsub(/,/, "", assigns)+1 == cnt [pkgname]){
print_lines()
good_pkg = 1
cnt [pkgname] = -1
return
}
good_pkg = -1
count = 0
}
$0 ~ /^PKGNAME=/ {
pkgname = substr($0, 9)
update()
next
}
$0 ~ /^ASSIGNMENTS=/ {
assigns = substr($0, 13)
update()
next
}
match($0, /^PKGPATH=.*:/) {
assigns = substr($0, RLENGTH+1)
update()
next
}