2016-07-02 17:08:25 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
####################################################################################################################################
|
|
|
|
# release.pl - PgBackRest Release Manager
|
|
|
|
####################################################################################################################################
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
2016-09-06 15:44:50 +02:00
|
|
|
use English '-no_match_vars';
|
2016-07-02 17:08:25 +02:00
|
|
|
|
|
|
|
$SIG{__DIE__} = sub { Carp::confess @_ };
|
|
|
|
|
|
|
|
use Cwd qw(abs_path);
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
use Getopt::Long qw(GetOptions);
|
|
|
|
use Pod::Usage qw(pod2usage);
|
|
|
|
use Storable;
|
|
|
|
|
|
|
|
use lib dirname($0) . '/lib';
|
2017-08-25 22:47:47 +02:00
|
|
|
use lib dirname(dirname($0)) . '/build/lib';
|
|
|
|
use lib dirname(dirname($0)) . '/lib';
|
|
|
|
use lib dirname(dirname($0)) . '/test/lib';
|
2016-11-04 13:56:26 +02:00
|
|
|
|
2016-07-02 17:08:25 +02:00
|
|
|
use BackRestDoc::Common::Doc;
|
|
|
|
use BackRestDoc::Common::DocConfig;
|
|
|
|
use BackRestDoc::Common::DocManifest;
|
|
|
|
use BackRestDoc::Common::DocRender;
|
|
|
|
use BackRestDoc::Html::DocHtmlSite;
|
|
|
|
use BackRestDoc::Latex::DocLatex;
|
|
|
|
use BackRestDoc::Markdown::DocMarkdown;
|
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
use pgBackRest::Common::Exception;
|
2016-07-02 17:08:25 +02:00
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::Common::String;
|
2017-06-09 23:51:41 +02:00
|
|
|
use pgBackRest::Storage::Local;
|
|
|
|
use pgBackRest::Storage::Posix::Driver;
|
2016-07-02 17:08:25 +02:00
|
|
|
use pgBackRest::Version;
|
|
|
|
|
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Usage
|
|
|
|
####################################################################################################################################
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
release.pl - pgBackRest Release Manager
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
release.pl [options]
|
|
|
|
|
|
|
|
General Options:
|
|
|
|
--help Display usage and exit
|
|
|
|
--version Display pgBackRest version
|
|
|
|
--quiet Sets log level to ERROR
|
|
|
|
--log-level Log level for execution (e.g. ERROR, WARN, INFO, DEBUG)
|
|
|
|
|
|
|
|
Release Options:
|
|
|
|
--build Build the cache before release (should be included in the release commit)
|
|
|
|
--deploy Deploy documentation to website (can be done as docs are updated)
|
|
|
|
=cut
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Load command line parameters and config (see usage above for details)
|
|
|
|
####################################################################################################################################
|
|
|
|
my $bHelp = false;
|
|
|
|
my $bVersion = false;
|
|
|
|
my $bQuiet = false;
|
|
|
|
my $strLogLevel = 'info';
|
|
|
|
my $bBuild = false;
|
|
|
|
my $bDeploy = false;
|
|
|
|
|
|
|
|
GetOptions ('help' => \$bHelp,
|
|
|
|
'version' => \$bVersion,
|
|
|
|
'quiet' => \$bQuiet,
|
|
|
|
'log-level=s' => \$strLogLevel,
|
|
|
|
'build' => \$bBuild,
|
|
|
|
'deploy' => \$bDeploy)
|
|
|
|
or pod2usage(2);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Run in eval block to catch errors
|
|
|
|
####################################################################################################################################
|
|
|
|
eval
|
|
|
|
{
|
|
|
|
# Display version and exit if requested
|
|
|
|
if ($bHelp || $bVersion)
|
|
|
|
{
|
|
|
|
print BACKREST_NAME . ' ' . BACKREST_VERSION . " Release Manager\n";
|
|
|
|
|
|
|
|
if ($bHelp)
|
|
|
|
{
|
|
|
|
print "\n";
|
|
|
|
pod2usage();
|
|
|
|
}
|
|
|
|
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
# If neither build nor deploy is requested then error
|
|
|
|
if (!$bBuild && !$bDeploy)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, 'neither --build nor --deploy requested, nothing to do');
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set console log level
|
|
|
|
if ($bQuiet)
|
|
|
|
{
|
|
|
|
$strLogLevel = 'error';
|
|
|
|
}
|
|
|
|
|
2016-10-05 15:09:30 +02:00
|
|
|
logLevelSet(undef, uc($strLogLevel), OFF);
|
2016-07-02 17:08:25 +02:00
|
|
|
|
|
|
|
# Set the paths
|
|
|
|
my $strDocPath = dirname(abs_path($0));
|
|
|
|
my $strDocHtml = "${strDocPath}/output/html";
|
|
|
|
my $strDocExe = "${strDocPath}/doc.pl";
|
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
my $oStorageDoc = new pgBackRest::Storage::Local(
|
|
|
|
$strDocPath, new pgBackRest::Storage::Posix::Driver({bFileSync => false, bPathSync => false}));
|
|
|
|
|
2016-07-02 17:08:25 +02:00
|
|
|
# Determine if this is a dev release
|
|
|
|
my $bDev = BACKREST_VERSION =~ /dev$/;
|
|
|
|
my $strVersion = $bDev ? 'dev' : BACKREST_VERSION;
|
|
|
|
|
|
|
|
if ($bBuild)
|
|
|
|
{
|
|
|
|
# Remove permanent cache file
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageDoc->remove("${strDocPath}/resource/exe.cache", {bIgnoreMissing => true});
|
2016-07-02 17:08:25 +02:00
|
|
|
|
2016-11-23 00:31:27 +02:00
|
|
|
# Remove all docker containers to get consistent IP address assignments
|
2017-04-13 01:17:39 +02:00
|
|
|
executeTest('docker rm -f $(docker ps -a -q)', {bSuppressError => true});
|
2016-11-23 00:31:27 +02:00
|
|
|
|
2016-07-02 17:08:25 +02:00
|
|
|
# Generate deployment docs for RHEL/Centos 6
|
|
|
|
&log(INFO, "Generate RHEL/CentOS 6 documentation");
|
|
|
|
|
2017-06-25 00:04:02 +02:00
|
|
|
executeTest("${strDocExe} --deploy --keyword=co6 --out=pdf", {bShowOutputAsync => true});
|
2016-07-02 17:08:25 +02:00
|
|
|
executeTest("${strDocExe} --deploy --cache-only --keyword=co6 --out=pdf --var=\"project-name=Crunchy BackRest\"");
|
|
|
|
|
|
|
|
# Generate deployment docs for Debian
|
|
|
|
&log(INFO, "Generate Debian/Ubuntu documentation");
|
|
|
|
|
2017-06-25 00:04:02 +02:00
|
|
|
executeTest("${strDocExe} --deploy", {bShowOutputAsync => true});
|
2016-08-02 17:38:12 +02:00
|
|
|
executeTest("${strDocExe} --deploy --cache-only --out=man --out=html --var=project-url-root=index.html");
|
2016-07-02 17:08:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($bDeploy)
|
|
|
|
{
|
2017-11-22 00:59:30 +02:00
|
|
|
my $strDeployPath = "${strDocPath}/site";
|
|
|
|
|
2016-07-02 17:08:25 +02:00
|
|
|
# Generate deployment docs for the website history
|
|
|
|
&log(INFO, 'Generate website ' . ($bDev ? 'dev' : 'history') . ' documentation');
|
|
|
|
|
|
|
|
executeTest(
|
|
|
|
$strDocExe . ($bDev ? '' : ' --deploy --cache-only') . ' --out=html --var=project-url-root=index.html' .
|
2017-11-22 00:59:30 +02:00
|
|
|
($bDev ? ' --keyword=default --keyword=dev --no-exe' : ' --exclude=release'));
|
2016-07-02 17:08:25 +02:00
|
|
|
|
|
|
|
# Deploy to server
|
2017-11-22 00:59:30 +02:00
|
|
|
&log(INFO, '...Deploy to repository');
|
|
|
|
executeTest("rm -rf ${strDeployPath}/${strVersion}");
|
|
|
|
executeTest("mkdir ${strDeployPath}/${strVersion}");
|
|
|
|
executeTest("cp ${strDocHtml}/* ${strDeployPath}/${strVersion}");
|
2016-07-02 17:08:25 +02:00
|
|
|
|
|
|
|
# Generate deployment docs for the main website
|
|
|
|
if (!$bDev)
|
|
|
|
{
|
|
|
|
&log(INFO, "Generate website documentation");
|
|
|
|
|
|
|
|
executeTest("${strDocExe} --deploy --cache-only --out=html");
|
|
|
|
|
2017-11-22 00:59:30 +02:00
|
|
|
&log(INFO, '...Deploy to repository');
|
|
|
|
executeTest("rm -rf ${strDeployPath}/dev");
|
|
|
|
executeTest("find ${strDeployPath} -maxdepth 1 -type f -exec rm {} +");
|
|
|
|
executeTest("cp ${strDocHtml}/* ${strDeployPath}");
|
|
|
|
executeTest("cp ${strDocPath}/../README.md ${strDeployPath}");
|
|
|
|
executeTest("cp ${strDocPath}/../LICENSE ${strDeployPath}");
|
|
|
|
executeTest("echo 'pgbackrest.org' > ${strDeployPath}/CNAME");
|
2016-07-02 17:08:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Update permissions
|
2017-11-22 02:52:56 +02:00
|
|
|
executeTest("find ${strDeployPath} -type d -exec chmod 750 {} +");
|
|
|
|
executeTest("find ${strDeployPath} -type f -exec chmod 640 {} +");
|
2016-07-02 17:08:25 +02:00
|
|
|
}
|
2016-09-06 15:44:50 +02:00
|
|
|
|
|
|
|
# Exit with success
|
|
|
|
exit 0;
|
|
|
|
}
|
2016-07-02 17:08:25 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Check for errors
|
|
|
|
####################################################################################################################################
|
2016-09-06 15:44:50 +02:00
|
|
|
or do
|
2016-07-02 17:08:25 +02:00
|
|
|
{
|
2016-09-06 15:44:50 +02:00
|
|
|
# If a backrest exception then return the code
|
2017-10-16 16:47:31 +02:00
|
|
|
exit $EVAL_ERROR->code() if (isException(\$EVAL_ERROR));
|
2016-07-02 17:08:25 +02:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
# Else output the unhandled error
|
|
|
|
print $EVAL_ERROR;
|
|
|
|
exit ERROR_UNHANDLED;
|
|
|
|
};
|
2016-07-02 17:08:25 +02:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
# It shouldn't be possible to get here
|
|
|
|
&log(ASSERT, 'execution reached invalid location in ' . __FILE__ . ', line ' . __LINE__);
|
|
|
|
exit ERROR_ASSERT;
|