Add support for building RHEL/CentOS 8 RPMs.

This commit is contained in:
Dave Page 2020-03-18 08:51:11 -04:00
parent b6c8707a4d
commit f156696339
8 changed files with 307 additions and 9 deletions

1
.gitignore vendored
View File

@ -16,6 +16,7 @@
/docker-build
/mac-build
/pip-build
/redhat-build
/src-build
/win-build
_build

View File

@ -91,7 +91,7 @@ runtime:
cd runtime && qmake CONFIG+=release && make
# Include all clean sub-targets in clean
clean: clean-appbundle clean-debian clean-dist clean-docs clean-node clean-pip clean-src clean-runtime
clean: clean-appbundle clean-debian clean-dist clean-docs clean-node clean-pip clean-redhat clean-src clean-runtime
rm -rf web/pgadmin/static/js/generated/*
rm -rf web/pgadmin/static/js/generated/.cache
rm -rf web/pgadmin/static/css/generated/*
@ -119,11 +119,14 @@ clean-node:
clean-pip:
rm -rf pip-build/
clean-redhat:
rm -rf redhat-build/
clean-src:
rm -rf src-build/
debian:
pkg/debian/build.sh
./pkg/debian/build.sh
docker:
echo $(APP_NAME)
@ -154,5 +157,8 @@ msg-update:
pip: docs
./pkg/pip/build.sh
redhat:
./pkg/redhat/build.sh
src:
./pkg/src/build.sh

View File

@ -18,9 +18,9 @@ source pkg/linux/build-functions.sh
_setup_env $0 "debian"
_cleanup "deb"
_setup_dirs
_create_python_virtualenv
_create_python_virtualenv "debian"
_build_runtime
_build_docs
_build_docs "debian"
_copy_code
#

View File

@ -61,8 +61,12 @@ _create_python_virtualenv() {
DIR_PYMODULES_PATH=`dirname ${PYMODULES_PATH}`
# Use /usr/bin/python3 here as we want the system path
PYSYSLIB_PATH=$(/usr/bin/python3 -c "import sys; print('%s/lib/python%d.%.d' % (sys.prefix, sys.version_info.major, sys.version_info.minor))")
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))")
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))")
fi
# Symlink in the rest of the Python libs. This is required because the runtime
# will clear PYTHONHOME for safety, which has the side-effect of preventing
# it from finding modules that are not explicitly included in the venv
@ -98,12 +102,15 @@ _create_python_virtualenv() {
_build_runtime() {
echo "Building the desktop runtime..."
_create_python_virtualenv
cd ${SOURCEDIR}/runtime
if [ -f Makefile ]; then
make clean
fi
qmake
if hash qmake-qt5 2>/dev/null; then
qmake-qt5
else
qmake
fi
make
mkdir -p "${DESKTOPROOT}/usr/${APP_NAME}/bin"
cp pgAdmin4 "${DESKTOPROOT}/usr/${APP_NAME}/bin/pgadmin4"
@ -118,7 +125,11 @@ _build_docs() {
cd "${SERVERROOT}" && mkdir -p "usr/${APP_NAME}/share/docs/en_US/html"
cd "${SOURCEDIR}/docs/en_US"
python3 build_code_snippet.py
PYTHONPATH=$PYTHONPATH:/usr/lib/python3/:/usr/lib/python3/dist-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
if [ $1 == "redhat" ]; then
PYTHONPATH=$PYTHONPATH:/usr/lib/python3.6/site-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
else
PYTHONPATH=$PYTHONPATH:/usr/lib/python3/:/usr/lib/python3/dist-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
fi
}
_copy_code() {

46
pkg/redhat/README Normal file
View File

@ -0,0 +1,46 @@
This directory contains the build runner script for creating .RPM packages for
Redhat distributions.
Build configuration
===================
To build RPM packages, first run the setup.sh script as root to install the
required pre-requisites, e.g.
# pkg/redhat/setup.sh
Building packages
=================
To build a set of packages, from the top-level source directory run:
$ make redhat
or
$ pkg/redhat/build.sh
Four .rpm packages will be created in the dist/ directory:
pgadmin4-<version>.<distro>_noarch.rpm
A convenience package that depends on all the others.
pgadmin4-server-<version>.<distro>.<arch>.rpm
The core server, e.g. the Python and JS code and the online documentation.
pgadmin4-desktop-<version>.<distro>.<arch>.rpm
The desktop runtime. Requires the server package.
pgadmin4-web-<version>.<distro>.<arch>.rpm
The server mode setup script for configuring Apache HTTPD. Requires the
server package.
Supported platforms
===================
RHEL/CentOS 8
Warning
=======
These scripts are experimental - use at your own risk!

189
pkg/redhat/build.sh Executable file
View File

@ -0,0 +1,189 @@
#!/bin/bash
# Exit when any command fails
set -e
# Debugging shizz
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
trap 'if [ $? -ne 0 ]; then echo "\"${last_command}\" command filed with exit code $?."; fi' EXIT
OS_VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | awk -F "=" '{ print $2 }' | sed 's/"//g')
OS_NAME=$(cat /etc/os-release | grep "^ID=" | awk -F "=" '{ print $2 }' | sed 's/"//g')
OS_ARCH=$(arch)
# Common Linux build functions
source pkg/linux/build-functions.sh
# Assemble the "standard" installation footprint
_setup_env $0 "redhat"
_cleanup "rpm"
_setup_dirs
_create_python_virtualenv "redhat"
_build_runtime
_build_docs "redhat"
_copy_code
#
# Server package
#
# Create the Redhat packaging stuffs for the server
echo "Creating the server package..."
cat << EOF > "${BUILDROOT}/server.spec"
%global __requires_exclude_from ^/.*$
%global __provides_exclude_from ^/.*$
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${APP_NAME}-server
Version: ${APP_LONG_VERSION}
Release: 1%{?dist}
Summary: The core server package for pgAdmin.
License: PostgreSQL
URL: https://www.pgadmin.org/
Requires: python3, libpq
Recommends: postgresql
%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.
%build
%install
cp -rfa %{pga_build_root}/server/* \${RPM_BUILD_ROOT}
%files
/usr/pgadmin4/*
EOF
# Build the Redhat package for the server
rpmbuild --define "pga_build_root ${BUILDROOT}" -bb "${BUILDROOT}/server.spec"
#
# Desktop package
#
# Create the Redhat packaging stuffs for the desktop
echo "Creating the desktop package..."
cat << EOF > "${BUILDROOT}/desktop.spec"
%global __requires_exclude_from ^/.*$
%global __provides_exclude_from ^/.*$
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${APP_NAME}-desktop
Version: ${APP_LONG_VERSION}
Release: 1%{?dist}
Summary: The desktop user interface for pgAdmin.
License: PostgreSQL
URL: https://www.pgadmin.org/
Requires: ${APP_NAME}-server, qt5-qtbase, qt5-qtbase-gui
Recommends: gnome-shell-extension-topicons-plus gnome-shell
%description
The desktop user interface 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.
%build
%install
cp -rfa %{pga_build_root}/desktop/* \${RPM_BUILD_ROOT}
%files
/usr/pgadmin4/bin/*
/usr/pgadmin4/share/*
/usr/share/applications/*
EOF
# Build the Redhat package for the server
rpmbuild --define "pga_build_root ${BUILDROOT}" -bb "${BUILDROOT}/desktop.spec"
#
# Web package
#
# Create the Redhat packaging stuffs for the web
echo "Creating the web package..."
cat << EOF > "${BUILDROOT}/web.spec"
%global __requires_exclude_from ^/.*$
%global __provides_exclude_from ^/.*$
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${APP_NAME}-web
Version: ${APP_LONG_VERSION}
Release: 1%{?dist}
Summary: The web interface for pgAdmin, hosted under Apache HTTPD.
License: PostgreSQL
URL: https://www.pgadmin.org/
Requires: ${APP_NAME}-server, httpd, python3-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.
%build
%install
cp -rfa %{pga_build_root}/web/* \${RPM_BUILD_ROOT}
%files
/usr/pgadmin4/bin/*
/etc/httpd/conf.d/*
EOF
mkdir -p "${WEBROOT}/etc/httpd/conf.d"
cp "${SOURCEDIR}/pkg/redhat/pgadmin4.conf" "${WEBROOT}/etc/httpd/conf.d"
# Build the Redhat package for the web
rpmbuild --define "pga_build_root ${BUILDROOT}" -bb "${BUILDROOT}/web.spec"
#
# Meta package
#
# Create the Redhat packaging stuffs for the meta package
echo "Creating the meta package..."
cat << EOF > "${BUILDROOT}/meta.spec"
%global __requires_exclude_from ^/.*$
%global __provides_exclude_from ^/.*$
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${APP_NAME}
Version: ${APP_LONG_VERSION}
Release: 1%{?dist}
BuildArch: noarch
Summary: Installs all required components to run pgAdmin in desktop and web modes.
License: PostgreSQL
URL: https://www.pgadmin.org/
Requires: ${APP_NAME}-server, ${APP_NAME}-desktop, ${APP_NAME}-web
%description
Installs all required components to run pgAdmin in desktop and web modes. 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.
%build
%install
%files
EOF
# Build the Redhat package for the meta package
rpmbuild --define "pga_build_root ${BUILDROOT}" -bb "${BUILDROOT}/meta.spec"
#
# Get the results!
#
cp ${HOME}/rpmbuild/RPMS/${OS_ARCH}/${APP_NAME}-*${APP_LONG_VERSION}-*.${OS_ARCH}.rpm "${DISTROOT}/"
cp ${HOME}/rpmbuild/RPMS/noarch/${APP_NAME}-*${APP_LONG_VERSION}-*.noarch.rpm "${DISTROOT}/"

19
pkg/redhat/pgadmin4.conf Normal file
View File

@ -0,0 +1,19 @@
LoadModule wsgi_module modules/mod_wsgi.so
WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/usr/pgadmin4/venv
WSGIScriptAlias /pgadmin4 /usr/pgadmin4/web/pgAdmin4.wsgi
<Directory /usr/pgadmin4/web/>
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>

26
pkg/redhat/setup.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "This script must be run as root"
exit 1
fi
# EPEL & other repos
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum config-manager --enable PowerTools AppStream BaseOS *epel
# Node repo
echo "Setting up the NodeJS repo..."
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
# Yarn repo
echo "Setting up the Yarn repo..."
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
# Install pre-reqs
echo "Installing build pre-requisites..."
yum groupinstall -y "Development Tools"
yum install -y fakeroot qt5-qtbase-devel libpq-devel python3-devel python3-sphinx nodejs yarn