2020-03-18 07:51:11 -05:00
#!/bin/bash
# Exit when any command fails
set -e
# Debugging shizz
2021-05-04 08:12:13 -05:00
trap 'ERRCODE=$? && if [ ${ERRCODE} -ne 0 ]; then echo "The command \"${BASH_COMMAND}\" failed in \"${FUNCNAME}\" with exit code ${ERRCODE}."; fi' EXIT
2020-03-18 07:51:11 -05:00
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)
2020-06-02 05:30:07 -05:00
# Make sure we get the right libpq
2021-10-04 05:42:45 -05:00
export PATH = /usr/pgsql-14/bin:$PATH
2020-06-02 05:30:07 -05:00
2022-02-14 05:56:27 -06:00
# Stop creating pyc files.
export PYTHONDONTWRITEBYTECODE = 1
2020-03-18 07:51:11 -05:00
# 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
2021-01-29 02:08:27 -06:00
# Get an RPM-compatible version number
RPM_VERSION = ${ APP_RELEASE } .${ APP_REVISION }
if [ ! -z ${ APP_SUFFIX } ] ; then
RPM_VERSION = ${ RPM_VERSION } _${ APP_SUFFIX }
fi
2020-03-18 07:51:11 -05:00
#
# 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 ^/.*$
2021-11-23 04:57:20 -06:00
%global _build_id_links none
2020-03-18 07:51:11 -05:00
2022-03-01 07:54:54 -06:00
# Disable RPATH checking, as it will fail with some of the paths in the Python
# virtualenv, in particular Pillow.libs.
%global __brp_check_rpaths %{ nil}
2020-03-19 11:53:00 -05:00
# 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
2020-03-18 07:51:11 -05:00
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${ APP_NAME } -server
2021-01-29 02:08:27 -06:00
Version: ${ RPM_VERSION }
2020-03-18 07:51:11 -05:00
Release: 1%{ ?dist}
Summary: The core server package for pgAdmin.
License: PostgreSQL
URL: https://www.pgadmin.org/
2020-05-28 10:26:44 -05:00
2021-04-02 03:31:17 -05:00
Requires: python3, postgresql-libs >= 11, krb5-libs
2020-03-18 07:51:11 -05:00
%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 ^/.*$
2021-11-23 04:57:20 -06:00
%global _build_id_links none
2020-03-18 07:51:11 -05:00
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${ APP_NAME } -desktop
2021-01-29 02:08:27 -06:00
Version: ${ RPM_VERSION }
2020-03-18 07:51:11 -05:00
Release: 1%{ ?dist}
Summary: The desktop user interface for pgAdmin.
License: PostgreSQL
URL: https://www.pgadmin.org/
2021-04-02 03:31:17 -05:00
Requires: ${ APP_NAME } -server = ${ RPM_VERSION } , libatomic, xdg-utils
2020-03-18 07:51:11 -05:00
%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}
2021-01-29 02:08:27 -06:00
%post
/bin/xdg-icon-resource forceupdate
2020-03-18 07:51:11 -05:00
%files
/usr/pgadmin4/bin/*
2021-01-29 02:08:27 -06:00
/usr/share/icons/hicolor/128x128/apps/*
/usr/share/icons/hicolor/64x64/apps/*
/usr/share/icons/hicolor/48x48/apps/*
/usr/share/icons/hicolor/32x32/apps/*
/usr/share/icons/hicolor/16x16/apps/*
2020-03-18 07:51:11 -05:00
/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 ^/.*$
2021-11-23 04:57:20 -06:00
%global _build_id_links none
2020-03-18 07:51:11 -05:00
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${ APP_NAME } -web
2021-01-29 02:08:27 -06:00
Version: ${ RPM_VERSION }
2020-03-18 07:51:11 -05:00
Release: 1%{ ?dist}
2020-03-20 10:48:00 -05:00
BuildArch: noarch
2020-03-18 07:51:11 -05:00
Summary: The web interface for pgAdmin, hosted under Apache HTTPD.
License: PostgreSQL
URL: https://www.pgadmin.org/
2020-03-19 11:53:00 -05:00
%if 0%{ ?rhel} && 0%{ ?rhel} = = 7
2021-02-19 04:08:25 -06:00
Requires: ${ APP_NAME } -server = ${ RPM_VERSION } , httpd, pgadmin4-python3-mod_wsgi
2020-03-19 11:53:00 -05:00
%else
2021-02-19 04:08:25 -06:00
Requires: ${ APP_NAME } -server = ${ RPM_VERSION } , httpd, python3-mod_wsgi
2020-03-19 11:53:00 -05:00
%endif
2020-03-18 07:51:11 -05:00
%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/*
2021-03-29 04:35:50 -05:00
%config( noreplace) /etc/httpd/conf.d/*
2020-03-18 07:51:11 -05:00
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 ^/.*$
2021-11-23 04:57:20 -06:00
%global _build_id_links none
2020-03-18 07:51:11 -05:00
%undefine __brp_mangle_shebangs
%undefine __brp_ldconfig
Name: ${ APP_NAME }
2021-01-29 02:08:27 -06:00
Version: ${ RPM_VERSION }
2020-03-18 07:51:11 -05:00
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/
2021-02-19 04:08:25 -06:00
Requires: ${ APP_NAME } -server = ${ RPM_VERSION } , ${ APP_NAME } -desktop = ${ RPM_VERSION } , ${ APP_NAME } -web = ${ RPM_VERSION }
2020-03-18 07:51:11 -05:00
%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 "
2020-03-19 11:53:00 -05:00
#
# 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
2021-12-13 04:28:13 -06:00
curl -o ${ HOME } /rpmbuild/SOURCES/mod_wsgi-4.9.0.tar.gz https://codeload.github.com/GrahamDumpleton/mod_wsgi/tar.gz/4.9.0
2020-03-19 11:53:00 -05:00
rpmbuild -bb " ${ SOURCEDIR } /pkg/redhat/pgadmin4-python-mod_wsgi.spec "
fi
2020-06-02 05:30:07 -05:00
# Get the libpq we need
2021-10-04 05:42:45 -05:00
yumdownloader -y --downloadonly --destdir= $DISTROOT postgresql14-libs
2020-06-02 05:30:07 -05:00
2020-03-18 07:51:11 -05:00
#
# Get the results!
#
2021-01-29 02:08:27 -06:00
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 } / "
2020-03-19 11:53:00 -05:00
if [ ${ OS_VERSION } = = 7 ] ; then
2021-12-13 04:29:01 -06:00
cp ${ HOME } /rpmbuild/RPMS/${ OS_ARCH } /pgadmin4-python3-mod_wsgi-4.9.0-1.el7.x86_64.rpm " ${ DISTROOT } / "
2020-03-19 11:53:00 -05:00
fi
2020-06-02 05:30:07 -05:00
2020-06-02 07:19:46 -05:00
echo " Completed. RPMs created in ${ DISTROOT } . "