Add support for building RPMs on CentOS/RHEL 7

This commit is contained in:
Dave Page 2020-03-19 12:53:00 -04:00
parent 96361656e4
commit 8812a7db69
7 changed files with 131 additions and 7 deletions

4
.gitignore vendored
View File

@ -1,8 +1,6 @@
*.autosave *.autosave
*.db *.db
*.diff
*.o *.o
*.patch
*.psp *.psp
*.pyc *.pyc
*.pyo *.pyo
@ -11,6 +9,8 @@
.DS_Store .DS_Store
.idea .idea
.vscode .vscode
/*.diff
/*.patch
/dist /dist
/debian-build /debian-build
/docker-build /docker-build

View File

@ -126,7 +126,11 @@ _build_docs() {
cd "${SOURCEDIR}/docs/en_US" cd "${SOURCEDIR}/docs/en_US"
python3 build_code_snippet.py python3 build_code_snippet.py
if [ $1 == "redhat" ]; then 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 else
PYTHONPATH=$PYTHONPATH:/usr/lib/python3/:/usr/lib/python3/dist-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" PYTHONPATH=$PYTHONPATH:/usr/lib/python3/:/usr/lib/python3/dist-packages python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
fi fi

View File

@ -34,6 +34,11 @@ cat << EOF > "${BUILDROOT}/server.spec"
%global __requires_exclude_from ^/.*$ %global __requires_exclude_from ^/.*$
%global __provides_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_mangle_shebangs
%undefine __brp_ldconfig %undefine __brp_ldconfig
@ -43,8 +48,12 @@ Release: 1%{?dist}
Summary: The core server package for pgAdmin. Summary: The core server package for pgAdmin.
License: PostgreSQL License: PostgreSQL
URL: https://www.pgadmin.org/ URL: https://www.pgadmin.org/
%if 0%{?rhel} && 0%{?rhel} != 7
Requires: python3, libpq Requires: python3, libpq
Recommends: postgresql Recommends: postgresql
%else
Requires: python3, postgresql
%endif
%description %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. 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 License: PostgreSQL
URL: https://www.pgadmin.org/ URL: https://www.pgadmin.org/
Requires: ${APP_NAME}-server, qt5-qtbase, qt5-qtbase-gui Requires: ${APP_NAME}-server, qt5-qtbase, qt5-qtbase-gui
Recommends: gnome-shell-extension-topicons-plus gnome-shell
%description %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. 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. Summary: The web interface for pgAdmin, hosted under Apache HTTPD.
License: PostgreSQL License: PostgreSQL
URL: https://www.pgadmin.org/ 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 Requires: ${APP_NAME}-server, httpd, python3-mod_wsgi
%endif
%description %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. 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 # Build the Redhat package for the meta package
rpmbuild --define "pga_build_root ${BUILDROOT}" -bb "${BUILDROOT}/meta.spec" 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! # Get the results!
# #
cp ${HOME}/rpmbuild/RPMS/${OS_ARCH}/${APP_NAME}-*${APP_LONG_VERSION}-*.${OS_ARCH}.rpm "${DISTROOT}/" 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}/" 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

View File

@ -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 <devrim@gunduz.org> - 4.6.8-2
- Initial packaging for the PostgreSQL YUM repository

View File

@ -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 $@

View File

@ -0,0 +1,4 @@
<IfModule !wsgi_module>
LoadModule wsgi_module modules/pgadmin4-python3-mod_wsgi.so
</IfModule>

View File

@ -5,8 +5,10 @@ if [ "$EUID" -ne 0 ]
exit 1 exit 1
fi fi
OS_VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | awk -F "=" '{ print $2 }' | sed 's/"//g')
# EPEL & other repos # 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 yum config-manager --enable PowerTools AppStream BaseOS *epel
# Node repo # Node repo
@ -20,7 +22,15 @@ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yu
# Install pre-reqs # Install pre-reqs
echo "Installing build pre-requisites..." echo "Installing build pre-requisites..."
yum groupinstall -y "Development Tools" 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