Skip to content

Commit

Permalink
pg_dump, pg_dumpall, pg_restore 14.2 (#20)
Browse files Browse the repository at this point in the history
postgresql-client static build
  • Loading branch information
hemnstill authored Apr 28, 2022
1 parent be20917 commit 50733c7
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/pg_dump.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) <br/>[![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) |
53 changes: 53 additions & 0 deletions pg_dump/build_mingw.sh
Original file line number Diff line number Diff line change
@@ -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 .
63 changes: 63 additions & 0 deletions pg_dump/build_musl.sh
Original file line number Diff line number Diff line change
@@ -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 .
65 changes: 65 additions & 0 deletions pg_dump/release/Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 50733c7

Please sign in to comment.