1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Separate version into component parts.

This guarantees a consistent version representation and allows the version to be easily represented in other ways.
This commit is contained in:
David Steele
2025-01-23 17:12:05 -05:00
parent 6776940c3b
commit 6df96f505f
3 changed files with 46 additions and 4 deletions

View File

@ -26,6 +26,11 @@ push @EXPORT, qw(PROJECT_CONF);
# Defines the current version of the BackRest executable. The version number is used to track features but does not affect what # Defines the current version of the BackRest executable. The version number is used to track features but does not affect what
# repositories or manifests can be read - that's the job of the format number. # repositories or manifests can be read - that's the job of the format number.
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
push @EXPORT, qw(PROJECT_VERSION_MAJOR);
push @EXPORT, qw(PROJECT_VERSION_MINOR);
push @EXPORT, qw(PROJECT_VERSION_PATCH);
push @EXPORT, qw(PROJECT_VERSION_SUFFIX);
push @EXPORT, qw(PROJECT_VERSION); push @EXPORT, qw(PROJECT_VERSION);
# Repository Format Number # Repository Format Number
@ -46,7 +51,6 @@ my $strProjectInfo = ${new pgBackRestTest::Common::Storage(
foreach my $strLine (split("\n", $strProjectInfo)) foreach my $strLine (split("\n", $strProjectInfo))
{ {
if ($strLine =~ /^#define PROJECT_NAME/) if ($strLine =~ /^#define PROJECT_NAME/)
{ {
eval("use constant PROJECT_NAME => " . (split(" ", $strLine))[-1]); eval("use constant PROJECT_NAME => " . (split(" ", $strLine))[-1]);
@ -56,9 +60,21 @@ foreach my $strLine (split("\n", $strProjectInfo))
eval("use constant PROJECT_EXE => " . (split(" ", $strLine))[-1]); eval("use constant PROJECT_EXE => " . (split(" ", $strLine))[-1]);
eval("use constant PROJECT_CONF => " . (split(" ", $strLine))[-1] . " . \'.conf\'"); eval("use constant PROJECT_CONF => " . (split(" ", $strLine))[-1] . " . \'.conf\'");
} }
elsif ($strLine =~ /^#define PROJECT_VERSION/) elsif ($strLine =~ /^#define PROJECT_VERSION_MAJOR/)
{ {
eval("use constant PROJECT_VERSION => " . (split(" ", $strLine))[-1]); eval("use constant PROJECT_VERSION_MAJOR => \"" . (split(" ", $strLine))[-1] . "\"");
}
elsif ($strLine =~ /^#define PROJECT_VERSION_MINOR/)
{
eval("use constant PROJECT_VERSION_MINOR => " . (split(" ", $strLine))[-1]);
}
elsif ($strLine =~ /^#define PROJECT_VERSION_PATCH/)
{
eval("use constant PROJECT_VERSION_PATCH => " . (split(" ", $strLine))[-1]);
}
elsif ($strLine =~ /^#define PROJECT_VERSION_SUFFIX/)
{
eval("use constant PROJECT_VERSION_SUFFIX => " . (split(" ", $strLine))[-1]);
} }
elsif ($strLine =~ /^#define REPOSITORY_FORMAT/) elsif ($strLine =~ /^#define REPOSITORY_FORMAT/)
{ {
@ -66,4 +82,8 @@ foreach my $strLine (split("\n", $strProjectInfo))
} }
} }
eval(
'use constant PROJECT_VERSION => "' . PROJECT_VERSION_MAJOR() . '.' . PROJECT_VERSION_MINOR() . '.' . PROJECT_VERSION_PATCH() .
PROJECT_VERSION_SUFFIX() . '"');
1; 1;

View File

@ -31,8 +31,13 @@ will be invalid unless migration functions are written.
#define REPOSITORY_FORMAT 5 #define REPOSITORY_FORMAT 5
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Software version Project version components. PROJECT_VERSION is automatically generated from the component parts.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#define PROJECT_VERSION_MAJOR 2
#define PROJECT_VERSION_MINOR 55
#define PROJECT_VERSION_PATCH 0
#define PROJECT_VERSION_SUFFIX "dev"
#define PROJECT_VERSION "2.55.0dev" #define PROJECT_VERSION "2.55.0dev"
#endif #endif

View File

@ -435,6 +435,23 @@ eval
buildPutDiffers($oStorageBackRest, "${strBackRestBase}/meson.build", $strMesonBuildNew); buildPutDiffers($oStorageBackRest, "${strBackRestBase}/meson.build", $strMesonBuildNew);
# Auto-generate version for version.h
#-------------------------------------------------------------------------------------------------------------------------------
my $strVersionCOld = ${$oStorageTest->get("${strBackRestBase}/src/version.h")};
my $strVersionCNew;
foreach my $strLine (split("\n", $strVersionCOld))
{
if ($strLine =~ /^#define PROJECT_VERSION /)
{
$strLine = "#define PROJECT_VERSION" . (' ' x 45) . '"' . PROJECT_VERSION . '"';
}
$strVersionCNew .= "${strLine}\n";
}
buildPutDiffers($oStorageBackRest, "${strBackRestBase}/src/version.h", $strVersionCNew);
# Start build container if vm is not none # Start build container if vm is not none
#------------------------------------------------------------------------------------------------------------------------------- #-------------------------------------------------------------------------------------------------------------------------------
if ($strVm ne VM_NONE) if ($strVm ne VM_NONE)