2008-04-05 12:14:15 +02:00
|
|
|
#!/usr/bin/env runawk
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
|
2009-05-10 15:44:00 +02:00
|
|
|
#env "LC_ALL=C"
|
|
|
|
|
2008-04-05 12:14:15 +02:00
|
|
|
#use "pkgsrc-dewey.awk"
|
2009-05-10 15:44:00 +02:00
|
|
|
#use "power_getopt.awk"
|
2008-04-05 12:14:15 +02:00
|
|
|
|
|
|
|
############################################################
|
2009-05-10 15:44:00 +02:00
|
|
|
#.begin-str help
|
|
|
|
# pkg_cmp_summary - compares two summary files
|
|
|
|
# usage: pkg_cmp_summary -h
|
|
|
|
# pkg_cmp_summary [OPTIONS] summary1 summary2
|
|
|
|
# OPTIONS:
|
|
|
|
# -h|--help display this help
|
|
|
|
# -p|--with-pkgpath use PKGPATH:PKGBASE pair for identifing a package
|
|
|
|
# -c|--use-checksum also use CVS_CHECKSUM field in comparing packages
|
|
|
|
# -m|--multi support multi-variant packages, that is packages
|
|
|
|
# with building options in PKGPATH section
|
|
|
|
# -P|--pkgpath use PKGPATH only for comparison, ignore PKGNAME
|
|
|
|
#.end-str
|
|
|
|
############################################################
|
2008-04-05 12:14:15 +02:00
|
|
|
|
|
|
|
BEGIN {
|
2008-12-26 18:10:23 +01:00
|
|
|
with_pkgname = 1
|
|
|
|
|
2009-05-10 15:44:00 +02:00
|
|
|
with_pkgpath = getarg("p")
|
|
|
|
use_checksum = getarg("c")
|
|
|
|
if (getarg("P")){
|
|
|
|
with_pkgpath = 1
|
|
|
|
with_pkgname = 0
|
|
|
|
}
|
|
|
|
if (getarg("m")){
|
|
|
|
with_multivar = 1
|
|
|
|
with_pkgpath = 1
|
2008-04-05 12:14:15 +02:00
|
|
|
}
|
|
|
|
|
2008-12-25 23:31:48 +01:00
|
|
|
for (ind=1; ind < ARGC && ARGV [ind] == ""; ++ind);
|
|
|
|
|
|
|
|
if (ARGC != ind+2){
|
2008-06-14 09:41:36 +02:00
|
|
|
usage()
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2008-12-25 23:31:48 +01:00
|
|
|
file1 = ARGV [ind]
|
2008-04-05 12:14:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function trim (s){
|
|
|
|
sub(/^[ \t]+/, "", s)
|
|
|
|
sub(/[ \t]+$/, "", s)
|
|
|
|
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2008-12-26 18:10:23 +01:00
|
|
|
with_pkgname && $0 ~ /^PKGNAME=/ {
|
2008-04-05 12:14:15 +02:00
|
|
|
pkgname = trim(substr($0, 9))
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:41:36 +02:00
|
|
|
use_checksum && $0 ~ /^CVS_CHECKSUM=/ {
|
|
|
|
checksum = trim(substr($0, 14))
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
2008-04-05 12:14:15 +02:00
|
|
|
with_pkgpath && $0 ~ /^PKGPATH=/ {
|
|
|
|
pkgpath = trim(substr($0, 9))
|
2008-09-07 18:53:32 +02:00
|
|
|
full_pkgpath = pkgpath
|
|
|
|
if (with_multivar && pkgpath ~ /:/){
|
|
|
|
sub(/:.*$/, "", pkgpath)
|
|
|
|
}
|
2008-04-05 12:14:15 +02:00
|
|
|
next
|
|
|
|
}
|
|
|
|
|
|
|
|
NF == 0 {
|
|
|
|
# ver
|
|
|
|
ver = pkgname
|
|
|
|
sub(/^.*-/, "", ver)
|
|
|
|
|
|
|
|
# pkgbase
|
2008-09-07 18:53:32 +02:00
|
|
|
sub(/-[^-]+$/, "", pkgname)
|
|
|
|
|
|
|
|
# option PKGPATH
|
2008-12-26 18:10:23 +01:00
|
|
|
if (with_pkgpath && with_pkgname){
|
2008-09-07 18:53:32 +02:00
|
|
|
pkgbase = pkgpath " " pkgname
|
|
|
|
full_pkgbase = full_pkgpath " " pkgname
|
2008-12-26 18:10:23 +01:00
|
|
|
}else if (with_pkgpath){
|
|
|
|
pkgbase = pkgpath
|
|
|
|
full_pkgbase = full_pkgpath
|
2008-09-07 18:53:32 +02:00
|
|
|
}else{
|
|
|
|
pkgbase = pkgname
|
|
|
|
full_pkgbase = pkgname
|
|
|
|
}
|
2008-04-05 12:14:15 +02:00
|
|
|
|
2008-06-14 09:41:36 +02:00
|
|
|
# current checksum
|
|
|
|
curr_checksum = checksum
|
|
|
|
|
|
|
|
# cleaning...
|
|
|
|
pkgname = pkgpath = checksum = ""
|
|
|
|
|
2008-04-05 12:14:15 +02:00
|
|
|
#
|
|
|
|
if (FILENAME == file1){
|
|
|
|
# first file!
|
|
|
|
if (pkgbase in names){
|
2008-05-09 22:56:18 +02:00
|
|
|
duplicates [pkgbase] += 1
|
2008-04-05 12:14:15 +02:00
|
|
|
}else{
|
|
|
|
names [pkgbase] = ver
|
2008-09-07 18:53:32 +02:00
|
|
|
if (with_multivar && pkgpath != full_pkgpath){
|
|
|
|
full_pkgpaths [pkgbase] = full_pkgbase
|
|
|
|
}
|
2008-06-14 09:41:36 +02:00
|
|
|
|
|
|
|
if (use_checksum){
|
|
|
|
checksums [pkgbase] = curr_checksum
|
|
|
|
}
|
2008-04-05 12:14:15 +02:00
|
|
|
}
|
|
|
|
}else{
|
2008-05-09 22:56:18 +02:00
|
|
|
# second file!
|
2008-04-05 12:14:15 +02:00
|
|
|
present [pkgbase] = 0
|
|
|
|
|
|
|
|
if (pkgbase in duplicates){
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! (pkgbase in names)){
|
2008-12-26 18:10:23 +01:00
|
|
|
if (ver != "")
|
|
|
|
print "+", full_pkgbase, ver
|
|
|
|
else
|
|
|
|
print "+", full_pkgbase
|
2008-09-07 18:53:32 +02:00
|
|
|
|
2008-04-05 12:14:15 +02:00
|
|
|
next
|
|
|
|
}
|
|
|
|
|
2008-12-26 18:10:23 +01:00
|
|
|
if (with_pkgname){
|
|
|
|
ver1 = names [pkgbase]
|
|
|
|
res = dewey_cmp(ver1, ver)
|
|
|
|
|
|
|
|
if (use_checksum && res == "="){
|
|
|
|
prev_checksum = checksums [pkgbase]
|
|
|
|
if (prev_checksum != "" &&
|
|
|
|
curr_checksum != "" &&
|
|
|
|
prev_checksum != curr_checksum)
|
|
|
|
{
|
|
|
|
res = "!"
|
|
|
|
}
|
2008-06-14 09:41:36 +02:00
|
|
|
}
|
|
|
|
|
2008-12-26 18:10:23 +01:00
|
|
|
print res, full_pkgbase, ver1, ver
|
|
|
|
}else{
|
|
|
|
print "=", full_pkgbase
|
|
|
|
}
|
2008-04-05 12:14:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
for (pkgbase in names){
|
|
|
|
if (! (pkgbase in present)){
|
2008-12-26 18:10:23 +01:00
|
|
|
if (names [pkgbase] != ""){
|
|
|
|
nm = " " names [pkgbase]
|
|
|
|
}else{
|
|
|
|
nm = ""
|
|
|
|
}
|
|
|
|
|
2008-09-07 18:53:32 +02:00
|
|
|
if (pkgbase in full_pkgpaths)
|
2008-12-26 18:10:23 +01:00
|
|
|
print "-", full_pkgpaths [pkgbase] nm
|
2008-09-07 18:53:32 +02:00
|
|
|
else
|
2008-12-26 18:10:23 +01:00
|
|
|
print "-", pkgbase nm
|
2008-09-07 18:53:32 +02:00
|
|
|
|
2008-04-05 12:14:15 +02:00
|
|
|
delete duplicates [pkgbase]
|
|
|
|
}else if (pkgbase in duplicates){
|
2008-05-09 22:56:18 +02:00
|
|
|
print duplicates [pkgbase]+1, pkgbase
|
2008-04-05 12:14:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|