From 1b1ee9eae49d6ef24ac4d81130a91ceab392fd2c Mon Sep 17 00:00:00 2001 From: Mandrake Date: Tue, 12 Sep 2006 11:34:08 +0000 Subject: add a range_check functions --- lib/Youri/Package/URPM.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/Youri/Package/URPM.pm b/lib/Youri/Package/URPM.pm index 3cd8aa4..fb02170 100644 --- a/lib/Youri/Package/URPM.pm +++ b/lib/Youri/Package/URPM.pm @@ -117,6 +117,25 @@ sub get_full_version { return $self->{_header}->epoch() ."-" . $self->{_header}->version() . "-". $self->{_header}->release() } +sub range_check { + my ($self, $obsolete, $package) = @_; + croak "Not a class method" unless ref $self; + my $obs = $obsolete->[Youri::Package::DEPENDENCY_NAME]; + my $range = $obsolete->[Youri::Package::DEPENDENCY_RANGE]; + my ($flag, $version) = $range =~ /(\S+)\s+(.*)/; + if ($version) { + my ($epoch, $ver, $release) = $version =~ /(?:(\d+):)?([^-]+(?:-[^-]*)?)/; + $release ||= '0'; + $epoch ||= '0'; + $range = "$flag $epoch-$ver-$release"; + my $full_version = $package->get_full_version; + print "Comparing $range with $full_version\n"; + return URPM::ranges_overlap($range, "== $full_version") + } else { + return 1 + } +} + sub get_release { my ($self) = @_; croak "Not a class method" unless ref $self; -- cgit v1.2.1