Brad wrote on Tue, Mar 11, 2008 at 05:59:06PM -0400:
> On Tuesday 11 March 2008 17:53:50 Jacob Meuser wrote:
>> I _hate_ it when I change a port locally and up the p level,
>> and then pkg_add -u downgrades that package.
Hmmm, the p-level is not ideal for keeping track of private tweaks,
imho it's better reserved for official, committed patch levels.
> ugh. that drives me crazy as well.
Try the following patch. It supports a "user patch level" (u-level)
in addition to the well-known p-level. p1u1 will be selected over
both p0u1 and p1u0, but in case p1u1 is missing, you will end up in
Interactive::choose1 to manually choose between p0u1 and p1u0 -
to choose what you prefer today, your latest private tweaks or the
latest official commit. Or perhaps you will interrupt, cvs up and
merge both in order to build p1u1.
Index: OpenBSD/PackageName.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackageName.pm,v
retrieving revision 1.31
diff -u -p -r1.31 PackageName.pm
--- OpenBSD/PackageName.pm 23 Aug 2007 09:09:16 -0000 1.31
+++ OpenBSD/PackageName.pm 13 Mar 2008 00:40:29 -0000
@@ -87,25 +87,17 @@ sub is_stem
sub splitp
{
local $_ = shift;
-
- if (/^(.*\-\d[^-]*)p(\d+)(.*)$/o) {
- return ($1.$3, $2);
- } else {
- return ($_,-1);
- }
+ m/^(.*?\-\d[^-puv]*)(?:p(\d+))?(?:u(\d+))?(.*)?$/o;
+ return $1 . (defined $4 ? $4 : ''),
+ [ (defined $2 ? $2 : -1), (defined $3 ? $3 : -1) ];
}
sub rebuildp
{
- my ($pkg, $p) = @_;
- if ($p == -1) {
- return $pkg;
- }
- if ($pkg =~ m/^(.*?)(\-\d[^-v]*)(.*)$/o) {
- return "$1$2p$p$3";
- } else {
- return $pkg."p".$p;
- }
+ my ($pkg, $p, $u) = ($_[0], @{$_[1]});
+ $pkg =~ m/^(.*?\-\d[^-v]*)(.*)?$/o;
+ return $1 . ($p >= 0 ? "p$p" : '') . ($u >= 0 ? "u$u" : '') .
+ (defined $2 ? $2 : '');
}
sub keep_most_recent
@@ -113,13 +105,27 @@ sub keep_most_recent
my $h = {};
for my $pkgname (@_) {
my ($p, $v) = splitp($pkgname);
- if (!defined $h->{$p} || $h->{$p} < $v) {
- $h->{$p} = $v;
+ unless (defined $h->{$p}) {
+ $h->{$p} = [ $v ];
+ next;
+ }
+ my $nvs = [];
+ for my $ov (@{$h->{$p}}) {
+ if ($ov->[0] >= $v->[0] && $ov->[1] >= $v->[1]) {
+ $nvs = undef;
+ last;
+ } elsif ($ov->[0] > $v->[0] || $ov->[1] > $v->[1]) {
+ push @$nvs, $ov;
+ }
+ }
+ if (defined $nvs) {
+ push @$nvs, $v;
+ $h->{$p} = $nvs;
}
}
my @list = ();
while (my ($p, $v) = each %$h) {
- push(@list, rebuildp($p, $v));
+ push @list, map(rebuildp($p, $_), @$v);
}
return @list;
}