From 50733c7c8d9b63bfdea70c1c35b749c6140242d8 Mon Sep 17 00:00:00 2001 From: Alexandr Reshetnikov Date: Thu, 28 Apr 2022 23:44:14 +0400 Subject: [PATCH] pg_dump, pg_dumpall, pg_restore 14.2 (#20) postgresql-client static build --- .github/workflows/pg_dump.yml | 58 +++++++++++++++++++++++++++++++ README.md | 1 + pg_dump/build_mingw.sh | 53 ++++++++++++++++++++++++++++ pg_dump/build_musl.sh | 63 +++++++++++++++++++++++++++++++++ pg_dump/release/Makefile | 65 +++++++++++++++++++++++++++++++++++ 5 files changed, 240 insertions(+) create mode 100644 .github/workflows/pg_dump.yml create mode 100755 pg_dump/build_mingw.sh create mode 100755 pg_dump/build_musl.sh create mode 100644 pg_dump/release/Makefile diff --git a/.github/workflows/pg_dump.yml b/.github/workflows/pg_dump.yml new file mode 100644 index 000000000..eda3edaad --- /dev/null +++ b/.github/workflows/pg_dump.yml @@ -0,0 +1,58 @@ +name: pg_dump + +on: [pull_request, workflow_dispatch] + +jobs: + prejob: + uses: ./.github/workflows/set-output-workflow.yml + with: + workflow: ${{ github.workflow }} + secrets: + _WORKFLOW: ${{ secrets._CURRENT_TOOL }} + + alpine-musl: + needs: prejob + if: ${{ needs.prejob.outputs.workflow == github.workflow }} + uses: ./.github/workflows/build-alpine.yml + with: + workflow: ${{ github.workflow }} + + alpine-mingw: + needs: prejob + if: ${{ needs.prejob.outputs.workflow == github.workflow }} + uses: ./.github/workflows/build-alpine.yml + with: + workflow: ${{ github.workflow }} + toolset: mingw + + ubuntu-glibc-test: + needs: alpine-musl + if: ${{ needs.prejob.outputs.workflow == github.workflow }} + uses: ./.github/workflows/test-ubuntu.yml + with: + artifact: build-musl + test-run: | + ./${{ github.workflow }} --version + + windows-mingw-test: + needs: alpine-mingw + if: ${{ needs.prejob.outputs.workflow == github.workflow }} + uses: ./.github/workflows/test-windows.yml + with: + artifact: build-mingw + test-run: | + ./${{ github.workflow }} --version + + release: + needs: [ubuntu-glibc-test, + windows-mingw-test] + uses: ./.github/workflows/release.yml + with: + workflow: ${{ github.workflow }} + tool_version: '14.2' + prepare_body: | + bsdtar -Oxf ./build-musl/build-musl.tar.gz build-musl.md >> body.md + bsdtar -Oxf ./build-mingw/build-mingw.tar.gz build-mingw.md >> body.md + artifacts: ./build-musl/build-musl.tar.gz,./build-mingw/build-mingw.tar.gz + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index cfda005c5..a627ddb17 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,4 @@ | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/pcre2grep-10.39/total?label=⭳%20pcre2grep-10.39)](https://github.com/hemnstill/StandaloneTools/releases/tag/pcre2grep-10.39) | [![GitHub Repo stars](https://img.shields.io/github/stars/PhilipHazel/pcre2?style=social&label=PCRE2)](https://github.com/PhilipHazel/pcre2) | | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/openssl-3.0.1/total?label=⭳%20openssl-3.0.1)](https://github.com/hemnstill/StandaloneTools/releases/tag/openssl-3.0.1)
[![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/openssl-1_1_1m/total?label=⭳%20openssl-1_1_1m)](https://github.com/hemnstill/StandaloneTools/releases/tag/openssl-1_1_1m) | [![GitHub Repo stars](https://img.shields.io/github/stars/openssl/openssl?style=social&label=OpenSSL)](https://github.com/openssl/openssl) | | [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/far2l-2.4.0-beta/total?label=⭳%20far2l-2.4.0-beta)](https://github.com/hemnstill/StandaloneTools/releases/tag/far2l-2.4.0-beta) | [![GitHub Repo stars](https://img.shields.io/github/stars/elfmz/far2l?style=social&label=far2l)](https://github.com/elfmz/far2l) | +| [![GitHub release (by tag)](https://img.shields.io/github/downloads/hemnstill/StandaloneTools/pg_dump-14.2/total?label=⭳%20pg_dump-14.2)](https://github.com/hemnstill/StandaloneTools/releases/tag/pg_dump-14.2) | [![GitHub Repo stars](https://img.shields.io/github/stars/postgres/postgres?style=social&label=postgres)](https://github.com/postgres/postgres) | diff --git a/pg_dump/build_mingw.sh b/pg_dump/build_mingw.sh new file mode 100755 index 000000000..88454b4c9 --- /dev/null +++ b/pg_dump/build_mingw.sh @@ -0,0 +1,53 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +set -e + +echo "::group::install deps" + +apk update +apk add --no-cache alpine-sdk linux-headers zlib-dev zlib-static postgresql-dev perl-dev bison flex mingw-w64-gcc icu-dev + +echo "::endgroup::" + +tool_name="pg_dump.exe" +tool_version="REL_14_2" +echo "::set-output name=tool_name::$tool_name" +echo "::set-output name=tool_version::$tool_version" + +download_url="https://github.com/postgres/postgres/archive/refs/tags/$tool_version.tar.gz" +echo "::group::prepare sources $download_url" + +tool_root_path="$dp0/release/postgres-$tool_version" + +mkdir -p "$dp0/release/build" && cd "$dp0/release" + +if [[ ! -f "$tool_root_path/configure" ]]; then + wget "$download_url" -O "tool-$tool_version.tar.gz" && tar -xf "tool-$tool_version.tar.gz" +fi + +cd "$tool_root_path" + +echo "::endgroup::" + +echo "::group::build" + +./configure --without-readline --without-zlib --with-system-tzdata=/usr/share/zoneinfo --host=x86_64-w64-mingw32 +make -j$(nproc) + +echo "::endgroup::" + +cp "$tool_root_path/src/bin/pg_dump/pg_dump.exe" "$dp0/release/build/" +cp "$tool_root_path/src/bin/pg_dump/pg_dumpall.exe" "$dp0/release/build/" +cp "$tool_root_path/src/bin/pg_dump/pg_restore.exe" "$dp0/release/build/" +cp "$tool_root_path/src/interfaces/libpq/libpq.dll" "$dp0/release/build/" + +cd "$dp0/release/build" + +{ printf 'SHA-256: %s +%s +' "$(sha256sum $tool_name)" "$download_url" +} > build-mingw.md + +cat build-mingw.md + +tar -czvf ../build-mingw.tar.gz . diff --git a/pg_dump/build_musl.sh b/pg_dump/build_musl.sh new file mode 100755 index 000000000..9ed052158 --- /dev/null +++ b/pg_dump/build_musl.sh @@ -0,0 +1,63 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +set -e + +echo "::group::install deps" + +apk update +apk add --no-cache alpine-sdk linux-headers zlib-dev zlib-static postgresql-dev perl-dev bison flex libpq-dev + +echo "::endgroup::" + +tool_name="pg_dump" +tool_version="REL_14_2" +echo "::set-output name=tool_name::$tool_name" +echo "::set-output name=tool_version::$tool_version" + +download_url="https://github.com/postgres/postgres/archive/refs/tags/$tool_version.tar.gz" +echo "::group::prepare sources $download_url" + +tool_root_path="$dp0/release/postgres-$tool_version" + +mkdir -p "$dp0/release/build" && cd "$dp0/release" + +if [[ ! -f "$tool_root_path/configure" ]]; then + wget "$download_url" -O "tool-$tool_version.tar.gz" && tar -xf "tool-$tool_version.tar.gz" +fi + +cp "$dp0/release/Makefile" "$tool_root_path/src/bin/pg_dump/" + +cd "$tool_root_path" + +echo "::endgroup::" + +echo "::group::build" + +./configure --without-readline --without-zlib + +make -j$(nproc) + +echo "::endgroup::" + +cp "$tool_root_path/src/bin/pg_dump/pg_dump" "$dp0/release/build/" +cp "$tool_root_path/src/bin/pg_dump/pg_dumpall" "$dp0/release/build/" +cp "$tool_root_path/src/bin/pg_dump/pg_restore" "$dp0/release/build/" + +cd "$dp0/release/build" + +strip "$tool_name" +strip "pg_dumpall" +strip "pg_restore" + +chmod +x "$tool_name" +chmod +x "pg_dumpall" +chmod +x "pg_restore" + +{ printf 'SHA-256: %s +%s +' "$(sha256sum $tool_name)" "$("./$tool_name" --version)" +} > build-musl.md + +cat build-musl.md + +tar -czvf ../build-musl.tar.gz . diff --git a/pg_dump/release/Makefile b/pg_dump/release/Makefile new file mode 100644 index 000000000..2f8d3c009 --- /dev/null +++ b/pg_dump/release/Makefile @@ -0,0 +1,65 @@ +#------------------------------------------------------------------------- +# +# Makefile for src/bin/pg_dump +# +# Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group +# Portions Copyright (c) 1994, Regents of the University of California +# +# src/bin/pg_dump/Makefile +# +#------------------------------------------------------------------------- + +PGFILEDESC = "pg_dump/pg_restore/pg_dumpall - backup and restore PostgreSQL databases" +PGAPPICON=win32 + +subdir = src/bin/pg_dump +top_builddir = ../../.. +include $(top_builddir)/src/Makefile.global + +override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) +LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) -static + +OBJS = \ + $(WIN32RES) \ + compress_io.o \ + dumputils.o \ + parallel.o \ + pg_backup_archiver.o \ + pg_backup_custom.o \ + pg_backup_db.o \ + pg_backup_directory.o \ + pg_backup_null.o \ + pg_backup_tar.o \ + pg_backup_utils.o + +all: pg_dump pg_restore pg_dumpall + +pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils + $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) + +pg_restore: pg_restore.o $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils + $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) + +pg_dumpall: pg_dumpall.o dumputils.o | submake-libpq submake-libpgport submake-libpgfeutils + $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(WIN32RES) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) + +install: all installdirs + $(INSTALL_PROGRAM) pg_dump$(X) '$(DESTDIR)$(bindir)'/pg_dump$(X) + $(INSTALL_PROGRAM) pg_restore$(X) '$(DESTDIR)$(bindir)'/pg_restore$(X) + $(INSTALL_PROGRAM) pg_dumpall$(X) '$(DESTDIR)$(bindir)'/pg_dumpall$(X) + +installdirs: + $(MKDIR_P) '$(DESTDIR)$(bindir)' + +check: + $(prove_check) + +installcheck: + $(prove_installcheck) + +uninstall: + rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X)) + +clean distclean maintainer-clean: + rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o + rm -rf tmp_check