diff options
author | Pascal Terjan <pterjan@mageia.org> | 2022-10-25 20:29:46 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@mageia.org> | 2022-11-01 22:23:53 +0000 |
commit | 2c86ed6389d741cfe41323937e9e93b89935490e (patch) | |
tree | 046cb4f3b1bf2046d8555ae18100280c3a3fb62c /URPM | |
parent | 775e1ad51b6318b1a308be9b997accc470329282 (diff) | |
download | perl-URPM-2c86ed6389d741cfe41323937e9e93b89935490e.tar perl-URPM-2c86ed6389d741cfe41323937e9e93b89935490e.tar.gz perl-URPM-2c86ed6389d741cfe41323937e9e93b89935490e.tar.bz2 perl-URPM-2c86ed6389d741cfe41323937e9e93b89935490e.tar.xz perl-URPM-2c86ed6389d741cfe41323937e9e93b89935490e.zip |
Fix parsing of properties containing [topic/parse_property
For example, the name extracted from a requirement of
"python3.10dist(fonttools[unicode])[>= 4.10]" was sometimes
"python3.10dist(fonttools" instead of the expected
"python3.10dist(fonttools[unicode])".
Code parsing such strings existed in many places, it now exists only
in 2 places, a perl version in Resolve.pm and a C version in URPM.xs.
Both codes used to handle both "foo >= 0" and "foo[>= 0]" but at least
the perl code seems to only call it on provides/conflicts/obsoletes
which are always using the second form so the support for it was
dropped from the perl version for the sake of simplicity.
Diffstat (limited to 'URPM')
-rw-r--r-- | URPM/Resolve.pm | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index dded564..1816eb1 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -58,7 +58,12 @@ Returns the property name (eg: "mageia-release" in above example) sub property2name { my ($property) = @_; - $property =~ /^([^\s\[]*)/ && $1; + my $name = $property; + if ($property =~ /^([^\s]+)\s*\[[^\[]*\]$/) { + $name = $1; + } + $name =~ s/\[\*\]$//; + return $name; } =item property2name_range($property) @@ -69,7 +74,14 @@ Returns the property name & range (eg: "mageia-release" & ">= 1" in above exampl sub property2name_range { my ($property) = @_; - $property =~ /^([^\s\[]*)(?:\[\*\])?\[?([^\s\]]*\s*[^\s\]]*)/; + my ($name, $range) = ($property, ""); + $name =~ s/\[\*\]$//; + if ($name =~ /^([^\s]+)\s*\[([^\[]*)\]$/) { + $name = $1; + $range = $2; + } + $name =~ s/\[\*\]$//; + return ($name, $range); } =item property2name_op_version($property) @@ -81,7 +93,15 @@ Returns the property name, operator & range (eg: "mageia-release", ">=", & "1" i sub property2name_op_version { my ($property) = @_; - $property =~ /^([^\s\[]*)(?:\[\*\])?\s*\[?([^\s\]]*)\s*([^\s\]]*)/; + my ($name, $op, $version) = ($property, "", ""); + $name =~ s/\[\*\]$//; + if ($name =~ /^([^\s]+)\s*\[([^\s\[]*)\s*([^\s\]]*)\]$/) { + $name = $1; + $op = $2; + $version = $3; + } + $name =~ s/\[\*\]$//; + return ($name, $op, $version); } |