Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support packaging on Ubuntu 24.04 and Rocky 9 #506

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 52 additions & 11 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
pull_request:
branches: [ POLARDB_11_DEV, POLARDB_11_STABLE ]
paths:
- '.github/workflows/regression-test.yml'
- 'config/**'
- 'contrib/**'
- 'external/**'
- 'src/**'
- 'configure*'
- 'polardb_build.sh'
- '.github/workflows/regression-test.yml'
- 'config/**'
- 'contrib/**'
- 'external/**'
- 'src/**'
- 'configure*'
- 'polardb_build.sh'
# trigger testing manually
workflow_dispatch:

Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
base_image: [ centos7, anolis8, rocky8 ]
base_image: [ centos7, anolis8, rocky8, rocky9 ]
steps:
- name: Fetch source code
uses: actions/checkout@v4
Expand Down Expand Up @@ -60,19 +60,60 @@ jobs:
run: |
sudo chown -R runner:runner `pwd`

release-rpm:
build-and-publish-deb:
runs-on: ubuntu-latest
strategy:
matrix:
base_image: [ ubuntu20.04, ubuntu22.04, ubuntu24.04 ]
steps:
- name: Fetch source code
uses: actions/checkout@v4
- name: Create and start the container
run: |
docker create \
-t \
--name polardb_${{ matrix.base_image }} \
-v `pwd`:/home/postgres/PolarDB-for-PostgreSQL \
polardb/polardb_pg_devel:${{ matrix.base_image }} \
bash && \
docker start polardb_${{ matrix.base_image }}
- name: Build deb package
run: |
docker exec \
polardb_${{ matrix.base_image }} \
bash -c "cd /home/postgres/PolarDB-for-PostgreSQL && \
sudo chown -R postgres:postgres ./ && \
cd ./package/debian && \
if [ -f /etc/bashrc ]; then source /etc/bashrc; fi && \
./build-deb.sh"
- name: Get package name
run: |
cd ./package/debian && DEBNAME=`ls *.deb` && echo "debname=$DEBNAME" >> $GITHUB_ENV
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: ${{ env.debname }}
path: ./package/debian/${{ env.debname }}
compression-level: 0
- name: Change ownership of the source code
run: |
sudo chown -R runner:runner `pwd`

release-packages:
if: startsWith(github.ref, 'refs/tags/')
needs: build-and-publish-rpm
needs: [ build-and-publish-rpm, build-and-publish-deb ]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: |
*.rpm
*.{rpm,deb}
merge-multiple: true
- name: Upload artifacts to release
uses: softprops/action-gh-release@v2
with:
files: |
*.rpm
*.deb
152 changes: 152 additions & 0 deletions package/debian/build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/bin/bash

# build-deb.sh
# Use shell script to build .deb packages.
#
# Copyright (c) 2024, Alibaba Group Holding Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# IDENTIFICATION
# package/debian/build-deb.sh

build_date=${1:-$(date +"%Y%m%d%H%M%S")}
code_commit=$(git rev-parse HEAD || echo unknown)
code_branch=$(git rev-parse --abbrev-ref HEAD || echo unknown)
polar_commit=$(git rev-parse --short=8 HEAD || echo unknown)
pg_version=$(grep AC_INIT ../../configure.in | awk -F'[][]' '{print $4}')
polar_majorversion=2.0.$(echo ${pg_version} | awk -F'[^0-9]+' '{print $1}')
polar_minorversion=$(grep -A 1 '&polar_version' ../../src/backend/utils/misc/guc.c | awk 'NR==2{print}' | awk -F'[."]' '{print $4}').0
polar_release_date=$(grep -A 1 '&polar_release_date' ../../src/backend/utils/misc/guc.c | awk 'NR==2{print}' | awk -F'[,"]' '{print $2}')
polar_version=${polar_majorversion}.${polar_minorversion}
polar_pg_version=${pg_version}.${polar_minorversion}

package=PolarDB
debpkgname=$(grep 'Package:' ./control | awk '{print $2}')
distname=$(grep '^ID=' /etc/os-release | awk -F'=' '{print $2}')
distversion=$(grep 'VERSION_ID=' /etc/os-release | awk -F\" '{print $2}')
arch=$(dpkg --print-architecture)

pkgname=${package}_${polar_pg_version}-${build_date}-${distname}${distversion}_${arch}
rm -rf ./${pkgname}
mkdir -p ${pkgname}/DEBIAN

cat ./control >> ${pkgname}/DEBIAN/control
echo 'Version: '${polar_pg_version}'-'${build_date}'' >> ${pkgname}/DEBIAN/control
echo 'Architecture: '${arch}'' >> ${pkgname}/DEBIAN/control

prefix=/u01/polardb_pg
buildroot=$(pwd)
cd ../../
./polardb_build.sh --basedir=${buildroot}/${pkgname}${prefix} --debug=off --with-pfsd --noinit
cd ${buildroot}

polar_install_dependency()
{
target_dir=${1}

# create link for lib inside lib
cd ${target_dir}/lib/
ln -sf ../lib ./lib

cd ${target_dir}

# generate list of .so files
# collect all the executable binaries, scripts and shared libraries
binfiles=`find ${target_dir}/bin`
libfiles=`find ${target_dir}/lib`
filelist=${binfiles}$'\n'${libfiles}
exelist=`echo $filelist | xargs -r file | egrep -v ":.* (commands|script)" | \
grep ":.*executable" | cut -d: -f1`
scriptlist=`echo $filelist | xargs -r file | \
egrep ":.* (commands|script)" | cut -d: -f1`
liblist=`echo $filelist | xargs -r file | \
grep ":.*shared object" | cut -d : -f1`

# dependency list of the executable binaries and shared libraries
cp /dev/null mytmpfilelist
cp /dev/null mytmpfilelist2

# put PolarDB-PG libs before any other libs to let ldd take it first
export LD_LIBRARY_PATH=${target_dir}/lib:$LD_LIBRARY_PATH:/usr/lib

# dependency list of all binaries and shared objects
for f in $liblist $exelist; do
ldd $f | awk '/=>/ {
if (X$3 != "X" && $3 !~ /libNoVersion.so/ && $3 !~ /4[um]lib.so/ && $3 !~ /libredhat-kernel.so/ && $3 !~ /libselinux.so/ && $3 !~ /\/u01\/polardb_pg/ && $3 !~ /libjvm.so/ && $3 ~ /\.so/) {
# printf "$s => $s\n", $1, $3
print $3
}
}' >> mytmpfilelist
done

# deduplicate
cat mytmpfilelist | sort -u > mytmpfilelist2

for f in `cat mytmpfilelist2`; do
ldd $f | awk '/=>/ {
if (X$3 != "X" && $3 !~ /libNoVersion.so/ && $3 !~ /4[um]lib.so/ && $3 !~ /libredhat-kernel.so/ && $3 !~ /libselinux.so/ && $3 !~ /\/u01\/polardb_pg/ && $3 !~ /libjvm.so/ && $3 ~ /\.so/) {
# printf "$s => $s\n", $1, $3
print $3
}
}' >> mytmpfilelist
done

