Yet more Sonarqube fixes.

This commit is contained in:
Dave Page 2022-08-10 17:01:31 +01:00
parent 9c9fb293da
commit 626681c5ba
4 changed files with 38 additions and 37 deletions

View File

@ -16,6 +16,7 @@ export PATH=/usr/pgsql-14/bin:$PATH
export PYTHONDONTWRITEBYTECODE=1
# Common Linux build functions
# shellcheck disable=SC1091
source pkg/linux/build-functions.sh
# Assemble the "standard" installation footprint
@ -29,7 +30,7 @@ _copy_code
# Get an RPM-compatible version number
RPM_VERSION=${APP_RELEASE}.${APP_REVISION}
if [ ! -z ${APP_SUFFIX} ]; then
if [ -n "${APP_SUFFIX}" ]; then
RPM_VERSION=${RPM_VERSION}_${APP_SUFFIX}
fi
@ -221,23 +222,23 @@ 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
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 postgresql14-libs
yumdownloader -y --downloadonly --destdir="${DISTROOT}" postgresql14-libs
#
# Get the results!
#
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}/"
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

@ -5,7 +5,7 @@ REPO_RPM_VERSION=2
REPO_RPM_BUILD=1
# Set the repo base directory
if [ "x${PGADMIN_REPO_DIR}" == "x" ]; then
if [ "${PGADMIN_REPO_DIR}" == "" ]; then
echo "PGADMIN_REPO_DIR not set. Setting it to the default: https://ftp.postgresql.org/pub/pgadmin/pgadmin4/repos/yum"
export PGADMIN_REPO_DIR=https://ftp.postgresql.org/pub/pgadmin/pgadmin4/repos/yum
fi
@ -14,12 +14,10 @@ fi
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')
trap 'ERRCODE=$? && if [ ${ERRCODE} -ne 0 ]; then echo "The command \"${BASH_COMMAND}\" failed in \"${FUNCNAME}\" with exit code ${ERRCODE}."; fi' EXIT
# Common Linux build functions
# shellcheck disable=SC1091
source pkg/linux/build-functions.sh
# Are we installing a package key?
@ -36,14 +34,14 @@ fi
# Create the Redhat packaging stuffs for the repo
_create_repo_rpm() {
DISTRO=$1
if [ ${DISTRO} == "redhat" ]; then
if [ "${DISTRO}" == "redhat" ]; then
PLATFORM="rhel"
else
PLATFORM=${DISTRO}
fi
echo "Creating the repo package for ${DISTRO}..."
test -d ${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d || mkdir -p ${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d
test -d "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d" || mkdir -p "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d"
cat << EOF > "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d/pgadmin4.repo"
[pgAdmin4]
@ -53,9 +51,11 @@ enabled=1
EOF
if [ ${INCLUDE_KEY} -eq 1 ]; then
echo repo_gpgcheck=1 >> "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d/pgadmin4.repo"
echo gpgcheck=1 >> "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d/pgadmin4.repo"
echo gpgkey=file:///etc/pki/rpm-gpg/PGADMIN_PKG_KEY >> "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d/pgadmin4.repo"
{
echo repo_gpgcheck=1
echo gpgcheck=1
echo gpgkey=file:///etc/pki/rpm-gpg/PGADMIN_PKG_KEY
} >> "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d/pgadmin4.repo"
else
echo gpgcheck=0 >> "${BUILDROOT}/${DISTRO}-repo/etc/yum.repos.d/pgadmin4.repo"
fi
@ -86,11 +86,11 @@ cp -rfa %{pga_build_root}/${DISTRO}-repo/* \${RPM_BUILD_ROOT}
EOF
if [ ${INCLUDE_KEY} -eq 1 ]; then
cat << EOF >> ${BUILDROOT}/${DISTRO}-repo.spec
cat << EOF >> "${BUILDROOT}/${DISTRO}-repo.spec"
/etc/pki/rpm-gpg/PGADMIN_PKG_KEY
EOF
test -d ${BUILDROOT}/${DISTRO}-repo/etc/pki/rpm-gpg || mkdir -p ${BUILDROOT}/${DISTRO}-repo/etc/pki/rpm-gpg
cp pkg/redhat/PGADMIN_PKG_KEY ${BUILDROOT}/${DISTRO}-repo/etc/pki/rpm-gpg/
test -d "${BUILDROOT}/${DISTRO}-repo/etc/pki/rpm-gpg" || mkdir -p "${BUILDROOT}/${DISTRO}-repo/etc/pki/rpm-gpg"
cp pkg/redhat/PGADMIN_PKG_KEY "${BUILDROOT}/${DISTRO}-repo/etc/pki/rpm-gpg/"
fi
# Build the package
@ -98,7 +98,7 @@ EOF
rpmbuild --define "pga_build_root ${BUILDROOT}" -bb "${BUILDROOT}/${DISTRO}-repo.spec"
}
_setup_env $0 "redhat"
_setup_env "$0" "redhat"
_create_repo_rpm redhat
_create_repo_rpm fedora
@ -106,4 +106,4 @@ _create_repo_rpm fedora
# Get the results!
#
test -d "${DISTROOT}/" || mkdir -p "${DISTROOT}/"
cp ${HOME}/rpmbuild/RPMS/noarch/${APP_NAME}-*-repo-${REPO_RPM_VERSION}-${REPO_RPM_BUILD}.noarch.rpm "${DISTROOT}/"
cp "${HOME}/rpmbuild/RPMS/noarch/${APP_NAME}-"*"-repo-${REPO_RPM_VERSION}-${REPO_RPM_BUILD}.noarch.rpm" "${DISTROOT}/"

View File

@ -5,24 +5,24 @@ if [ "$EUID" -ne 0 ]
exit 1
fi
OS_VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | awk -F "=" '{ print $2 }' | sed 's/"//g' | awk -F "." '{ print $1 }')
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
yum config-manager --enable PowerTools AppStream BaseOS *epel
yum install -y "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${OS_VERSION}.noarch.rpm"
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
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-${OS_VERSION}-x86_64/pgdg-redhat-repo-latest.noarch.rpm
if [ "${OS_VERSION}" == 7 ] || [ "${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
yum install -y "https://download.postgresql.org/pub/repos/yum/reporpms/F-${OS_VERSION}-x86_64/pgdg-fedora-repo-latest.noarch.rpm"
fi
# Node repo
@ -37,10 +37,10 @@ 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
if [ "${OS_VERSION}" == 7 ]; then
yum install -y expect fakeroot httpd-devel postgresql14-devel python3-devel nodejs yarn rpm-build rpm-sign yum-utils krb5-devel
pip3 install sphinx
elif [ ${OS_VERSION} == 9 ]; then
elif [ "${OS_VERSION}" == 9 ]; then
yum install -y expect postgresql14-devel python3-devel nodejs yarn rpm-build rpm-sign yum-utils krb5-devel
pip3 install sphinx
else
@ -50,7 +50,7 @@ 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
if [ "${OS_VERSION}" == 7 ]; then
cat << EOF
# Macros for signing RPMs.

View File

@ -66,7 +66,7 @@ do
echo Adding "${FILE}"
# We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents
# shellcheck disable=SC2164
tar cf - "${FILE}" | (cd src-build/${TARBALL_NAME}; tar xf -)
tar cf - "${FILE}" | (cd "src-build/${TARBALL_NAME}"; tar xf -)
done
pushd web > /dev/null || exit