Skip to content

Commit fc29c2f

Browse files
committed
Initial project
0 parents  commit fc29c2f

File tree

10 files changed

+928
-0
lines changed

10 files changed

+928
-0
lines changed

.github/workflows/build.yml

Lines changed: 504 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
initialize:
16+
name: Initialize
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Get PR head ref
20+
if: ${{ github.event_name == 'pull_request' }}
21+
id: pr_head_ref
22+
run: |
23+
echo "ref=refs/pull/${{ github.event.pull_request.number }}/head" >> $GITHUB_OUTPUT
24+
outputs:
25+
ref: >-
26+
${{
27+
(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/v'))
28+
&& steps.pr_head_ref.outputs.ref
29+
|| github.ref
30+
}}
31+
32+
build:
33+
name: Build
34+
needs: [initialize]
35+
uses: ./.github/workflows/build.yml
36+
with:
37+
ref: ${{ needs.initialize.outputs.ref }}
38+

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create_release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout source
17+
uses: actions/checkout@v4
18+
- name: Get the release version from the tag
19+
if: env.VERSION == ''
20+
run: echo "VERSION=${{ github.ref_name }}" | tee -a $GITHUB_ENV
21+
- name: Display the version
22+
run: |
23+
echo "version is: $VERSION"
24+
- name: Create GitHub release
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: gh release create "${VERSION}" --draft --verify-tag --title $VERSION
28+
outputs:
29+
version: ${{ env.VERSION }}
30+
31+
build:
32+
name: Build & Release
33+
needs: [create_release]
34+
uses: ./.github/workflows/build.yml
35+
with:
36+
release: true
37+
38+
publish_release:
39+
name: Publish Release
40+
needs: [build]
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout source
44+
uses: actions/checkout@v4
45+
- name: Get the release version from the tag
46+
if: env.VERSION == ''
47+
run: echo "VERSION=${{ github.ref_name }}" | tee -a $GITHUB_ENV
48+
- name: Display the version
49+
run: |
50+
echo "version is: $VERSION"
51+
- name: Publish GitHub release
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: gh release edit "${VERSION}" --draft=false
55+
outputs:
56+
version: ${{ env.VERSION }}
57+

.gitignore

Whitespace-only changes.

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2024, Theseus
2+
3+
Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
4+
5+
IN NO EVENT SHALL Theseus BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF Theseus HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6+
7+
Theseus SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN “AS IS” BASIS, AND Theseus HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Postgresql Binaries
2+
3+
---
4+
[![CI](https://github.com/theseus-rs/postgresql_binaries/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/theseus-rs/postgresql_binaries/actions?query=workflow%3Aci+branch%3Amain)
5+
[![License](https://img.shields.io/github/license/theseus-rs/postgresql_binaries)](./LICENSE)
6+
7+
Postgresql binaries for Linux, MacOS and Windows; releases aligned with Rust [supported platforms](https://doc.rust-lang.org/nightly/rustc/platform-support.html).
8+
9+
## Choosing an installation package
10+
11+
Installation packages use the pattern `postgresql-<version>-<target>.<extension>`, where`<version>` is the
12+
postgresql version, `<target>` is the target triple for the platform, and `<extension>` is the archive file
13+
extension. To find the `<target>` triple for your platform run `rustc -vV` and look for the value of the
14+
`host` field. The target triple can be obtained programmatically in rust using the [target-triple](https://crates.io/crates/target-triple) crate.
15+
16+
## Versioning
17+
18+
This project uses a versioning scheme that is compatible with [postgresql versioning](https://www.postgresql.org/support/versioning/).
19+
The version comprises `<postgres major>.<postgres minor>.<release>` where `<release>` is the release for
20+
this projects build of a version of postgresql. New releases of this project will be made when new versions
21+
of postgresql are released or new builds of existing versions are required for bug fixes, new targets, etc.
22+
23+
## License
24+
25+
PostgreSQL is covered under [The PostgreSQL License](https://opensource.org/licenses/postgresql).

dockerfiles/Dockerfile.linux-gnu

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
FROM debian:12.4
2+
3+
ARG POSTGRESQL_VERSION
4+
5+
RUN apt-get update && \
6+
apt-get install -y --no-install-recommends \
7+
bison \
8+
build-essential \
9+
clang-16 \
10+
flex \
11+
fop \
12+
gettext \
13+
git \
14+
libicu-dev \
15+
libkrb5-dev \
16+
libldap-dev \
17+
liblz4-dev \
18+
libossp-uuid-dev \
19+
libperl-dev \
20+
libreadline-dev \
21+
libssl-dev \
22+
libxml2-dev \
23+
libxml2-utils \
24+
libxslt-dev \
25+
libz-dev \
26+
libzstd-dev \
27+
llvm-16 \
28+
lz4 \
29+
make \
30+
meson \
31+
ninja-build \
32+
openssl \
33+
patchelf \
34+
perl \
35+
pkg-config \
36+
python3 \
37+
python3-dev \
38+
tcl \
39+
tcl-dev \
40+
wget \
41+
xsltproc \
42+
zstd
43+
44+
RUN branch=$(echo "$POSTGRESQL_VERSION" | awk -F. '{print "REL_"$1"_"$2}') && \
45+
echo "branch=$branch" && \
46+
git config --global http.version HTTP/1.1 && \
47+
git config --global http.sslVerify false && \
48+
for i in $(seq 1 5); do \
49+
git clone --depth 1 --branch $branch -c advice.detachedHead=false https://git.postgresql.org/git/postgresql.git /usr/src/postgresql \
50+
&& break || sleep 3; \
51+
done
52+
53+
WORKDIR /usr/src/postgresql
54+
55+
ENV CLANG=clang-16
56+
ENV LLVM_CONFIG="/usr/lib/llvm-16/bin/llvm-config"
57+
58+
RUN major_version=$(echo "$POSTGRESQL_VERSION" | awk -F. '{print $1}') && \
59+
./configure \
60+
--prefix /opt/postgresql \
61+
--enable-integer-datetimes \
62+
--enable-option-checking=fatal \
63+
--enable-thread-safety \
64+
--with-gssapi \
65+
$([ $major_version -ge 14 ] && echo "--with-icu" || echo "--without-icu") \
66+
$([ $major_version -ge 11 ] && echo "--with-ldap") \
67+
--with-libxml \
68+
--with-libxslt \
69+
$([ $major_version -ge 14 ] && echo "--with-lz4") \
70+
--with-openssl \
71+
--with-perl \
72+
--with-pgport=5432 \
73+
$([ $major_version -ge 15 ] && echo "--with-python") \
74+
--with-readline \
75+
--with-system-tzdata=/usr/share/zoneinfo \
76+
--with-tcl \
77+
--with-uuid=ossp \
78+
$([ $major_version -ge 16 ] && echo "--with-zstd") && \
79+
make $([ $major_version -ge 15 ] && echo "world-bin") && \
80+
make $([ $major_version -ge 15 ] && echo "install-world-bin" || echo "install") && \
81+
make -C contrib install
82+
83+
# Update binary rpath to use a relative path.
84+
# LD_FLAGS=-Wl,-rpath,'$ORIGIN/../lib' should be used instead, but does not appear to work.
85+
RUN cd /opt/postgresql/bin && \
86+
rpath=$(patchelf --print-rpath postgres | sed 's|/opt/postgresql/lib|$ORIGIN/../lib|g') && \
87+
find ./ -type f | xargs -L 1 patchelf --set-rpath $rpath
88+
89+
RUN cp /usr/src/postgresql/COPYRIGHT /opt/postgresql
90+
91+
# Create user and group for running tests
92+
RUN groupadd --system --gid 1000 postgresql && \
93+
useradd --system --gid postgresql --uid 1000 --shell /bin/bash --create-home postgresql && \
94+
mkdir -p /opt/test && \
95+
chown postgresql:postgresql /opt/test
96+
97+
USER postgresql

dockerfiles/Dockerfile.linux-musl

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
FROM alpine:3.19.0
2+
3+
ARG POSTGRESQL_VERSION
4+
5+
RUN echo "POSTGRESQL_VERSION=$POSTGRESQL_VERSION"
6+
RUN apk update
7+
RUN apk add --no-cache \
8+
bash \
9+
bison \
10+
clang16 \
11+
dpkg \
12+
dpkg-dev \
13+
e2fsprogs-dev \
14+
flex \
15+
g++ \
16+
gcc \
17+
gettext-dev \
18+
git \
19+
icu-dev \
20+
krb5-dev \
21+
libc-dev \
22+
libxml2-dev \
23+
libxslt-dev \
24+
linux-headers \
25+
llvm16-dev \
26+
lz4 \
27+
lz4-dev \
28+
make \
29+
meson \
30+
musl-dev \
31+
ninja-build \
32+
openldap-dev \
33+
openssl-dev \
34+
ossp-uuid-dev \
35+
patchelf \
36+
perl \
37+
perl-dev \
38+
perl-ipc-run \
39+
perl-utils \
40+
python3 \
41+
python3-dev \
42+
readline-dev \
43+
tcl \
44+
tcl-dev \
45+
util-linux-dev \
46+
zlib-dev \
47+
zstd-dev
48+
49+
RUN branch=$(echo "$POSTGRESQL_VERSION" | awk -F. '{print "REL_"$1"_"$2}') && \
50+
echo "branch=$branch" && \
51+
git config --global http.version HTTP/1.1 && \
52+
git config --global http.sslVerify false && \
53+
for i in $(seq 1 5); do \
54+
git clone --depth 1 --branch $branch -c advice.detachedHead=false https://git.postgresql.org/git/postgresql.git /usr/src/postgresql \
55+
&& break || sleep 3; \
56+
done
57+
58+
WORKDIR /usr/src/postgresql
59+
60+
ENV CLANG=clang-16
61+
ENV LLVM_CONFIG="/usr/lib/llvm16/bin/llvm-config"
62+
63+
RUN major_version=$(echo "$POSTGRESQL_VERSION" | awk -F. '{print $1}') && \
64+
./configure \
65+
--prefix /opt/postgresql \
66+
--enable-integer-datetimes \
67+
--enable-option-checking=fatal \
68+
--enable-tap-tests \
69+
--enable-thread-safety \
70+
--with-gssapi \
71+
$([ $major_version -ge 14 ] && echo "--with-icu" || echo "--without-icu") \
72+
$([ $major_version -ge 14 ] && echo "--with-ldap") \
73+
--with-libxml \
74+
--with-libxslt \
75+
$([ $major_version -ge 16 ] && echo "--with-llvm") \
76+
$([ $major_version -ge 14 ] && echo "--with-lz4") \
77+
--with-openssl \
78+
--with-perl \
79+
--with-pgport=5432 \
80+
$([ $major_version -ge 15 ] && echo "--with-python") \
81+
--with-readline \
82+
--with-system-tzdata=/usr/share/zoneinfo \
83+
--with-tcl \
84+
--with-uuid=ossp \
85+
$([ $major_version -ge 16 ] && echo "--with-zstd") && \
86+
make $([ $major_version -ge 15 ] && echo "world-bin") && \
87+
make $([ $major_version -ge 15 ] && echo "install-world-bin" || echo "install") && \
88+
make -C contrib install
89+
90+
# Update binary rpath to use a relative path.
91+
# LD_FLAGS=-Wl,-rpath,'$ORIGIN/../lib' should be used instead, but does not appear to work.
92+
RUN cd /opt/postgresql/bin && \
93+
rpath=$(patchelf --print-rpath postgres | sed 's|/opt/postgresql/lib|$ORIGIN/../lib|g') && \
94+
find ./ -type f -print0 | while IFS= read -r -d '' file; do patchelf --set-rpath $rpath $file; done
95+
96+
RUN cp /usr/src/postgresql/COPYRIGHT /opt/postgresql
97+
98+
# Create user and group for running tests
99+
RUN addgroup -S -g 1000 postgresql && \
100+
adduser -D -S -G postgresql -u 1000 -s /bin/ash postgresql && \
101+
mkdir -p /opt/test && \
102+
chown postgresql:postgresql /opt/test
103+
104+
USER postgresql

0 commit comments

Comments
 (0)