1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-20 04:59:25 +02:00

Move version check against release notes to release.pl.

This is a more appropriate place for the check and means test.pl can avoid loading any XML files if --no-gen is specified.

The XML::Checker::Parser module originally selected for XML in Perl is not very portable so the requirement reduces the number of platforms where tests can be run.
This commit is contained in:
David Steele 2021-01-22 12:52:30 -05:00
parent fdf1c299f9
commit 708c3e9135
2 changed files with 18 additions and 44 deletions

View File

@ -36,6 +36,7 @@ use pgBackRestDoc::Common::DocRender;
use pgBackRestDoc::Common::Exception;
use pgBackRestDoc::Common::Log;
use pgBackRestDoc::Common::String;
use pgBackRestDoc::Custom::DocCustomRelease;
use pgBackRestDoc::Html::DocHtmlSite;
use pgBackRestDoc::Latex::DocLatex;
use pgBackRestDoc::Markdown::DocMarkdown;
@ -134,6 +135,17 @@ eval
my $bDev = PROJECT_VERSION =~ /dev$/;
my $strVersion = $bDev ? 'dev' : PROJECT_VERSION;
# Make sure version number matches the latest release
&log(INFO, "check version info");
my $strReleaseFile = dirname(dirname(abs_path($0))) . '/doc/xml/release.xml';
my $oRelease = (new pgBackRestDoc::Custom::DocCustomRelease(new pgBackRestDoc::Common::Doc($strReleaseFile)))->releaseLast();
if ($oRelease->paramGet('version') ne PROJECT_VERSION)
{
confess 'unable to find version ' . PROJECT_VERSION . " as the most recent release in ${strReleaseFile}";
}
if ($bBuild)
{
if (!$bNoGen)

View File

@ -615,46 +615,6 @@ eval
}
}
# Check Perl version against release notes and update version in C code if needed
#---------------------------------------------------------------------------------------------------------------------------
my $bVersionDev = true;
my $strVersionBase;
if (!$bDev || $bBuildPackage)
{
# Make sure version number matches the latest release
#-----------------------------------------------------------------------------------------------------------------------
&log(INFO, "check version info");
# Load the doc modules dynamically since they are not supported on all systems
require pgBackRestDoc::Common::Doc;
pgBackRestDoc::Common::Doc->import();
require pgBackRestDoc::Custom::DocCustomRelease;
pgBackRestDoc::Custom::DocCustomRelease->import();
my $strReleaseFile = dirname(dirname(abs_path($0))) . '/doc/xml/release.xml';
my $oRelease =
(new pgBackRestDoc::Custom::DocCustomRelease(new pgBackRestDoc::Common::Doc($strReleaseFile)))->releaseLast();
my $strVersion = $oRelease->paramGet('version');
$bVersionDev = false;
$strVersionBase = $strVersion;
if ($strVersion =~ /dev$/)
{
$bVersionDev = true;
$strVersionBase = substr($strVersion, 0, length($strVersion) - 3);
if (PROJECT_VERSION !~ /dev$/ && $oRelease->nodeTest('release-core-list'))
{
confess "dev release ${strVersion} must match the program version when core changes have been made";
}
}
elsif ($strVersion ne PROJECT_VERSION)
{
confess 'unable to find version ' . PROJECT_VERSION . " as the most recent release in ${strReleaseFile}";
}
}
# Clean up
#---------------------------------------------------------------------------------------------------------------------------
my $iTestFail = 0;
@ -905,6 +865,8 @@ eval
}
# If dev build then disable static release date used for reproducibility
my $bVersionDev = PROJECT_VERSION =~ /dev$/;
if ($bVersionDev)
{
my $strRules = ${$oStorageBackRest->get("${strBuildPath}/debian/rules")};
@ -920,7 +882,7 @@ eval
# Update changelog to add experimental version
$oStorageBackRest->put("${strBuildPath}/debian/changelog",
"pgbackrest (${strVersionBase}-0." . ($bVersionDev ? 'D' : 'P') . strftime("%Y%m%d%H%M%S", gmtime) .
"pgbackrest (${\PROJECT_VERSION}-0." . ($bVersionDev ? 'D' : 'P') . strftime("%Y%m%d%H%M%S", gmtime) .
") experimental; urgency=medium\n" .
"\n" .
' * Automated experimental ' . ($bVersionDev ? 'development' : 'production') . " build.\n" .
@ -986,8 +948,8 @@ eval
# Copy source files
executeTest(
"tar --transform='s_^_pgbackrest-release-${strVersionBase}/_'" .
" -czf ${strBuildPath}/SOURCES/${strVersionBase}.tar.gz -C ${strBackRestBase}" .
"tar --transform='s_^_pgbackrest-release-${\PROJECT_VERSION}/_'" .
" -czf ${strBuildPath}/SOURCES/${\PROJECT_VERSION}.tar.gz -C ${strBackRestBase}" .
" src LICENSE");
# Copy package files
@ -1016,7 +978,7 @@ eval
# Update version number to match current version
my $strSpec = ${$oStorageBackRest->get("${strBuildPath}/SPECS/pgbackrest.spec")};
$strSpec =~ s/^Version\:.*$/Version\:\t${strVersionBase}/gm;
$strSpec =~ s/^Version\:.*$/Version\:\t${\PROJECT_VERSION}/gm;
$oStorageBackRest->put("${strBuildPath}/SPECS/pgbackrest.spec", $strSpec);
# Build package