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

Get package source files dynamically during package build.

The prior method was to build a special container to hold these files which meant they would get stale on development systems.  On CI the container was always rebuilt so failures would be seen there even when dev seemed to be working.

Instead get the package source when the package is built to ensure it is as up-to-date as possible.

This change was prompted by failures on the Ubuntu 12.04 container while getting the package source, probably due to an ancient version of git.  Package builds are no longer supported on that platform with the addition of lz4 compression so it didn't seem worth fixing.
This commit is contained in:
David Steele 2020-03-12 08:48:45 -04:00
parent 4a5bd002c0
commit 0ba8062f5f
2 changed files with 24 additions and 43 deletions

View File

@ -546,46 +546,6 @@ sub containerBuild
containerWrite( containerWrite(
$oStorageDocker, $strTempPath, $strOS, 'Base', $strImageParent, $strImage, $strCopy, $strScript, $bVmForce); $oStorageDocker, $strTempPath, $strOS, 'Base', $strImageParent, $strImage, $strCopy, $strScript, $bVmForce);
# Build image
###########################################################################################################################
$strImageParent = containerRepo() . ":${strOS}-base";
$strImage = "${strOS}-build";
$strCopy = undef;
$strScript = sectionHeader() .
"# Create test user\n" .
' ' . groupCreate($strOS, TEST_GROUP, TEST_GROUP_ID) . " && \\\n" .
' ' . userCreate($strOS, TEST_USER, TEST_USER_ID, TEST_GROUP);
# Fetch package source
if ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{
$strScript .= sectionHeader() .
"# Install pgBackRest package source\n" .
" git clone https://salsa.debian.org/postgresql/pgbackrest.git /root/package-src";
}
else
{
# Fetching specific files is fragile but even a shallow clone of the entire pgrpms repo is very expensive. Using
# 'git archive' does not seem to work: access denied or repository not exported: /git/pgrpms.git.
$strScript .= sectionHeader() .
"# Install pgBackRest package source\n" .
" mkdir /root/package-src && \\\n" .
" wget -O /root/package-src/pgbackrest-conf.patch " .
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
"f=rpm/redhat/master/pgbackrest/master/pgbackrest-conf.patch;hb=refs/heads/master' && \\\n" .
" wget -O /root/package-src/pgbackrest-libxmlinclude.patch " .
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
"f=rpm/redhat/master/pgbackrest/master/pgbackrest-libxmlinclude.patch;hb=refs/heads/master' && \\\n" .
" wget -O /root/package-src/pgbackrest.spec " .
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
"f=rpm/redhat/master/pgbackrest/master/pgbackrest.spec;hb=refs/heads/master'";
}
$strScript .= entryPointSetup($strOS);
containerWrite($oStorageDocker, $strTempPath, $strOS, 'Build', $strImageParent, $strImage, $strCopy, $strScript, $bVmForce);
# Test image # Test image
######################################################################################################################## ########################################################################################################################
if (!$bDeprecated) if (!$bDeprecated)

View File

@ -785,7 +785,7 @@ eval
{ {
executeTest( executeTest(
"docker run -itd -h test-build --name=test-build" . "docker run -itd -h test-build --name=test-build" .
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-build", " -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-test",
{bSuppressStdErr => true}); {bSuppressStdErr => true});
} }
@ -873,12 +873,17 @@ eval
{ {
executeTest( executeTest(
"docker run -itd -h test-build --name=test-build" . "docker run -itd -h test-build --name=test-build" .
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-build", " -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-test",
{bSuppressStdErr => true}); {bSuppressStdErr => true});
} }
$oStorageBackRest->pathCreate($strBuildPath, {bIgnoreExists => true, bCreateParent => true}); $oStorageBackRest->pathCreate($strBuildPath, {bIgnoreExists => true, bCreateParent => true});
# Clone a copy of the debian package repo
executeTest(
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
"bash -c 'git clone https://salsa.debian.org/postgresql/pgbackrest.git /root/package-src 2>&1'");
executeTest("rsync -r --exclude .vagrant --exclude .git ${strBackRestBase}/ ${strBuildPath}/"); executeTest("rsync -r --exclude .vagrant --exclude .git ${strBackRestBase}/ ${strBuildPath}/");
executeTest( executeTest(
($strVm ne VM_NONE ? "docker exec -i test-build " : '') . ($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
@ -948,10 +953,26 @@ eval
{ {
executeTest( executeTest(
"docker run -itd -h test-build --name=test-build" . "docker run -itd -h test-build --name=test-build" .
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-build", " -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-test",
{bSuppressStdErr => true}); {bSuppressStdErr => true});
} }
# Fetching specific files is fragile but even a shallow clone of the entire pgrpms repo is very expensive.
# Using 'git archive' does not seem to work: access denied or repository not exported: /git/pgrpms.git.
executeTest(
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
"bash -c \"" .
"mkdir /root/package-src && " .
"wget -q -O /root/package-src/pgbackrest-conf.patch " .
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
"f=rpm/redhat/master/pgbackrest/master/pgbackrest-conf.patch;hb=refs/heads/master' && " .
"wget -q -O /root/package-src/pgbackrest-libxmlinclude.patch " .
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
"f=rpm/redhat/master/pgbackrest/master/pgbackrest-libxmlinclude.patch;hb=refs/heads/master' && " .
"wget -q -O /root/package-src/pgbackrest.spec " .
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
"f=rpm/redhat/master/pgbackrest/master/pgbackrest.spec;hb=refs/heads/master'\"");
# Create build directories # Create build directories
$oStorageBackRest->pathCreate($strBuildPath, {bIgnoreExists => true, bCreateParent => true}); $oStorageBackRest->pathCreate($strBuildPath, {bIgnoreExists => true, bCreateParent => true});
$oStorageBackRest->pathCreate("${strBuildPath}/SOURCES", {bIgnoreExists => true, bCreateParent => true}); $oStorageBackRest->pathCreate("${strBuildPath}/SOURCES", {bIgnoreExists => true, bCreateParent => true});