# deduplicate
cat mytmpfilelist | sort -u > mytmpfilelist2

# copy libraries if necessary
for line in `cat mytmpfilelist2`; do
base=`basename $line`
dirpath=${target_dir}/lib
filepath=$dirpath/$base

objdump -p $line | awk 'BEGIN { START=0; LIBNAME=""; }
/^$/ { START=0; }
/^Dynamic Section:$/ { START=1; }
(START==1) && /NEEDED/ {
print $2 ;
}
(START==2) && /^[A-Za-z]/ { START=3; }
/^Version References:$/ { START=2; }
(START==2) && /required from/ {
sub(/:/, "", $3);
LIBNAME=$3;
}
(START==2) && (LIBNAME!="") && ($4!="") && (($4~/^GLIBC_*/) || ($4~/^GCC_*/)) {
print LIBNAME "(" $4 ")";
}
END { exit 0 }
' > objdumpfile

has_private=
if grep -q PRIVATE objdumpfile; then
has_private=true
fi

if [[ ! -f $filepath ]]; then
if [[ $has_private != "true" ]]; then
cp $line $dirpath
echo $line $dirpath
fi
fi
done

rm mytmpfilelist mytmpfilelist2 objdumpfile
}

# install package dependencies
polar_install_dependency $(pwd)/${pkgname}${prefix}
cd ${buildroot}

dpkg --build ./${pkgname}
17 changes: 17 additions & 0 deletions package/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Package: polardb-for-postgresql
Maintainer: mrdrivingduck <[email protected]>
Depends: libicu66 | libicu70 | libicu74, libkrb5-3, libldap-2.4-2 | libldap-2.5-0 | libldap2
Section: database
Priority: optional
Homepage: https://github.com/ApsaraDB/PolarDB-for-PostgreSQL
Description: PolarDB is an advanced Object-Relational database management system
(DBMS) that supports almost all SQL constructs (including
transactions, subselects and user-defined types and functions). The
PolarDB package includes the client programs and libraries that
you'll need to access a PolarDB DBMS server. These PolarDB
client programs are programs that directly manipulate the internal
structure of PolarDB databases on a PolarDB server. These client
programs can be located on the same machine with the PolarDB
server, or may be on a remote machine which accesses a PolarDB
server over a network connection. This package contains the command-line
utilities for managing PolarDB databases on a PolarDB server.
3 changes: 1 addition & 2 deletions package/rpm/PolarDB.spec
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ polar_install_dependency()
cp /dev/null mytmpfilelist2

# put PolarDB-PG libs before any other libs to let ldd take it first
# Add /usr/lib for libmxml.so needed by oss_fdw extension
eval PERL_PATH=`cd /usr/lib64/perl[5-9]/CORE/ ; pwd`
export LD_LIBRARY_PATH=%{buildroot}${target_dir}/lib:$PERL_PATH:$LD_LIBRARY_PATH:/usr/lib

Expand Down Expand Up @@ -196,4 +195,4 @@ fi
%defattr(-,root,root)
%{prefix}/*

%{nil}
%define __os_install_post %{nil}
20 changes: 20 additions & 0 deletions package/rpm/build-rpm.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#!/bin/bash

# build-rpm.sh
# Use shell script to build .rpm packages.
#
# Copyright (c) 2024, Alibaba Group Holding Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# IDENTIFICATION
# package/rpm/build-rpm.sh

RPM_MACROS=$HOME/.rpmmacros
TOP_DIR=`pwd`/.self_rpm_create

Expand Down
3 changes: 0 additions & 3 deletions src/pl/plpython/plpython.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ typedef int Py_ssize_t;
#undef TEXTDOMAIN
#define TEXTDOMAIN PG_TEXTDOMAIN("plpython")

#include <compile.h>
#include <eval.h>

/* put back our snprintf and vsnprintf */
#ifdef USE_REPL_SNPRINTF
#ifdef snprintf
Expand Down
Loading