aboutsummaryrefslogtreecommitdiffstats
path: root/ports-mgmt/portupdate-scan
diff options
context:
space:
mode:
authormilki <milki@FreeBSD.org>2014-06-04 23:42:35 +0800
committermilki <milki@FreeBSD.org>2014-06-04 23:42:35 +0800
commitedd3de7fd7e544090b8bf1d34dac81a477538eb4 (patch)
tree54b530fdfc19e330b6fa36c58f6b755441c693b9 /ports-mgmt/portupdate-scan
parent0c88828fd13de082a536cb58cb29c70d1274af68 (diff)
downloadfreebsd-ports-gnome-edd3de7fd7e544090b8bf1d34dac81a477538eb4.tar.gz
freebsd-ports-gnome-edd3de7fd7e544090b8bf1d34dac81a477538eb4.tar.zst
freebsd-ports-gnome-edd3de7fd7e544090b8bf1d34dac81a477538eb4.zip
Update ports-mgmt/portupdate-scan to 0.4
- Add support for pkgng. - ISCL License - Incorporates -a argument suggested by Marcel Bonnet in PR 179637. Hence this supersedes PR 179637, which can now be closed. - Other misc. fixes and enhancements, including correcting typos. PR: 190051 Submitted by: alex@stangl.us Approved by: swills (eadler)
Diffstat (limited to 'ports-mgmt/portupdate-scan')
-rw-r--r--ports-mgmt/portupdate-scan/Makefile4
-rw-r--r--ports-mgmt/portupdate-scan/pkg-descr2
-rw-r--r--ports-mgmt/portupdate-scan/src/portupdate-scan71
-rw-r--r--ports-mgmt/portupdate-scan/src/portupdate-scan.85
4 files changed, 56 insertions, 26 deletions
diff --git a/ports-mgmt/portupdate-scan/Makefile b/ports-mgmt/portupdate-scan/Makefile
index 5713ea40b970..b6dc3a190cba 100644
--- a/ports-mgmt/portupdate-scan/Makefile
+++ b/ports-mgmt/portupdate-scan/Makefile
@@ -2,7 +2,7 @@
# $FreeBSD$
PORTNAME= portupdate-scan
-PORTVERSION= 0.3
+PORTVERSION= 0.4
CATEGORIES= ports-mgmt
MASTER_SITES= # none
DISTFILES= # none
@@ -10,6 +10,8 @@ DISTFILES= # none
MAINTAINER= alex@stangl.us
COMMENT= Display pertinent parts of {PORTSDIR}/UPDATING
+LICENSE= ISCL
+
NO_BUILD= yes
USES= perl5 shebangfix
USE_PERL5= run
diff --git a/ports-mgmt/portupdate-scan/pkg-descr b/ports-mgmt/portupdate-scan/pkg-descr
index cfcc65b820c0..95632b72c04d 100644
--- a/ports-mgmt/portupdate-scan/pkg-descr
+++ b/ports-mgmt/portupdate-scan/pkg-descr
@@ -4,7 +4,7 @@ many ports installed that it is difficult to know which sections are relevant.
It reads /usr/ports/UPDATING, attempting for each block to determine whether
the affected ports are installed. It omits blocks that do not apply.
It handles wildcards and other special cases, however it cannot handle
-all variants of phrases used on the APPLIES: line.
+all variants of phrases used on the AFFECTS: line.
In uncertain cases, it errs on the side of reporting.
Alex Stangl <alex@stangl.us>
diff --git a/ports-mgmt/portupdate-scan/src/portupdate-scan b/ports-mgmt/portupdate-scan/src/portupdate-scan
index 51b8c87bd643..ce866a8b7a86 100644
--- a/ports-mgmt/portupdate-scan/src/portupdate-scan
+++ b/ports-mgmt/portupdate-scan/src/portupdate-scan
@@ -17,10 +17,7 @@
# Check /usr/ports/UPDATING file for all sections matching packages
# that are installed, and outputting those sections.
# Intended to be used prior to upgrading ports
-# Usage: portupdatescan [-dDhmuvV] [--help] [--version]
-# Created: 2006/12/21 Alex Stangl
-# Updates: 2008/02/04 Alex Stangl INDEX computation change from Tom Doherty
-# 2008/07/21 Alex Stangl Tolerate problems w/ MOVED & UPDATING
+# Usage: portupdatescan [-dhmuvV] [-a yyyymmdd_date] [-D portsdir] [--help] [--version]
use Text::ParseWords;
use Getopt::Std;
@@ -29,7 +26,8 @@ use strict;
# Display usage and exit
sub HELP_MESSAGE() {
print <<EOF;
-Usage: portupdate-scan [-dhmuvV] [-D portsdir] [--help] [--version]
+Usage: portupdate-scan [-dhmuvV] [-a yyyymmdd_date] [-D portsdir] [--help] [--version]
+ -a display sections later than date specified in YYYYMMDD format
-d display additional debugging info
-D portsdir override default port directory
-h, --help display this help and exit
@@ -42,25 +40,34 @@ EOF
}
sub VERSION_MESSAGE() {
- print "portupdate-scan 0.3\n";
+ print "portupdate-scan 0.4\n";
}
# Fetch cmdline args, display usage if appropriate
$Getopt::Std::STANDARD_HELP_VERSION=1; # std, not paranoia behavior
# our($opt_d, $opt_h, $opt_m, $opt_u, $opt_v, $opt_V);
my %opt; # map of command-line options
-HELP_MESSAGE() unless getopts("dD:hmuvV", \%opt);
+HELP_MESSAGE() unless getopts("dD:hmuvVa:", \%opt);
HELP_MESSAGE() if $opt{h};
VERSION_MESSAGE() && exit if $opt{V};
+my $afterDate = $opt{a}; # display sections later than this date
my $portsdir = $opt{D} || "/usr/ports"; # ports directory
my $portIndexFile = "$portsdir/" . `make -f $portsdir/Makefile -V INDEXFILE`; # port index file
+print "+ portIndexFile = $portIndexFile\n" if $opt{d};
+
+# Auto-detect whether PKGNG is in use.
+`env TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexistent pkg info -x 'pkg(-devel)?\$' >/dev/null 2>&1`;
+my $pkgngInUse = !$?;
+print "+ PKGNG in use\n" if $opt{d} && $pkgngInUse;
+print "+ Legacy PKG manager in use\n" if $opt{d} && !$pkgngInUse;
+
my $movedFile = "$portsdir/MOVED"; # file w/ port renames/deletes
my $updatingFile = "$portsdir/UPDATING"; # file w/ ports update news
-my @portlist = `pkg_info -aoq`
- or die "Error trying to execute pkg_info -aoq: $!";
+my @portlist = $pkgngInUse ? `pkg info -aoq` : `pkg_info -aoq`
+ or die "Error trying to execute pkg info -aoq: $!";
my %installedPorts =
map {chomp($_);$_, 1} @portlist; # map of installed ports -> 1
@@ -83,10 +90,10 @@ sub processBlock(@) {
my ($affects, $remainder, $line);
my $index = 0;
foreach $line (@_) {
- if ($line =~ /^\s*AFFECTS:/i) {
+ if ($line =~ /^\s*AFFECTS:/i) {
$affects = $line;
$remainder = $index;
- } elsif ($affects and $line =~ /^\s*AUTHOR/i) {
+ } elsif ($affects and $line =~ /^\s*AUTHOR/i) {
last;
} elsif ($affects) {
$affects .= $line;
@@ -132,8 +139,7 @@ sub parseexpr($); # forward declaration needed because of recursion
sub parseexpr($) {
my @retval;
my $sepExp = "(,\\s+and\\s+|,\\s+or\\s+|,\\s+|\\s+and\\s+|\\s+or\\s+|\\s+)";
- if ($_[0] =~ /{.*,.*}/)
- {
+ if ($_[0] =~ /{.*,.*}/) {
# Handle expression like textproc/{senna,p5-Senna}
# to produce textproc/senna, textproc/p5-Senna
my ($prefix, $subexpr, $suffix) = ($_[0] =~ /([^{]*){([^}]*)}(.*)/);
@@ -145,6 +151,18 @@ sub parseexpr($) {
foreach $line (@exprs) {
push @retval, parseexpr($prefix . $line . $suffix);
}
+ } elsif ($_[0] =~ /{.*\|.*}/) {
+ # Handle expression like textproc/{senna|p5-Senna}
+ # to produce textproc/senna, textproc/p5-Senna
+ my ($prefix, $subexpr, $suffix) = ($_[0] =~ /([^{]*){([^}]*)}(.*)/);
+
+ # Parse portname fragment contained within braces
+ # Breaks string at "|" and discards quotes and single backslashes
+ my @exprs = &quotewords('\|', 0, $subexpr);
+ my $line;
+ foreach $line (@exprs) {
+ push @retval, parseexpr($prefix . $line . $suffix);
+ }
} elsif ($_[0] =~ /\[\d{1,4}\]/) {
# Handle expressions like net/openldap2[34]-server
# to produce net/openldap23-server, net/openldap24-server
@@ -164,7 +182,7 @@ sub parseexpr($) {
# Handle "dir1/port1 and dir2/port2" recursively.
my ($prefix, $sep, $suffix) = ($_[0] =~ /(.*?)$sepExp(.*)/);
push @retval, parseexpr($prefix) if $prefix ne "";
- push @retval, parseexpr($suffix) if $suffix ne "";
+ push @retval, parseexpr($suffix) if $suffix ne "" and $suffix ne "any port that depends on it";
} elsif ($_[0] =~ /\*/ or $_[0] =~ /\?/) {
push @retval, expandwildcard($_[0]);
} else {
@@ -177,10 +195,12 @@ sub parseexpr($) {
# Parse a single AFFECTS: line
sub parseline($) {
- return ("ALL") if $_[0] =~ /^\s+AFFECTS:\s*everybody\s*$/i
- or $_[0] =~ /^\s+AFFECTS:\s*everyone\s*$/i
- or $_[0] =~ /^\s+AFFECTS:\s*all\s*$/i;
- if ($_[0] =~ s/.*([uU]sers|[tT]esters) of[ \t]*(.*)/$2/) {
+ if ($_[0] =~ s/^\s+AFFECTS:\s*(.*)/$1/) {
+ return ("ALL") if $_[0] =~ /^everybody\s*$/i
+ or $_[0] =~ /^everyone\s*$/i
+ or $_[0] =~ /^all users\s*$/i
+ or $_[0] =~ /^all\s*$/i;
+ $_[0] =~ s/.*([uU]sers|[tT]esters) of[ \t]*(.*)/$2/;
my @retval = parseexpr($_[0]);
print "+ parseline returns @retval for $_[0]\n" if $opt{d};
return @retval;
@@ -210,7 +230,7 @@ sub expandwildcard($) {
return @retval;
}
-# Convert glob-style pattern to standard regular-expression pattern
+# Convert glob-style pattern to standard regex pattern
sub glob2pat($) {
(my $globstr = $_[0]) =~ s/(.)/$glob2regexp{$1} || "\Q$1"/ge;
return '^' . $globstr . '$';
@@ -303,7 +323,7 @@ sub printall(@) {
# Main entry point. First, open INDEX and read all ports into allPorts
MAIN:{
- open(IDX, $portIndexFile) or die "Can't open $portIndexFile: $!";
+ open(IDX, $portIndexFile) or die "Can't open $portIndexFile: $!. Maybe you should run make fetchindex or make index from ports directory";
while(<IDX>) {
chomp;
my ($portLine) = ($_ =~ /^[^|]*\|\/usr\/ports\/([^|]*)/)
@@ -318,9 +338,9 @@ MAIN:{
open(MOVED, $movedFile) or die "Can't open $movedFile: $!";
while(<MOVED>) {
chomp;
- if ($_ =~ /^\s*$/) {
- print "+ Ignoring MOVED line containing no non-whitespace chars.\n" if $opt{d};
- } elsif ($_ !~ /^\s*#/) {
+ if ($_ =~ /^\s*$/) {
+ print "+ Ignoring MOVED line containing no non-whitespace chars.\n" if $opt{d};
+ } elsif ($_ !~ /^\s*#/) {
my ($from, $to) = ($_ =~ /^([^|]*)\|([^|]*)/)
or die "$_ is not a correctly formed MOVED line";
@@ -340,6 +360,11 @@ MAIN:{
open(UPD, $updatingFile) or die "Can't open $updatingFile: $!";
while(<UPD>) {
chomp;
+ if ($opt{a} && /^\d{8}/) {
+ my $sectionDate = $_;
+ $sectionDate =~ s/\://;
+ last if $sectionDate <= $afterDate;
+ }
if (/^\s*AFFECTS:/ && @bufferBlock > 0) {
processBlock(@bufferBlock);
@bufferBlock = ();
diff --git a/ports-mgmt/portupdate-scan/src/portupdate-scan.8 b/ports-mgmt/portupdate-scan/src/portupdate-scan.8
index 446b6d2d7131..0df73689e349 100644
--- a/ports-mgmt/portupdate-scan/src/portupdate-scan.8
+++ b/ports-mgmt/portupdate-scan/src/portupdate-scan.8
@@ -22,6 +22,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl dhmuVv
+.Op Fl a Ar yyyymmdd date
.Op Fl D Ar portdir
.Op Fl -help
.Op Fl -version
@@ -33,6 +34,8 @@ installed are omitted.
.Pp
The following options are available:
.Bl -tag -width indent
+.It Fl a Ar yyyymmdd date
+only display sections later than the date specified in yyyymmdd format
.It Fl D Ar portsdir
use portsdir as ports directory instead of /usr/ports
.It Fl d
@@ -72,6 +75,6 @@ To include details of installed/uninstalled ports for MIXED sections:
.Sh AUTHORS
.An "Alex Stangl" Aq alex@stangl.us
.Sh BUGS
-The concept of machine-interpreting the APPLIES: line in /usr/ports/UPDATING,
+The concept of machine-interpreting the AFFECTS: line in /usr/ports/UPDATING,
which were intended for human consumption, is dubious. It would be nice to
evolve some more robust method for communicating this information.