Use correct python binary for Ubuntu 18 and EL-8.

pull/5967/head
Akshay Joshi 2023-03-17 17:47:53 +05:30 committed by GitHub
parent 6c12829cd4
commit f9fee9103b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 63 deletions

View File

@ -6,7 +6,6 @@ set -e
# Debugging shizz
trap 'ERRCODE=$? && if [ ${ERRCODE} -ne 0 ]; then echo "The command \"${BASH_COMMAND}\" failed in \"${FUNCNAME}\" with exit code ${ERRCODE}."; fi' EXIT
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F "=" '{ print $2 }' | sed 's/"//g')
OS_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
# Stop creating pyc files.
@ -38,7 +37,7 @@ Version: ${APP_LONG_VERSION}
Architecture: ${OS_ARCH}
Section: database
Priority: optional
Depends: python3, libpq5 (>= 11.0), libgssapi-krb5-2
Depends: ${PYTHON_BINARY}, libpq5 (>= 11.0), libgssapi-krb5-2
Recommends: postgresql-client | postgresql-client-15 | postgresql-client-14 | postgresql-client-13 | postgresql-client-12 | postgresql-client-11 | postgresql-client-10
Maintainer: pgAdmin Development Team <pgadmin-hackers@postgresql.org>
Description: The core server package for pgAdmin. pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.

View File

@ -33,5 +33,12 @@ apt update
# Install pre-reqs
echo "Installing build pre-requisites..."
apt install -y build-essential python3-dev python3-venv python3-sphinx python3-wheel python3-pip libpq-dev libffi-dev nodejs yarn libkrb5-dev
python3 -m pip install sphinxcontrib-youtube
# Install correct Python packages for Ubuntu 18.
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F "=" '{ print $2 }' | sed 's/"//g' | awk -F "." '{ print $1 }')
if [ "${OS_VERSION}" == "18" ]; then
apt install -y build-essential python3.8-dev python3.8-venv libpq-dev libffi-dev nodejs yarn libkrb5-dev
python3.8 -m pip install pip wheel sphinx sphinxcontrib-youtube
else
apt install -y build-essential python3-dev python3-venv python3-sphinx python3-wheel python3-pip libpq-dev libffi-dev nodejs yarn libkrb5-dev
python3 -m pip install sphinxcontrib-youtube
fi

View File

