Subject: pkg_notify patch
To: None <tech-pkg@netbsd.org>
From: Bedis <bedis@bedis.eu>
List: tech-pkg
Date: 08/13/2006 22:31:56
--s/l3CgOIzMHHjg/5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi all
I worked on pkg_notify to fix some bugs.
You'll find in attachment a patch.
The main problem was that sometimes pkg_notify was wrong sometimes
because it had some problems to determine which development branch to
compare the pkgsrc package.
ie: www/apache2 is in fact the branch 2.0 of apache development, if
pkg_notify compared the package to the 2.0 branch, it compared to 2.2
branch too.
Now, we can ask to pkg_notify to limit the comparison to an unique
branch:
- on the command line: pkg_notify -b 2.0 www/apache2
- in the /usr/pkg/etc/pkg_notify.list by a line like:
www/apache2;branch=2.0
I'll appreciate your returns about that.
bedis
--s/l3CgOIzMHHjg/5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pkg_notify.patch"
--- pkg_notify.orig 2006-08-13 21:48:40.000000000 +0200
+++ pkg_notify 2006-08-07 23:27:48.000000000 +0200
@@ -16,11 +16,12 @@
#
# $ pkg_notify category/package
#
-# $Id: pkg_notify,v 1.20 2005/01/05 13:36:23 imil Exp $
+# $Id: pkg_notify,v 1.4 2006/08/07 21:27:48 bedis Exp $
use Net::FTP;
use LWP::UserAgent;
use HTTP::Request::Common;
+use Getopt::Std;
use strict;
@@ -33,6 +34,12 @@
################################################################################
+# Options
+our($opt_b, $opt_c, $opt_h);
+$opt_b = $opt_c = "";
+$opt_h = 0;
+my $branch = 0;
+
my $extract_sufx = "";
my $distname = "";
my $pkgname = "";
@@ -54,6 +61,18 @@
# create an alpha to num mapping
my %alnum = map { $_ => ord($_) - ord('a') + 1 } ('a' .. 'z');
+# Print help!
+sub print_help {
+ my $basename = `basename $0`;
+ chomp $basename;
+ print <<EOF
+Usage:
+ $basename [-h] [-c /path/to/conf_file]
+Or
+ $basename [-b branch] category/package
+EOF
+}
+
sub dot_strip {
my $out = $_[0];
# clean extremities from dots
@@ -108,6 +127,10 @@
}
sub is_beta {
+ # If date, not considered as beta
+ if ($_[0] =~ /[0-9]{4}[0-1][0-9][0-3][0-9]/) {
+ return (0);
+ }
if ($_[0] =~ /00[0-9]+00/) {
return (1);
}
@@ -190,53 +213,61 @@
my @pkg_version = split(/[\.\-_]/, $version);
my @ls_version = split(/[\.\-_]/, $lsvers);
- my $i = 0;
- foreach (@ls_version) {
-
- # package version has this member
- if (defined($pkg_version[$i])) {
-
- my $member = $_;
+ # 2 solutions:
+ # - we didn't specify a branch number
+ # - we specified a branch number and we compare it to lsvers
+ if ((!$branch) or
+ (($branch) and ($branch eq substr($lsvers, 0, length($branch))))) {
+
+ my $i = 0;
+ foreach (@ls_version) {
+
+ # package version has this member
+ if (defined($pkg_version[$i])) {
+
+ my $member = $_;
+
+ # empty member
+ if ($member =~ /^$/) {
+ last;
+ }
+ # archive version has non-num in it, can't compare
+ if ($member =~ /[^0-9]/) {
+ last;
+ }
+ # is this member greater that pkg_version equiv ?
+ if ($member > $pkg_version[$i]) {
+ # if member is beta, version is >
+ if (is_beta($member) &&
+ !is_beta($pkg_version[$i])) {
+ last;
+ }
+ $greater = 1;
+ last;
+ }
- # empty member
- if ($member =~ /^$/) {
- last;
- }
- # archive version has non-num in it, can't compare
- if ($member =~ /[^0-9]/) {
- last;
- }
- # is this member greater that pkg_version equiv ?
- if ($member > $pkg_version[$i]) {
- # if member is beta, version is >
- if (is_beta($member) &&
- !is_beta($pkg_version[$i])) {
- last;
+ # local package has a superior version, end
+ if ($pkg_version[$i] > $member) {
+ # if version is beta, member is >
+ if (!is_beta($member) &&
+ is_beta($pkg_version[$i])) {
+ $greater = 1;
+ }
+ last;
}
- $greater = 1;
- last;
- }
- # local package has a superior version, end
- if ($pkg_version[$i] > $member) {
- # if version is beta, member is >
- if (!is_beta($member) &&
- is_beta($pkg_version[$i])) {
+ } else { # package version don't have this sub-number
+ if (!is_beta($_)) { # avoid beta versions
+ # aka 1.1.1beta !> 1.1.1
$greater = 1;
}
last;
}
- } else { # package version don't have this sub-number
- if (!is_beta($_)) { # avoid beta versions
- # aka 1.1.1beta !> 1.1.1
- $greater = 1;
- }
- last;
- }
-
- $i++; # increment version member
- } # foreach
+ $i++; # increment version member
+ } # foreach
+
+ } # check branch
}
if ($nicearc == 0) { # not a nice distname
@@ -446,6 +477,16 @@
my @packages;
+# manage command line options
+getopts('b:c:h');
+$branch = $opt_b;
+$conf = $opt_c;
+
+if ($opt_h) {
+ print_help();
+ exit 0;
+}
+
if ($#ARGV > -1) {
@packages = @ARGV;
} else {
@@ -498,14 +539,27 @@
next;
}
+ # Remove spaces characters
+ s/\s//g;
+
my $pkg = $_;
my $master_site;
+
+ # check if we have to compare $pkg
+ # against a specific branch
+ if ($pkg =~ m/(.*);branch=(.*)$/) {
+ $pkg = $1;
+ $branch = $2;
+ }
$pkgpath = "$pkgsrcbase/$pkg/";
+ if (!-d $pkgpath) {
+ die "Error: $pkgpath is not a directory!!!\n";
+ }
+
$pkgname = `cd $pkgpath && $make show-var VARNAME=PKGNAME`;
chomp($pkgname);
-
$pkgversion = $pkgname;
$pkgversion =~ s/(.+)\-([0-9a-z_\.]+)$/$2/;
$pkgname = $1;
--s/l3CgOIzMHHjg/5--