Skip to content

Commit 9e8eeba

Browse files
authored
feat: Vendor libicu as a BOSH package to fix postgres-16/17/18 on Ubuntu Resolute (#99)
1 parent 85aa5c9 commit 9e8eeba

12 files changed

Lines changed: 155 additions & 26 deletions

File tree

‎ci/pipeline.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ jobs:
4545
trigger: true
4646
- get: postgres-18-src
4747
trigger: true
48+
- get: icu-src
49+
trigger: true
50+
params:
51+
globs:
52+
- icu4c-*-sources.tgz
53+
- SHASUM512.txt
4854
- get: yq-release
4955
trigger: true
5056
params:
@@ -61,6 +67,15 @@ jobs:
6167
options:
6268
access_key_id: ((postgres-release-blobstore-user.username))
6369
secret_access_key: ((postgres-release-blobstore-user.password))
70+
- task: bump-libicu-package
71+
file: postgres-release/ci/tasks/bump-libicu-package/task.yml
72+
image: bosh-integration-image
73+
params:
74+
PRIVATE_YML: |
75+
blobstore:
76+
options:
77+
access_key_id: ((postgres-release-blobstore-user.username))
78+
secret_access_key: ((postgres-release-blobstore-user.password))
6479
- task: bump-postgres-15-package
6580
file: postgres-release/ci/tasks/bump-postgres-packages/task.yml
6681
image: bosh-integration-image
@@ -321,6 +336,16 @@ resources:
321336
regex: 'href="v(?P<version>18\.[0-9.]+)/"'
322337
uri: "https://ftp.postgresql.org/pub/source/v{version}/postgresql-{version}.tar.gz"
323338

339+
- name: icu-src
340+
type: github-release
341+
source:
342+
owner: unicode-org
343+
repository: icu
344+
tag_filter: release-([0-9]+\.[0-9]+)
345+
access_token: ((github_public_repo_token))
346+
globs:
347+
- icu4c-*-sources.tgz
348+
324349
- name: yq-release
325350
type: github-release
326351
source:
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
NEED_COMMIT=false
3+
4+
set -euo pipefail
5+
6+
echo "${PRIVATE_YML}" > postgres-release/config/private.yml
7+
8+
get_old_blob_path() {
9+
local blobs_file="config/blobs.yml"
10+
if grep -q "^icu/" "$blobs_file"; then
11+
grep "^icu/" "$blobs_file" | head -1 | cut -f1 -d:
12+
else
13+
echo ""
14+
fi
15+
}
16+
17+
pushd postgres-release
18+
CURRENT_BLOBS=$(bosh blobs)
19+
BLOB_PATH=$(echo ../icu-src/icu4c-*-sources.tgz)
20+
FILENAME=$(basename "${BLOB_PATH}")
21+
22+
expected_sha512=$(awk -v fname="${FILENAME}" '$0 ~ ("\\*" fname "$") {print $1}' ../icu-src/SHASUM512.txt)
23+
actual_sha512=$(sha512sum "${BLOB_PATH}" | awk '{print $1}')
24+
if [ "$expected_sha512" != "$actual_sha512" ]; then
25+
echo "SHA-512 verification failed for ${FILENAME}"
26+
echo "Expected: $expected_sha512"
27+
echo "Actual: $actual_sha512"
28+
exit 1
29+
fi
30+
echo "SHA-512 verified: $actual_sha512"
31+
32+
OLD_BLOB_PATH=$(get_old_blob_path)
33+
34+
if ! echo "${CURRENT_BLOBS}" | grep -q "${FILENAME}"; then
35+
NEED_COMMIT=true
36+
echo "adding ${FILENAME}"
37+
bosh add-blob --sha2 "${BLOB_PATH}" "icu/${FILENAME}"
38+
if [[ -n "${OLD_BLOB_PATH}" ]]; then
39+
bosh remove-blob "${OLD_BLOB_PATH}"
40+
fi
41+
bosh upload-blobs
42+
fi
43+
44+
if [ "${NEED_COMMIT}" = "true" ]; then
45+
echo "-----> $(date): Creating git commit"
46+
git config user.name "$GIT_USER_NAME"
47+
git config user.email "$GIT_USER_EMAIL"
48+
git add .
49+
50+
git --no-pager diff --cached
51+
if [[ "$( git status --porcelain )" != "" ]]; then
52+
git commit -am "Bump packages"
53+
fi
54+
fi
55+
popd
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
platform: linux
3+
4+
inputs:
5+
- name: postgres-release
6+
- name: icu-src
7+
8+
outputs:
9+
- name: postgres-release
10+
11+
run:
12+
path: postgres-release/ci/tasks/bump-libicu-package/task.sh
13+
14+
params:
15+
PRIVATE_YML:
16+
GIT_USER_NAME: CI Bot
17+
GIT_USER_EMAIL: bots@cloudfoundry.org

‎packages/postgres-15/packaging‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ function extract_archive() {
1717
function compile() {
1818

1919
pushd postgresql-* > /dev/null
20-
if [[ "$(uname -a)" =~ "x86_64" || "$(uname -a)" =~ "ppc64le" ]] ; then
20+
ARCH=$(uname -m)
21+
if [[ "$ARCH" == "x86_64" || "$ARCH" == "ppc64le" ]]; then
2122
./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2223
else
23-
CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
24+
CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2425
fi
2526

2627
pushd src/bin/pg_config > /dev/null

‎packages/postgres-16/packaging‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
#!/bin/bash -exu
1+
#!/bin/bash
2+
3+
set -euo pipefail
24

35
function main() {
46
extract_archive
57
compile
6-
78
}
89

910
function extract_archive() {
10-
1111
echo "Extracting archive..."
1212
tar xzf postgres/postgresql-*
13-
1413
}
1514

1615
function compile() {
17-
1816
pushd postgresql-* > /dev/null
19-
if [[ "$(uname -a)" =~ "x86_64" || "$(uname -a)" =~ "ppc64le" ]] ; then
20-
ICU_CFLAGS=" " ICU_LIBS="-L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata" ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
17+
ARCH=$(uname -m)
18+
if [[ "$ARCH" == "x86_64" || "$ARCH" == "ppc64le" ]]; then
19+
ICU_CFLAGS="-I${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/include" \
20+
ICU_LIBS="-L${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/lib -licui18n -licuuc -licudata -lstdc++" \
21+
./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2122
else
22-
ICU_CFLAGS=" " ICU_LIBS="-L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata" CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
23+
ICU_CFLAGS="-I${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/include" \
24+
ICU_LIBS="-L${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/lib -licui18n -licuuc -licudata -lstdc++" \
25+
CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2326
fi
2427

2528
pushd src/bin/pg_config > /dev/null

‎packages/postgres-16/spec‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
name: postgres-16
3+
dependencies:
4+
- postgres-libicu
35
files:
46
- postgres/postgresql-16.*.tar.gz

‎packages/postgres-17/packaging‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
#!/bin/bash -exu
1+
#!/bin/bash
2+
3+
set -euo pipefail
24

35
function main() {
46
extract_archive
57
compile
6-
78
}
89

910
function extract_archive() {
10-
1111
echo "Extracting archive..."
1212
tar xzf postgres/postgresql-*
13-
1413
}
1514

1615
function compile() {
17-
1816
pushd postgresql-* > /dev/null
19-
if [[ "$(uname -a)" =~ "x86_64" || "$(uname -a)" =~ "ppc64le" ]] ; then
20-
ICU_CFLAGS=" " ICU_LIBS="-L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata" ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
17+
ARCH=$(uname -m)
18+
if [[ "$ARCH" == "x86_64" || "$ARCH" == "ppc64le" ]]; then
19+
ICU_CFLAGS="-I${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/include" \
20+
ICU_LIBS="-L${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/lib -licui18n -licuuc -licudata -lstdc++" \
21+
./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2122
else
22-
ICU_CFLAGS=" " ICU_LIBS="-L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata" CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
23+
ICU_CFLAGS="-I${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/include" \
24+
ICU_LIBS="-L${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/lib -licui18n -licuuc -licudata -lstdc++" \
25+
CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2326
fi
2427

2528
pushd src/bin/pg_config > /dev/null

‎packages/postgres-17/spec‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
name: postgres-17
3+
dependencies:
4+
- postgres-libicu
35
files:
46
- postgres/postgresql-17.*.tar.gz

‎packages/postgres-18/packaging‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
#!/bin/bash -exu
1+
#!/bin/bash
2+
3+
set -euo pipefail
24

35
function main() {
46
extract_archive
57
compile
6-
78
}
89

910
function extract_archive() {
10-
1111
echo "Extracting archive..."
1212
tar xzf postgres/postgresql-*
13-
1413
}
1514

1615
function compile() {
17-
1816
pushd postgresql-* > /dev/null
19-
if [[ "$(uname -a)" =~ "x86_64" || "$(uname -a)" =~ "ppc64le" ]] ; then
20-
ICU_CFLAGS=" " ICU_LIBS="-L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata" ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
17+
ARCH=$(uname -m)
18+
if [[ "$ARCH" == "x86_64" || "$ARCH" == "ppc64le" ]]; then
19+
ICU_CFLAGS="-I${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/include" \
20+
ICU_LIBS="-L${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/lib -licui18n -licuuc -licudata -lstdc++" \
21+
./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2122
else
22-
ICU_CFLAGS=" " ICU_LIBS="-L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata" CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
23+
ICU_CFLAGS="-I${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/include" \
24+
ICU_LIBS="-L${BOSH_PACKAGES_PATH:-/var/vcap/packages}/postgres-libicu/lib -licui18n -licuuc -licudata -lstdc++" \
25+
CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix="${BOSH_INSTALL_TARGET}" --with-openssl
2326
fi
2427

2528
pushd src/bin/pg_config > /dev/null

‎packages/postgres-18/spec‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
name: postgres-18
3+
dependencies:
4+
- postgres-libicu
35
files:
46
- postgres/postgresql-18.*.tar.gz
57

0 commit comments

Comments
 (0)