From 8c53742a5e1b5b01a7635ea33dbb72ec3c957e13 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sun, 18 Dec 2022 21:36:53 +0000 Subject: Add back support for foo > 5 in property2name* This is used internally to create search queries. At the same time update synthesis tests to be more representative by using foo[< 5] syntax which has been what is genereated for many many years. --- Changes | 2 ++ URPM/Resolve.pm | 20 +++++++++++--------- t/resolve.t | 5 +++++ t/synthesis.t | 25 +++++++++++++++---------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Changes b/Changes index cb7769a..8ea790b 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ +- Add back support for "foo > 5" syntx in property2name* + Version 5.223.1 - 14 November 2022 - Drop a debug statement diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index 1816eb1..dde3159 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -48,6 +48,9 @@ sub find(&@) { The property2name* functions parse things like "mageia-release[>= 1]" which is the format returned by URPM.xs for ->requires, ->provides, ->conflicts... +They also support the format "mageia-release > 1" which get generated by +some code to find newer versions of a package for example. + =over 4 =item property2name($property) @@ -59,7 +62,7 @@ Returns the property name (eg: "mageia-release" in above example) sub property2name { my ($property) = @_; my $name = $property; - if ($property =~ /^([^\s]+)\s*\[[^\[]*\]$/) { + if ($property =~ /^([^\s]+)(\s*\[[^\[]*\]$|\s+[><=])/) { $name = $1; } $name =~ s/\[\*\]$//; @@ -76,9 +79,9 @@ sub property2name_range { my ($property) = @_; my ($name, $range) = ($property, ""); $name =~ s/\[\*\]$//; - if ($name =~ /^([^\s]+)\s*\[([^\[]*)\]$/) { + if ($name =~ /^([^\s]+)(\s*\[([^\[]+)\]|\s+([><=].*))$/) { $name = $1; - $range = $2; + $range = $3 || $4; } $name =~ s/\[\*\]$//; return ($name, $range); @@ -93,12 +96,11 @@ Returns the property name, operator & range (eg: "mageia-release", ">=", & "1" i sub property2name_op_version { my ($property) = @_; - my ($name, $op, $version) = ($property, "", ""); - $name =~ s/\[\*\]$//; - if ($name =~ /^([^\s]+)\s*\[([^\s\[]*)\s*([^\s\]]*)\]$/) { - $name = $1; - $op = $2; - $version = $3; + my ($name, $range) = property2name_range($property); + my ($op, $version) = ("", ""); + if ($range =~ /^([><=]+)\s+(.*)$/) { + $op = $1; + $version = $2; } $name =~ s/\[\*\]$//; return ($name, $op, $version); diff --git a/t/resolve.t b/t/resolve.t index 56869b1..78c73e8 100644 --- a/t/resolve.t +++ b/t/resolve.t @@ -11,6 +11,11 @@ my $testcases = [ name => 'mageia-release', op => '>=', version => '1', + }, { + property => 'mageia-release >= 1', + name => 'mageia-release', + op => '>=', + version => '1', }, { property => 'python3.10dist(fonttools[unicode])[>= 4.10]', name => 'python3.10dist(fonttools[unicode])', diff --git a/t/synthesis.t b/t/synthesis.t index 794fd7a..2f30c46 100644 --- a/t/synthesis.t +++ b/t/synthesis.t @@ -2,7 +2,7 @@ use strict ; use warnings ; -use Test::More tests => 113; +use Test::More tests => 116; use URPM; chdir 't' if -d 't'; @@ -10,10 +10,10 @@ my $file1 = 'synthesis.sample.cz'; my $file2 = 'synthesis.sample-xz.cz'; my $s = <<'EOF'; -@provides@glibc-devel == 6:2.2.4-25mdk -@requires@/sbin/install-info@glibc == 2.2.4@kernel-headers@kernel-headers >= 2.2.1@/bin/sh@/bin/sh@/bin/sh@rpmlib(PayloadFilesHavePrefix) <= 4.0-1@rpmlib(CompressedFileNames) <= 3.0.4-1 -@conflicts@texinfo < 3.11@gcc < 2.96-0.50mdk -@obsoletes@libc-debug@libc-headers@libc-devel@linuxthreads-devel@glibc-debug +@provides@glibc-devel[== 6:2.2.4-25mdk] +@requires@/sbin/install-info@glibc[== 2.2.4]@kernel-headers@kernel-headers[>= 2.2.1]@/bin/sh@/bin/sh@/bin/sh@rpmlib(PayloadFilesHavePrefix)[<= 4.0-1]@rpmlib(CompressedFileNames)[<= 3.0.4-1] +@conflicts@texinfo[< 3.11]@gcc[< 2.96-0.50mdk] +@obsoletes@libc-debug@libc-headers@libc-devel@linuxthreads-devel@glibc-debug[< 3] @info@glibc-devel-2.2.4-25mdk.i586@6@45692097@Development/C EOF @@ -108,21 +108,26 @@ ok($pkg->id == 0); my @obsoletes = $pkg->obsoletes; ok(@obsoletes == 5); ok($obsoletes[0] eq 'libc-debug'); -ok($obsoletes[4] eq 'glibc-debug'); +ok($obsoletes[4] eq 'glibc-debug[< 3]'); + +my @obsoletes_nosense = $pkg->obsoletes_nosense; +ok(@obsoletes_nosense == 5); +ok($obsoletes_nosense[0] eq 'libc-debug'); +ok($obsoletes_nosense[4] eq 'glibc-debug'); my @conflicts = $pkg->conflicts; ok(@conflicts == 2); -ok($conflicts[0] eq 'texinfo < 3.11'); -ok($conflicts[1] eq 'gcc < 2.96-0.50mdk'); +ok($conflicts[0] eq 'texinfo[< 3.11]'); +ok($conflicts[1] eq 'gcc[< 2.96-0.50mdk]'); my @requires = $pkg->requires; ok(@requires == 9); ok($requires[0] eq '/sbin/install-info'); -ok($requires[8] eq 'rpmlib(CompressedFileNames) <= 3.0.4-1'); +ok($requires[8] eq 'rpmlib(CompressedFileNames)[<= 3.0.4-1]'); my @provides = $pkg->provides; ok(@provides == 1); -ok($provides[0] eq 'glibc-devel == 6:2.2.4-25mdk'); +ok($provides[0] eq 'glibc-devel[== 6:2.2.4-25mdk]'); my @files = $pkg->files; ok(@files == 0); -- cgit v1.2.1