From 5b491b3035502819a31e1200636c8d2757a78a18 Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 26 Feb 2018 19:32:27 -0500 Subject: [PATCH] Add CentOS/RHEL package builds. --- doc/xml/release.xml | 8 +++ .../pgBackRestTest/Common/ContainerTest.pm | 14 ++++- test/patch/rhel-package.patch | 41 +++++++++++++ test/test.pl | 60 +++++++++++++++++++ 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 test/patch/rhel-package.patch diff --git a/doc/xml/release.xml b/doc/xml/release.xml index ef1ccb9e7..7e3a4eec8 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -28,6 +28,14 @@ + + + + +

Add CentOS/RHEL package builds.

+
+
+
diff --git a/test/lib/pgBackRestTest/Common/ContainerTest.pm b/test/lib/pgBackRestTest/Common/ContainerTest.pm index 88c1af4cd..8a52449a4 100755 --- a/test/lib/pgBackRestTest/Common/ContainerTest.pm +++ b/test/lib/pgBackRestTest/Common/ContainerTest.pm @@ -577,7 +577,19 @@ sub containerBuild } else { - $strScript = ''; + $strScript = sectionHeader() . + "# Install package build tools\n" . + " yum install -y rpm-build"; + + $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.spec " . + "'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" . + "f=rpm/redhat/master/pgbackrest/master/pgbackrest.spec;hb=refs/heads/master'"; } containerWrite($oStorageDocker, $strTempPath, $strOS, 'Build', $strImageParent, $strImage, $strCopy,$strScript, $bVmForce); diff --git a/test/patch/rhel-package.patch b/test/patch/rhel-package.patch new file mode 100644 index 000000000..4145cffec --- /dev/null +++ b/test/patch/rhel-package.patch @@ -0,0 +1,41 @@ +--- pgbackrest.spec ++++ pgbackrest.spec +@@ -2,7 +2,7 @@ + + Summary: Reliable PostgreSQL Backup & Restore + Name: pgbackrest +-Version: 1.28 ++Version: 2.00 + Release: 1%{?dist} + License: MIT + Group: Applications/Databases +@@ -33,6 +33,10 @@ + %{__make} + popd + ++pushd src ++%{__make} ++popd ++ + %install + %{__install} -D -d -m 0755 %{buildroot}%{perl_vendorlib} %{buildroot}%{_bindir} + %{__install} -D -d -m 0700 %{buildroot}/%{_sharedstatedir}/%{name} +@@ -46,7 +50,7 @@ + %{__cp} -a libc/blib/lib/auto/pgBackRest/LibC/* %{buildroot}%{perl_vendorarch}/auto/pgBackRest/LibC + %{__mkdir} -p %{buildroot}%{perl_vendorarch}/pgBackRest + %{__cp} -a libc/blib/lib/pgBackRest/* %{buildroot}%{perl_vendorarch}/pgBackRest +-%{__cp} -a bin/%{name} %{buildroot}%{_bindir}/%{name} ++%{__cp} -a src/%{name} %{buildroot}%{_bindir}/%{name} + + %clean + %{__rm} -rf %{buildroot} +@@ -68,6 +72,9 @@ + %attr(-,postgres,postgres) /var/spool/%{name} + + %changelog ++* Mon Feb 26 2018 - David Steele 2.00-1 ++- Build C pgbackrest bin, remove Perl bin ++ + * Sun Feb 4 2018 - Devrim Gündüz 1.28-1 + - Update to 1.28, per #3078 + diff --git a/test/test.pl b/test/test.pl index 345ddffe7..9408cf6f3 100755 --- a/test/test.pl +++ b/test/test.pl @@ -766,6 +766,66 @@ eval executeTest("docker rm -f test-build"); } + + if (!$oStorageBackRest->pathExists($strBuildPath) && $oVm->{$strBuildVM}{&VM_OS_BASE} eq VM_OS_BASE_RHEL) + { + &log(INFO, "build package for ${strBuildVM} (${strBuildPath})"); + + # Create build container + executeTest( + "docker run -itd -h test-build --name=test-build" . + " -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-build", + {bSuppressStdErr => true}); + + # Create build directories + $oStorageBackRest->pathCreate($strBuildPath, {bIgnoreExists => true, bCreateParent => true}); + $oStorageBackRest->pathCreate("${strBuildPath}/SOURCES", {bIgnoreExists => true, bCreateParent => true}); + $oStorageBackRest->pathCreate("${strBuildPath}/SPECS", {bIgnoreExists => true, bCreateParent => true}); + $oStorageBackRest->pathCreate("${strBuildPath}/RPMS", {bIgnoreExists => true, bCreateParent => true}); + $oStorageBackRest->pathCreate("${strBuildPath}/BUILD", {bIgnoreExists => true, bCreateParent => true}); + + # Copy source files + executeTest( + "tar --transform='s_^_pgbackrest-release-${strVersionBase}/_'" . + " -czf ${strBuildPath}/SOURCES/${strVersionBase}.tar.gz -C ${strBackRestBase}" . + " lib libc src LICENSE"); + + # Copy package files + executeTest( + "docker exec -i test-build bash -c '" . + "ln -s ${strBuildPath} /root/rpmbuild && " . + "cp /root/package-src/pgbackrest.spec ${strBuildPath}/SPECS && " . + "cp /root/package-src/*.patch ${strBuildPath}/SOURCES && " . + "sudo chown -R " . TEST_USER . " ${strBuildPath}'"); + + # Patch files in RHEL package builds + # + # Use these commands to create a new patch (may need to modify first line): + # BRDIR=/backrest;BRVM=co7;BRPATCHFILE=${BRDIR?}/test/patch/rhel-package.patch + # PKDIR=${BRDIR?}/test/.vagrant/package/${BRVM}/src/SPECS + # diff -Naur ${PKDIR?}.old ${PKDIR}.new > ${BRPATCHFILE?} + my $strPackagePatch = "${strBackRestBase}/test/patch/rhel-package.patch"; + + if ($oStorageBackRest->exists($strPackagePatch)) + { + executeTest("cp -r ${strBuildPath}/SPECS ${strBuildPath}/SPECS.old"); + executeTest("patch -d ${strBuildPath}/SPECS < ${strPackagePatch}"); + executeTest("cp -r ${strBuildPath}/SPECS ${strBuildPath}/SPECS.new"); + } + + # Update version number to match current version + my $strSpec = ${$oStorageBackRest->get("${strBuildPath}/SPECS/pgbackrest.spec")}; + $strSpec =~ s/^Version\:.*$/Version\:\t${strVersionBase}/gm; + $oStorageBackRest->put("${strBuildPath}/SPECS/pgbackrest.spec", $strSpec); + + # Build package + executeTest( + "docker exec -i test-build rpmbuild -v -bb --clean root/rpmbuild/SPECS/pgbackrest.spec", + {bSuppressStdErr => true}); + + # Remove build container + executeTest("docker rm -f test-build"); + } } # Write files to indicate the last time a build was successful