Avoid having to rely on `pkgver()` yielding a newer version for VCS packages

Bump pkgver/pkgrel of VCS packages. This should help with case (1) and
should not interfere with case (2).

(1) If the pkgver does not change after all then makepkg leaves the bumped
    pkgrel untouched.
(2) If the pkgver does change then makepkg will reset the bumped pkgrel and
    it is as if we haven't changed anything.
This commit is contained in:
Martchus 2023-09-03 14:27:59 +02:00
parent cda3c34806
commit c816972a16
1 changed files with 12 additions and 13 deletions

View File

@ -744,8 +744,8 @@ void PrepareBuild::bumpVersions()
continue;
}
auto existingVersion = existingVersionStr.empty() ? LibPkg::PackageVersion{} : LibPkg::PackageVersion::fromString(existingVersionStr);
LibPkg::PackageAmendment amendment;
LibPkg::PackageVersion newVersion;
auto amendment = LibPkg::PackageAmendment();
auto newVersion = LibPkg::PackageVersion();
for (const auto &[packageID, package] : buildData.packages) {
newVersion = LibPkg::PackageVersion::fromString(package->version);
if (existingVersionStr.empty()) {
@ -760,18 +760,17 @@ void PrepareBuild::bumpVersions()
break;
case LibPkg::PackageVersionComparison::SoftwareUpgrade:
if (package->decomposeName().isVcsPackage()) {
// skip bumping epoch of VCS packages; the pkgver is supposed to be adjusted in pkgver()
// note: Not skipping this in the pkgrel handling in the case above because when pkgver() returns a new version, pkgrel is
// reset automatically so there's no harm in bumping it and it might actually be needed if there's no no version.
m_warnings.emplace_back("Version of package " % package->name % " is" % package->version
% " which is older than existing version " % existingVersionStr
+ "; NOT bumping the epoch because it is a VCS package; be sure pkgver() actually yields a new version");
break;
amendment.setUpstreamVersion = true;
amendment.bumpDownstreamVersion = LibPkg::PackageAmendment::VersionBump::PackageVersion;
m_warnings.emplace_back("Bumping pkgver and pkgrel of VCS package " % package->name % "; its version " % package->version % " is older than existing version "
+ existingVersionStr);
} else {
amendment.bumpDownstreamVersion = LibPkg::PackageAmendment::VersionBump::Epoch;
m_warnings.emplace_back("Bumping epoch of " % package->name % "; its version " % package->version % " is older than existing version "
+ existingVersionStr);
goto breakLoop;
}
amendment.bumpDownstreamVersion = LibPkg::PackageAmendment::VersionBump::Epoch;
m_warnings.emplace_back("Bumping epoch of " % package->name % "; its version " % package->version % " is older than existing version "
+ existingVersionStr);
goto breakLoop;
break;
default:;
}
}