From 8812a7db694034edc1b3a39fca07425fe23d60a2 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Thu, 19 Mar 2020 12:53:00 -0400 Subject: [PATCH] Add support for building RPMs on CentOS/RHEL 7 --- .gitignore | 4 +- pkg/linux/build-functions.sh | 6 +- pkg/redhat/build.sh | 28 +++++++- pkg/redhat/pgadmin4-python-mod_wsgi.spec | 71 +++++++++++++++++++ .../pgadmin4-python3-mod_wsgi-exports.patch | 11 +++ pkg/redhat/pgadmin4-python3-mod_wsgi.conf | 4 ++ pkg/redhat/setup.sh | 14 +++- 7 files changed, 131 insertions(+), 7 deletions(-) create mode 100644 pkg/redhat/pgadmin4-python-mod_wsgi.spec create mode 100644 pkg/redhat/pgadmin4-python3-mod_wsgi-exports.patch create mode 100644 pkg/redhat/pgadmin4-python3-mod_wsgi.conf diff --git a/.gitignore b/.gitignore index 558b66daa..5d26a435e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ *.autosave *.db -*.diff *.o -*.patch *.psp *.pyc *.pyo @@ -11,6 +9,8 @@ .DS_Store .idea .vscode +/*.diff +/*.patch /dist /debian-build /docker-build diff --git a/pkg/linux/build-functions.sh b/pkg/linux/build-functions.sh index 67cc2bbac..b26c12c5c 100644 --- a/pkg/linux/build-functions.sh +++ b/pkg/linux/build-functions.sh @@ -126,7 +126,11 @@ _build_docs() { cd "${SOURCEDIR}/docs/en_US" python3 build_code_snippet.py if [ $1 == "redhat" ]; then - PYTHONPATH=$PYTHONPATH:/usr/lib/python3.6/site-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" + if [ "${OS_VERSION}" == "7" ]; then + PYTHONPATH=$PYTHONPATH:/usr/local/lib64/python3.6/site-packages:/usr/local/lib/python3.6/site-packages:/usr/lib/python3.6/site-packages python3 /usr/local/bin/sphinx-build . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" + else + PYTHONPATH=$PYTHONPATH:/usr/lib/python3.6/site-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" + fi else PYTHONPATH=$PYTHONPATH:/usr/lib/python3/:/usr/lib/python3/dist-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" fi diff --git a/pkg/redhat/build.sh b/pkg/redhat/build.sh index ed415cc5d..ce0df12a5 100755 --- a/pkg/redhat/build.sh +++ b/pkg/redhat/build.sh @@ -34,6 +34,11 @@ cat << EOF > "${BUILDROOT}/server.spec" %global __requires_exclude_from ^/.*$ %global __provides_exclude_from ^/.*$ +# 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 + %undefine __brp_mangle_shebangs %undefine __brp_ldconfig @@ -43,8 +48,12 @@ Release: 1%{?dist} Summary: The core server package for pgAdmin. License: PostgreSQL URL: https://www.pgadmin.org/ +%if 0%{?rhel} && 0%{?rhel} != 7 Requires: python3, libpq Recommends: postgresql +%else +Requires: python3, postgresql +%endif %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. @@ -82,7 +91,6 @@ 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. @@ -122,7 +130,11 @@ Release: 1%{?dist} 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, httpd, pgadmin4-python3-mod_wsgi +%else Requires: ${APP_NAME}-server, httpd, python3-mod_wsgi +%endif %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. @@ -181,9 +193,21 @@ 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.7.1.tar.gz https://codeload.github.com/GrahamDumpleton/mod_wsgi/tar.gz/4.7.1 + rpmbuild -bb "${SOURCEDIR}/pkg/redhat/pgadmin4-python-mod_wsgi.spec" +fi + # # 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}/" - +if [ ${OS_VERSION} == 7 ]; then + cp ${HOME}/rpmbuild/RPMS/${OS_ARCH}/pgadmin4-python3-mod_wsgi-4.7.1-2.el7.x86_64.rpm "${DISTROOT}/" +fi diff --git a/pkg/redhat/pgadmin4-python-mod_wsgi.spec b/pkg/redhat/pgadmin4-python-mod_wsgi.spec new file mode 100644 index 000000000..435c24db4 --- /dev/null +++ b/pkg/redhat/pgadmin4-python-mod_wsgi.spec @@ -0,0 +1,71 @@ +%global sname mod_wsgi + +%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}} + +%{!?_httpd_mmn: %{expand: %%global _httpd_mmn %%(cat %{_includedir}/httpd/.mmn 2>/dev/null || echo 0-0)}} +%{!?_httpd_confdir: %{expand: %%global _httpd_confdir %%{_sysconfdir}/httpd/conf.d}} +# /etc/httpd/conf.d with httpd < 2.4 and defined as /etc/httpd/conf.modules.d with httpd >= 2.4 +%{!?_httpd_modconfdir: %{expand: %%global _httpd_modconfdir %%{_sysconfdir}/httpd/conf.d}} +%{!?_httpd_moddir: %{expand: %%global _httpd_moddir %%{_libdir}/httpd/modules}} + +%global debug_package %{nil} + +Name: pgadmin4-python3-%{sname} +Version: 4.7.1 +Release: 2%{?dist} +Summary: A WSGI interface for Python web applications in Apache (customized for pgAdmin4) +License: ASL 2.0 +URL: https://modwsgi.readthedocs.io/ +Source0: https://github.com/GrahamDumpleton/%{sname}/archive/%{version}.tar.gz#/mod_wsgi-%{version}.tar.gz +Source2: %{name}.conf +Patch1: %{name}-exports.patch + +Requires: httpd-mmn = %{_httpd_mmn} +BuildRequires: python3-devel +BuildRequires: httpd-devel +BuildRequires: gcc + +# Suppress auto-provides for module DSO +%{?filter_provides_in: %filter_provides_in %{_httpd_moddir}/.*\.so$} +%{?filter_setup} + +%global _description\ +The mod_wsgi adapter is an Apache module that provides a WSGI compliant\ +interface for hosting Python based web applications within Apache. The\ +adapter is written completely in C code against the Apache C runtime and\ +for hosting WSGI applications within Apache has a lower overhead than using\ +existing WSGI adapters for mod_python or CGI.\ + +%description %_description + +%prep +%autosetup -p1 -n %{sname}-%{version} + +%build +export LDFLAGS="$RPM_LD_FLAGS -L%{_libdir}" +export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" + +%configure --enable-shared --with-apxs=%{_httpd_apxs} --with-python=python3 +%{__make} %{?_smp_mflags} +%{_bindir}/python3 setup.py build + +%install +%{__make} install DESTDIR=%{buildroot} LIBEXECDIR=%{_httpd_moddir} +%{__install} -d -m 755 %{buildroot}%{_httpd_modconfdir} +%{__install} -p -m 644 %{SOURCE2} %{buildroot}%{_httpd_modconfdir}/10-pgadmin4-python3-mod_wsgi.conf +%{_bindir}/python3 setup.py install -O1 --skip-build --root %{buildroot} +%{__mv} %{buildroot}%{_httpd_moddir}/mod_wsgi.so %{buildroot}%{_httpd_moddir}/pgadmin4-python3-mod_wsgi.so +%{__mv} %{buildroot}%{_bindir}/mod_wsgi-express %{buildroot}%{_bindir}/pgadmin4-mod_wsgi-express-3 + +%files +%license LICENSE +%doc CREDITS.rst README.rst +%config(noreplace) %{_httpd_modconfdir}/*pgadmin4-python3-mod_wsgi.conf +%{_httpd_moddir}/pgadmin4-python3-mod_wsgi.so +%{python3_sitearch}/mod_wsgi-*.egg-info +%{python3_sitearch}/mod_wsgi +%{_bindir}/pgadmin4-mod_wsgi-express-3 + +%changelog +* Fri Mar 6 2020 Devrim Gündüz - 4.6.8-2 +- Initial packaging for the PostgreSQL YUM repository diff --git a/pkg/redhat/pgadmin4-python3-mod_wsgi-exports.patch b/pkg/redhat/pgadmin4-python3-mod_wsgi-exports.patch new file mode 100644 index 000000000..97e56714e --- /dev/null +++ b/pkg/redhat/pgadmin4-python3-mod_wsgi-exports.patch @@ -0,0 +1,11 @@ +--- mod_wsgi-4.5.20/Makefile.in.exports ++++ mod_wsgi-4.5.20/Makefile.in +@@ -28,7 +28,7 @@ + all : src/server/mod_wsgi.la + + src/server/mod_wsgi.la : $(SRCFILES) +- $(APXS) -c $(CPPFLAGS) $(CFLAGS) $(SRCFILES) $(LDFLAGS) $(LDLIBS) ++ $(APXS) -Wl,-export-symbols-regex -Wl,wsgi_module -c $(CPPFLAGS) $(CFLAGS) $(SRCFILES) $(LDFLAGS) $(LDLIBS) + + $(DESTDIR)$(LIBEXECDIR) : + mkdir -p $@ diff --git a/pkg/redhat/pgadmin4-python3-mod_wsgi.conf b/pkg/redhat/pgadmin4-python3-mod_wsgi.conf new file mode 100644 index 000000000..1c3c3b226 --- /dev/null +++ b/pkg/redhat/pgadmin4-python3-mod_wsgi.conf @@ -0,0 +1,4 @@ + + LoadModule wsgi_module modules/pgadmin4-python3-mod_wsgi.so + + diff --git a/pkg/redhat/setup.sh b/pkg/redhat/setup.sh index bfb36bdba..b6da92b9e 100755 --- a/pkg/redhat/setup.sh +++ b/pkg/redhat/setup.sh @@ -5,8 +5,10 @@ if [ "$EUID" -ne 0 ] exit 1 fi +OS_VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | awk -F "=" '{ print $2 }' | sed 's/"//g') + # EPEL & other repos -yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm +yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${OS_VERSION}.noarch.rpm yum config-manager --enable PowerTools AppStream BaseOS *epel # Node repo @@ -20,7 +22,15 @@ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yu # 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 + +if [ ${OS_VERSION} == 7 ]; then + yum install -y fakeroot httpd-devel qt5-qtbase-devel postgresql-devel python3-devel nodejs yarn + pip3 install sphinx +else + yum install -y fakeroot qt5-qtbase-devel libpq-devel python3-devel python3-sphinx nodejs yarn +fi + +