pkg_version.pl now understands the new package/port numbering scheme
introduced by version 1.349 of ports/Mk/bsd.port.mk and originally submitted by kris. In particular, it understands the $PORTREVISION (FreeBSD-specific changes or patches to a port) and $PORTEPOCH (for re-sorting version numbers when not used or when broken).
This commit is contained in:
parent
b5350bb3a5
commit
f974d44667
@ -50,13 +50,13 @@ $CommentChar = "#";
|
|||||||
$LimitFlag = "";
|
$LimitFlag = "";
|
||||||
|
|
||||||
#
|
#
|
||||||
# CompareVersions
|
# CompareNumbers
|
||||||
#
|
#
|
||||||
# Try to figure out the relationship between two program version numbers.
|
# Try to figure out the relationship between two program version numbers.
|
||||||
# Detecting equality is easy, but determining order is a little difficult.
|
# Detecting equality is easy, but determining order is a little difficult.
|
||||||
# This function returns -1, 0, or 1, in the same manner as <=> or cmp.
|
# This function returns -1, 0, or 1, in the same manner as <=> or cmp.
|
||||||
#
|
#
|
||||||
sub CompareVersions {
|
sub CompareNumbers {
|
||||||
local($v1, $v2);
|
local($v1, $v2);
|
||||||
$v1 = $_[0];
|
$v1 = $_[0];
|
||||||
$v2 = $_[1];
|
$v2 = $_[1];
|
||||||
@ -91,24 +91,95 @@ sub CompareVersions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# CompareVersions
|
||||||
|
#
|
||||||
|
# Try to figure out the relationship between two program "full
|
||||||
|
# versions", which is defined as the
|
||||||
|
# ${PORTVERSION}[_${PORTREVISION}][,${PORTEPOCH}]
|
||||||
|
# part of a package's name.
|
||||||
|
#
|
||||||
|
# Key points: ${PORTEPOCH} supercedes ${PORTVERSION}
|
||||||
|
# supercedes ${PORTREVISION}. See the commit log for revision
|
||||||
|
# 1.349 of ports/Mk/bsd.port.mk for more information.
|
||||||
|
#
|
||||||
|
sub CompareVersions {
|
||||||
|
local($fv1, $fv2, $v1, $v2, $v1, $r2, $e1, $e2, $rc);
|
||||||
|
|
||||||
|
$fv1 = $_[0];
|
||||||
|
$fv2 = $_[1];
|
||||||
|
|
||||||
|
# Shortcut check for equality before invoking the parsing
|
||||||
|
# routines.
|
||||||
|
if ($fv1 eq $fv2) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
($v1, $r1, $e1) = &GetVersionComponents($fv1);
|
||||||
|
($v2, $r2, $e2) = &GetVersionComponents($fv2);
|
||||||
|
|
||||||
|
# Check epoch, port version, and port revision, in that
|
||||||
|
# order.
|
||||||
|
$rc = &CompareNumbers($e1, $e2);
|
||||||
|
if ($rc == 0) {
|
||||||
|
$rc = &CompareNumbers($v1, $v2);
|
||||||
|
if ($rc == 0) {
|
||||||
|
$rc = &CompareNumbers($r1, $r2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# GetVersionComponents
|
||||||
|
#
|
||||||
|
# Parse out the version number, revision number, and epoch number
|
||||||
|
# of a port's version string and return them as a three-element array.
|
||||||
|
#
|
||||||
|
# Syntax is: ${PORTVERSION}[_${PORTREVISION}][,${PORTEPOCH}]
|
||||||
|
#
|
||||||
|
sub GetVersionComponents {
|
||||||
|
local ($fullversion, $version, $revision, $epoch);
|
||||||
|
|
||||||
|
$fullversion = $_[0];
|
||||||
|
|
||||||
|
$fullversion =~ /([^_,]+)/;
|
||||||
|
$version = $1;
|
||||||
|
|
||||||
|
if ($fullversion =~ /_([^_,]+)/) {
|
||||||
|
$revision = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fullversion =~ /,([^_,]+)/) {
|
||||||
|
$epoch = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return($version, $revision, $epoch);
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# GetNameAndVersion
|
# GetNameAndVersion
|
||||||
#
|
#
|
||||||
# Get the name and version number of a package. Returns a two element
|
# Get the name and version number of a package. Returns a two element
|
||||||
# array, first element is name, second element is version number.
|
# array, first element is name, second element is full version string.,
|
||||||
#
|
#
|
||||||
sub GetNameAndVersion {
|
sub GetNameAndVersion {
|
||||||
local($string);
|
local($fullname, $name, $fullversion);
|
||||||
$string = $_[0];
|
$fullname = $_[0];
|
||||||
|
|
||||||
# If no hyphens then no version number
|
# If no hyphens then no version numbers
|
||||||
return ($string, "") if $string !~ /-/;
|
return ($fullname, "", "", "", "") if $fullname !~ /-/;
|
||||||
|
|
||||||
# Match (and group) everything in between two hyphens. Because the
|
# Match (and group) everything after hyphen(s). Because the
|
||||||
# regexp is 'greedy', the first .* will try and match everything up
|
# regexp is 'greedy', the first .* will try and match everything up
|
||||||
# to (but not including) the last hyphen
|
# to (but not including) the last hyphen
|
||||||
$string =~ /(.*)-(.*)/;
|
$fullname =~ /(.+)-(.+)/;
|
||||||
return ($1, $2);
|
$name = $1;
|
||||||
|
$fullversion = $2;
|
||||||
|
|
||||||
|
return ($name, $fullversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -179,13 +250,14 @@ if ($DebugFlag) {
|
|||||||
open CURRENT, "$CurrentPackagesCommand|";
|
open CURRENT, "$CurrentPackagesCommand|";
|
||||||
while (<CURRENT>) {
|
while (<CURRENT>) {
|
||||||
($packageString, $rest) = split;
|
($packageString, $rest) = split;
|
||||||
($packageName, $packageVersion) = &GetNameAndVersion($packageString);
|
|
||||||
|
($packageName, $packageFullversion) = &GetNameAndVersion($packageString);
|
||||||
$currentPackages{$packageName}{'name'} = $packageName;
|
$currentPackages{$packageName}{'name'} = $packageName;
|
||||||
if (defined $currentPackages{$packageName}{'version'}) {
|
if (defined $currentPackages{$packageName}{'fullversion'}) {
|
||||||
$currentPackages{$packageName}{'version'} .= "," . $packageVersion;
|
$currentPackages{$packageName}{'fullversion'} .= "|" . $packageFullversion;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$currentPackages{$packageName}{'version'} = $packageVersion;
|
$currentPackages{$packageName}{'fullversion'} = $packageFullversion;
|
||||||
}
|
}
|
||||||
$currentPackages{$packageName}{'refcount'}++;
|
$currentPackages{$packageName}{'refcount'}++;
|
||||||
}
|
}
|
||||||
@ -198,14 +270,15 @@ if ($DebugFlag) {
|
|||||||
open INDEX, "$IndexPackagesCommand|";
|
open INDEX, "$IndexPackagesCommand|";
|
||||||
while (<INDEX>) {
|
while (<INDEX>) {
|
||||||
($packageString, $packagePath, $rest) = split(/\|/);
|
($packageString, $packagePath, $rest) = split(/\|/);
|
||||||
($packageName, $packageVersion) = &GetNameAndVersion($packageString);
|
|
||||||
|
($packageName, $packageFullversion) = &GetNameAndVersion($packageString);
|
||||||
$indexPackages{$packageName}{'name'} = $packageName;
|
$indexPackages{$packageName}{'name'} = $packageName;
|
||||||
$indexPackages{$packageName}{'path'} = $packagePath;
|
$indexPackages{$packageName}{'path'} = $packagePath;
|
||||||
if (defined $indexPackages{$packageName}{'version'}) {
|
if (defined $indexPackages{$packageName}{'fullversion'}) {
|
||||||
$indexPackages{$packageName}{'version'} .= "," . $packageVersion;
|
$indexPackages{$packageName}{'fullversion'} .= "|" . $packageFullversion;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$indexPackages{$packageName}{'version'} = $packageVersion;
|
$indexPackages{$packageName}{'fullversion'} = $packageFullversion;
|
||||||
}
|
}
|
||||||
$indexPackages{$packageName}{'refcount'}++;
|
$indexPackages{$packageName}{'refcount'}++;
|
||||||
}
|
}
|
||||||
@ -214,16 +287,24 @@ close INDEX;
|
|||||||
#
|
#
|
||||||
# Produce reports
|
# Produce reports
|
||||||
#
|
#
|
||||||
|
# Prior versions of pkg_version used commas (",") as delimiters
|
||||||
|
# when there were multiple versions of a package installed.
|
||||||
|
# The new package version number syntax uses commas as well,
|
||||||
|
# so we've used vertical bars ("|") internally, and convert them
|
||||||
|
# to commas before we output anything so the reports look the
|
||||||
|
# same as they did before.
|
||||||
|
#
|
||||||
foreach $packageName (sort keys %currentPackages) {
|
foreach $packageName (sort keys %currentPackages) {
|
||||||
$~ = "STDOUT_VERBOSE" if $VerboseFlag;
|
$~ = "STDOUT_VERBOSE" if $VerboseFlag;
|
||||||
$~ = "STDOUT_COMMANDS" if $ShowCommandsFlag;
|
$~ = "STDOUT_COMMANDS" if $ShowCommandsFlag;
|
||||||
|
|
||||||
$packageNameVer = "$packageName-$currentPackages{$packageName}{'version'}";
|
$packageNameVer = "$packageName-$currentPackages{$packageName}{'fullversion'}";
|
||||||
|
$packageNameVer =~ s/\|/,/g;
|
||||||
|
|
||||||
if (defined $indexPackages{$packageName}{'version'}) {
|
if (defined $indexPackages{$packageName}{'fullversion'}) {
|
||||||
|
|
||||||
$indexVersion = $indexPackages{$packageName}{'version'};
|
$indexVersion = $indexPackages{$packageName}{'fullversion'};
|
||||||
$currentVersion = $currentPackages{$packageName}{'version'};
|
$currentVersion = $currentPackages{$packageName}{'fullversion'};
|
||||||
|
|
||||||
$indexRefcount = $indexPackages{$packageName}{'refcount'};
|
$indexRefcount = $indexPackages{$packageName}{'refcount'};
|
||||||
$currentRefcount = $currentPackages{$packageName}{'refcount'};
|
$currentRefcount = $currentPackages{$packageName}{'refcount'};
|
||||||
@ -233,10 +314,14 @@ foreach $packageName (sort keys %currentPackages) {
|
|||||||
if (($indexRefcount > 1) || ($currentRefcount > 1)) {
|
if (($indexRefcount > 1) || ($currentRefcount > 1)) {
|
||||||
$versionCode = "?";
|
$versionCode = "?";
|
||||||
$Comment = "multiple versions (index has $indexVersion)";
|
$Comment = "multiple versions (index has $indexVersion)";
|
||||||
|
$Comment =~ s/\|/,/g;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$rc = &CompareVersions($currentVersion, $indexVersion);
|
# Do the comparison
|
||||||
|
$rc =
|
||||||
|
&CompareVersions($currentPackages{$packageName}{'fullversion'},
|
||||||
|
$indexPackages{$packageName}{'fullversion'});
|
||||||
|
|
||||||
if ($rc == 0) {
|
if ($rc == 0) {
|
||||||
next if $ShowCommandsFlag;
|
next if $ShowCommandsFlag;
|
||||||
@ -288,7 +373,7 @@ $packageName, $versionCode
|
|||||||
|
|
||||||
# Verbose report (-v flag)
|
# Verbose report (-v flag)
|
||||||
format STDOUT_VERBOSE =
|
format STDOUT_VERBOSE =
|
||||||
@<<<<<<<<<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
@<<<<<<<<<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||||
$packageNameVer, $versionCode, $Comment
|
$packageNameVer, $versionCode, $Comment
|
||||||
.
|
.
|
||||||
;
|
;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user