@ -18,6 +18,19 @@ _setup_env() {
if [ -n "${APP_SUFFIX}" ]; then
APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX}
fi
# Setting up the correct Python version for Ubuntu 18 and EL-8, which have
# new Python versions installed parallel to the old ones.
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F "=" '{ print $2 }' | sed 's/"//g' | awk -F "." '{ print $1 }')
SYSTEM_PYTHON_PATH='/usr/bin/python3'
PYTHON_BINARY='python3'
if [ "$2" == 'debian' ] && [ "${OS_VERSION}" == "18" ]; then
SYSTEM_PYTHON_PATH='/usr/bin/python3.8'
PYTHON_BINARY='python3.8'
elif [ "$2" == 'redhat' ] && [ "${OS_VERSION}" == "8" ]; then
SYSTEM_PYTHON_PATH='/usr/bin/python3.9'
PYTHON_BINARY='python3.9'
fi
}
_cleanup() {
@ -51,9 +64,9 @@ _create_python_virtualenv() {
cd "usr/${APP_NAME}" || exit
# Create the blank venv
python3 -m venv venv
${SYSTEM_PYTHON_PATH} -m venv
# shellcheck disable=SC1091
source venv/bin/activate
. venv/bin/activate
# Make sure we have the wheel package present, as well as the latest pip
pip3 install --upgrade pip
@ -78,11 +91,11 @@ _create_python_virtualenv() {
PYMODULES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
DIR_PYMODULES_PATH=$(dirname "${PYMODULES_PATH}")
# Use /usr/bin/python3 here as we want the system path
# Use {SYSTEM_PYTHON_PATH} here as we want the system path
if [ "$1" == "debian" ]; then
PYSYSLIB_PATH=$(/usr/bin/python3 -c "import sys; print('%s/lib/python%d.%.d' % (sys.prefix, sys.version_info.major, sys.version_info.minor))")
PYSYSLIB_PATH=$(${SYSTEM_PYTHON_PATH} -c "import sys; print('%s/lib/python%d.%.d' % (sys.prefix, sys.version_info.major, sys.version_info.minor))")
else
PYSYSLIB_PATH=$(/usr/bin/python3 -c "import sys; print('%s/lib64/python%d.%.d' % (sys.prefix, sys.version_info.major, sys.version_info.minor))")
PYSYSLIB_PATH=$(${SYSTEM_PYTHON_PATH} -c "import sys; print('%s/lib64/python%d.%.d' % (sys.prefix, sys.version_info.major, sys.version_info.minor))")
fi
# Symlink in the rest of the Python libs. This is required because the runtime
@ -188,13 +201,9 @@ _build_docs() {
cd "${SERVERROOT}" && mkdir -p "usr/${APP_NAME}/share/docs/en_US/html"
cd "${SOURCEDIR}/docs/en_US" || exit
python3 build_code_snippet.py
SYS_PYTHONPATH=$(/usr/bin/python3 -c "import sys; print(':'.join([p for p in sys.path if p]))")
SYS_PYTHONPATH=$(${SYSTEM_PYTHON_PATH} -c "import sys; print(':'.join([p for p in sys.path if p]))")
# shellcheck disable=SC2153
if [ "$1" == "redhat" ] && [ "${OS_VERSION}" == "7" ]; then
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 /usr/local/bin/sphinx-build . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
else
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
fi
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
}
_copy_code() {
@ -230,8 +239,8 @@ _copy_code() {
# user has configured an alternative default.
# DO THIS LAST!
cd "${SERVERROOT}/usr/${APP_NAME}/venv/bin" || exit
PYTHON_INTERPRETER=$(/usr/bin/python3 -c "import os, sys; print(os.path.realpath(sys.executable))")
PYTHON_VERSION=$(/usr/bin/python3 -c "import sys; print('%d.%d' % (sys.version_info.major, sys.version_info.minor))")
PYTHON_INTERPRETER=$(${SYSTEM_PYTHON_PATH} -c "import os, sys; print(os.path.realpath(sys.executable))")
PYTHON_VERSION=$(${SYSTEM_PYTHON_PATH} -c "import sys; print('%d.%d' % (sys.version_info.major, sys.version_info.minor))")
rm python && ln -s python3 python
rm "python${PYTHON_VERSION}" && ln -s python3 "python${PYTHON_VERSION}"
rm python3 && ln -s "${PYTHON_INTERPRETER}" python3

View File

@ -6,7 +6,6 @@ set -e
# Debugging shizz
trap 'ERRCODE=$? && if [ ${ERRCODE} -ne 0 ]; then echo "The command \"${BASH_COMMAND}\" failed in \"${FUNCNAME}\" with exit code ${ERRCODE}."; fi' EXIT
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F "=" '{ print $2 }' | sed 's/"//g')
OS_ARCH=$(arch)
# Make sure we get the latest libpq
@ -50,11 +49,6 @@ cat << EOF > "${BUILDROOT}/server.spec"
# virtualenv, in particular Pillow.libs.
%global __brp_check_rpaths %{nil}
# Bytecompiling Python 3 doesn't work on RHEL/CentOS 7, so make it a no-op
%if 0%{?rhel} && 0%{?rhel} == 7
%define __python /bin/true
%endif
# Don't strip binaries when packaging them as this might break cpython modules
%define __strip /bin/true
@ -68,7 +62,7 @@ Summary: The core server package for pgAdmin.
License: PostgreSQL
URL: https://www.pgadmin.org/
Requires: python3, postgresql-libs >= 11, krb5-libs
Requires: ${PYTHON_BINARY}, postgresql-libs >= 11, krb5-libs
%description
The core server package for pgAdmin. pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
@ -155,11 +149,7 @@ BuildArch: noarch
Summary: The web interface for pgAdmin, hosted under Apache HTTPD.
License: PostgreSQL
URL: https://www.pgadmin.org/
%if 0%{?rhel} && 0%{?rhel} == 7
Requires: ${APP_NAME}-server = ${RPM_VERSION}, httpd, pgadmin4-python3-mod_wsgi
%else
Requires: ${APP_NAME}-server = ${RPM_VERSION}, httpd, python3-mod_wsgi
%endif
Requires: ${APP_NAME}-server = ${RPM_VERSION}, httpd, ${PYTHON_BINARY}-mod_wsgi
%description
The web interface for pgAdmin, hosted under Apache HTTPD. pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
@ -219,16 +209,6 @@ EOF
# Build the Redhat package for the meta package
rpmbuild --define "pga_build_root ${BUILDROOT}" -bb "${BUILDROOT}/meta.spec"
#
# mod_wsgi for CentOS 7
#
if [ "${OS_VERSION}" == 7 ]; then
cp "${SOURCEDIR}/pkg/redhat/pgadmin4-python3-mod_wsgi-exports.patch" "${HOME}/rpmbuild/SOURCES"
cp "${SOURCEDIR}/pkg/redhat/pgadmin4-python3-mod_wsgi.conf" "${HOME}/rpmbuild/SOURCES"
curl -o "${HOME}/rpmbuild/SOURCES/mod_wsgi-4.9.0.tar.gz" https://codeload.github.com/GrahamDumpleton/mod_wsgi/tar.gz/4.9.0
rpmbuild -bb "${SOURCEDIR}/pkg/redhat/pgadmin4-python-mod_wsgi.spec"
fi
# Get the libpq we need
yumdownloader -y --downloadonly --destdir="${DISTROOT}" libpq5 libpq5-devel postgresql$(ls -d /usr/pgsql-1* | sort -r | head -1 | awk -F '-' '{ print $2 }')-libs
@ -237,8 +217,5 @@ yumdownloader -y --downloadonly --destdir="${DISTROOT}" libpq5 libpq5-devel post
#
cp "${HOME}/rpmbuild/RPMS/${OS_ARCH}/${APP_NAME}-"*"${RPM_VERSION}-"*".${OS_ARCH}.rpm" "${DISTROOT}/"
cp "${HOME}/rpmbuild/RPMS/noarch/${APP_NAME}-"*"${RPM_VERSION}-"*".noarch.rpm" "${DISTROOT}/"
if [ "${OS_VERSION}" == 7 ]; then
cp "${HOME}/rpmbuild/RPMS/${OS_ARCH}/pgadmin4-python3-mod_wsgi-4.9.0-1.el7.x86_64.rpm" "${DISTROOT}/"
fi
echo "Completed. RPMs created in ${DISTROOT}."

View File

@ -8,18 +8,18 @@ fi
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F "=" '{ print $2 }' | sed 's/"//g' | awk -F "." '{ print $1 }')
# EPEL & other repos
if [ "${OS_VERSION}" != 9 ]; then
if [ "${OS_VERSION}" != "9" ]; then
yum -y install centos-release-scl
fi
yum install -y "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${OS_VERSION}.noarch.rpm"
if [ "${OS_VERSION}" == 8 ] || [ "${OS_VERSION}" == 9 ]; then
if [ "${OS_VERSION}" == "8" ] || [ "${OS_VERSION}" == "9" ]; then
yum config-manager --enable PowerTools AppStream BaseOS "*epel"
dnf -qy module disable postgresql
fi
# PostgreSQL repo
if [ "${OS_VERSION}" == 7 ] || [ "${OS_VERSION}" == 8 ] || [ "${OS_VERSION}" == 9 ]; then
if [ "${OS_VERSION}" == "8" ] || [ "${OS_VERSION}" == "9" ]; then
yum install -y "https://download.postgresql.org/pub/repos/yum/reporpms/EL-${OS_VERSION}-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
else
yum install -y "https://download.postgresql.org/pub/repos/yum/reporpms/F-${OS_VERSION}-x86_64/pgdg-fedora-repo-latest.noarch.rpm"
@ -37,11 +37,11 @@ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yu
echo "Installing build pre-requisites..."
yum groupinstall -y "Development Tools"
if [ "${OS_VERSION}" == 7 ]; then
yum install -y expect fakeroot httpd-devel postgresql15-devel python3-devel nodejs yarn rpm-build rpm-sign yum-utils krb5-devel
pip3 install sphinx
pip3 install sphinxcontrib-youtube
elif [ "${OS_VERSION}" == 9 ]; then
if [ "${OS_VERSION}" == "8" ]; then
yum install -y expect fakeroot postgresql15-devel python3.9-devel nodejs yarn rpm-build rpm-sign yum-utils krb5-devel
pip3.9 install sphinx
pip3.9 install sphinxcontrib-youtube
elif [ "${OS_VERSION}" == "9" ]; then
yum install -y expect libpq5-devel postgresql15-devel python3-devel nodejs yarn rpm-build rpm-sign yum-utils krb5-devel
pip3 install sphinx
pip3 install sphinxcontrib-youtube
@ -54,18 +54,6 @@ fi
# Setup RPM macros for signing
echo "Please add the following macros to ~/.rpmmacros for the user that will sign the RPMs if required:"
echo
if [ "${OS_VERSION}" == 7 ]; then
cat << EOF
# Macros for signing RPMs.
%_signature gpg
%_gpg_path ~/.gnupg
%_gpg_name Package Manager
%_gpgbin /usr/bin/gpg2
%__gpg_sign_cmd %{__gpg} gpg --force-v3-sigs --batch --verbose --no-armor --passphrase-fd 3 --no-secmem-warning -u "%{_gpg_name}" -sbo %{__
signature_filename} --digest-algo sha256 %{__plaintext_filename}
EOF
else
cat << EOF
# Macros for signing RPMs.
@ -76,6 +64,5 @@ else
%__gpg_sign_cmd %{__gpg} gpg --force-v3-sigs --batch --verbose --no-armor --no-secmem-warning -u "%{_gpg_name}" -sbo %{__signature_filename
} --digest-algo sha256 %{__plaintext_filename}
EOF
fi
echo