1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add host-repo-path variable internal replacement.

This variable needs to be replaced right before being used without being added to the cache since the host repo path will vary from system to system.

This is frankly a bit of a hack to get the documentation to build in the Debian packages for the upcoming release.  We'll need to come up with something more flexible going forward.
This commit is contained in:
David Steele 2019-06-25 07:58:38 -04:00
parent 5cbe2dee85
commit 51fcaee43e
3 changed files with 26 additions and 12 deletions

View File

@ -9,8 +9,10 @@ use warnings FATAL => qw(all);
use Carp qw(confess);
use English '-no_match_vars';
use Cwd qw(abs_path);
use Exporter qw(import);
our @EXPORT = qw();
use File::Basename qw(dirname);
use Storable qw(dclone);
use pgBackRest::Common::Exception;
@ -1080,12 +1082,30 @@ sub sectionChildProcess
$strImage = $strPreImage;
}
my $strHostRepoPath = dirname(dirname(abs_path($0)));
# Replace host repo path in mounts with if present
my $strMount = undef;
if (defined($oChild->paramGet('mount', false)))
{
$strMount = $self->{oManifest}->variableReplace($oChild->paramGet('mount'));
$strMount =~ s/\{\[host\-repo\-path\]\}/${strHostRepoPath}/g;
}
# Replace host repo mount in params if present
my $strOption = $$hCacheKey{option};
if (defined($strOption))
{
$strOption =~ s/\{\[host\-repo\-path\]\}/${strHostRepoPath}/g;
}
my $oHost = new pgBackRestTest::Common::HostTest(
$$hCacheKey{name}, "doc-$$hCacheKey{name}", $strImage,
$self->{oManifest}->variableReplace($oChild->paramGet('user')), $$hCacheKey{os},
defined($oChild->paramGet('mount', false)) ?
[$self->{oManifest}->variableReplace($oChild->paramGet('mount'))] : undef,
$$hCacheKey{option}, $$hCacheKey{param}, $$hCacheKey{'update-hosts'});
defined($strMount) ? [$strMount] : undef,
$strOption, $$hCacheKey{param}, $$hCacheKey{'update-hosts'});
$self->{host}{$$hCacheKey{name}} = $oHost;
$self->{oManifest}->variableSet('host-' . $hCacheKey->{id} . '-ip', $oHost->{strIP}, true);

View File

@ -1036,6 +1036,7 @@ sub processText
{
$strBuffer =~ s/\&mdash\;/--/g;
$strBuffer =~ s/\&lt\;/\</g;
$strBuffer =~ s/\&ge\;/\>\=/g;
}
$strBuffer = $self->variableReplace($strBuffer);

View File

@ -45,13 +45,6 @@
<variable key="user-guide-os" if="{[os-type-is-centos6]}">RHEL/CentOS 6</variable>
<variable key="user-guide-os" if="{[os-type-is-centos7]}">RHEL/CentOS 7</variable>
<variable key="pgbackrest-host-repo-path" eval="y">
use File::Basename qw(dirname);
use Cwd qw(abs_path);
dirname(dirname(abs_path($0)));
</variable>
<variable key="pgbackrest-repo-path">/pgbackrest</variable>
<!-- Path where CA certificates are installed -->
@ -60,7 +53,7 @@
<!-- Path where fake certificates are located -->
<variable key="fake-cert-path-relative">resource/fake-cert</variable>
<variable key="fake-cert-path">{[pgbackrest-host-repo-path]}/doc/{[fake-cert-path-relative]}</variable>
<variable key="fake-cert-path">{[host-repo-path]}/doc/{[fake-cert-path-relative]}</variable>
<variable key="pg-version" if="{[os-type-is-debian]}">{[os-debian-pg-version]}</variable>
<variable key="pg-version" if="{[os-type-is-centos6]}">{[os-centos6-pg-version]}</variable>
@ -156,7 +149,7 @@
<variable key="host-option">-v /sys/fs/cgroup:/sys/fs/cgroup:rw -v /tmp/$(mktemp -d):/run</variable>
<variable key="host-user" eval="y">use English; getpwuid($UID) eq 'root' ? 'vagrant' : getpwuid($UID) . ''</variable>
<variable key="host-mount">{[pgbackrest-host-repo-path]}:{[pgbackrest-repo-path]}</variable>
<variable key="host-mount">{[host-repo-path]}:{[pgbackrest-repo-path]}</variable>
<variable key="image-repo">pgbackrest/test</variable>
<variable key="host-s3-id">s3</variable>