Fix dependency matching if pkgrel contains a dot
This commit is contained in:
parent
b06a1dfcd2
commit
6a9589b4a1
|
@ -227,17 +227,18 @@ PackageVersionPartComparison PackageVersion::compareParts(const string &part1, c
|
|||
part2Pos = part2End + 1;
|
||||
} else if (*part1End) {
|
||||
// only part 1 has another segment -> it is more specific and hence considered newer
|
||||
if (allowImplicitPkgRel) {
|
||||
// check whether the only further segment in part 1 is pkgrel
|
||||
// -> check for pkgrel separation which is always '-'
|
||||
if (*part1End == '-') {
|
||||
part1Pos = part1End + 1;
|
||||
part1End = firstNonAlphanumericCharacter(part1Pos, part1End);
|
||||
if (!*part1End) {
|
||||
// consider both parts equal if part 2 doesn't have explicit pkgrel and part 1 does
|
||||
return PackageVersionPartComparison::Equal;
|
||||
if (allowImplicitPkgRel && *part1End == '-') {
|
||||
// check whether the only further segment in part 1 is pkgrel (starts with '-' and only contains alphanumeric chars and '.')
|
||||
for (part1Pos = part1End + 1; part1Pos != part1End; ++part1Pos) {
|
||||
const char c = *part1Pos;
|
||||
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (c == '.'))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!*part1Pos) {
|
||||
// consider both parts equal if part 2 doesn't have explicit pkgrel and part 1 does
|
||||
return PackageVersionPartComparison::Equal;
|
||||
}
|
||||
}
|
||||
return PackageVersionPartComparison::Newer;
|
||||
} else if (*part2End) {
|
||||
|
|
|
@ -188,12 +188,17 @@ void DataTests::testDependencyMatching()
|
|||
CPPUNIT_ASSERT_MESSAGE(
|
||||
"greather equal constraint with explicitely specified pkgrel must match", pkg3.providesDependency(Dependency::fromString(depStr, 17)));
|
||||
|
||||
Package pkg4;
|
||||
pkg3.name = "sphinxbase";
|
||||
pkg3.version = "5prealpha-11.1aBc";
|
||||
depStr = "sphinxbase=5prealpha";
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
"equal constraint, any pkgrel should match (even strange one)", pkg3.providesDependency(Dependency::fromString(depStr, 20)));
|
||||
|
||||
pkg3.name = "ffmpeg";
|
||||
pkg3.version = "1:4.1-3";
|
||||
CPPUNIT_ASSERT(pkg3.providesDependency(Dependency::fromString("ffmpeg<1:4.3")));
|
||||
CPPUNIT_ASSERT_MESSAGE("real-world ffmpeg example (1)", pkg3.providesDependency(Dependency::fromString("ffmpeg<1:4.3")));
|
||||
pkg3.version = "1:4.1-2";
|
||||
CPPUNIT_ASSERT(!pkg3.providesDependency(Dependency::fromString("ffmpeg>=1:4.1-3")));
|
||||
CPPUNIT_ASSERT_MESSAGE("real-world ffmpeg example (2)", !pkg3.providesDependency(Dependency::fromString("ffmpeg>=1:4.1-3")));
|
||||
}
|
||||
|
||||
void DataTests::testPackageSearch()
|
||||
|
|
Loading…
Reference in New Issue