Yet more Sonarqube fixes.

This commit is contained in:
Dave Page 2022-08-10 16:43:48 +01:00
parent 2bc60c9142
commit 9c9fb293da
4 changed files with 65 additions and 60 deletions

View File

@ -193,7 +193,7 @@ _build_docs() {
cd "${SOURCEDIR}/docs/en_US" || exit cd "${SOURCEDIR}/docs/en_US" || exit
python3 build_code_snippet.py python3 build_code_snippet.py
SYS_PYTHONPATH=$(/usr/bin/python3 -c "import sys; print(':'.join([p for p in sys.path if p]))") SYS_PYTHONPATH=$(/usr/bin/python3 -c "import sys; print(':'.join([p for p in sys.path if p]))")
# shellcheck disable=SC2154 # shellcheck disable=SC2153
if [ "$1" == "redhat" ] && [ "${OS_VERSION}" == "7" ]; then if [ "$1" == "redhat" ] && [ "${OS_VERSION}" == "7" ]; then
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 /usr/local/bin/sphinx-build . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 /usr/local/bin/sphinx-build . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
else else

View File

@ -9,7 +9,7 @@ if [ "$EUID" -ne 0 ]
exit 1 exit 1
fi fi
if [[ "$#" -ne 0 ]] && ([[ "$#" -eq 1 ]] && [[ "$1" != "--yes" ]]); then if [[ "$#" -gt 1 ]] || { [[ "$#" -eq 1 ]] && [[ "$1" != "--yes" ]]; }; then
echo "Usage: $0 [--yes]" echo "Usage: $0 [--yes]"
exit 1 exit 1
fi fi
@ -128,8 +128,7 @@ if pgrep ${APACHE} > /dev/null; then
case ${RESPONSE} in case ${RESPONSE} in
y|Y ) y|Y )
systemctl restart ${APACHE} if ! systemctl restart ${APACHE}; then
if [ $? != 0 ]; then
echo "Error restarting ${APACHE}. Please check the systemd logs" echo "Error restarting ${APACHE}. Please check the systemd logs"
else else
echo "Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4" echo "Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4"

View File

@ -10,28 +10,28 @@
######################################################################### #########################################################################
# Runtime checks # Runtime checks
if [ ! -d runtime -a ! -d web ]; then if [ ! -d runtime ] && [ ! -d web ]; then
echo This script must be run from the top-level directory of the source tree. echo This script must be run from the top-level directory of the source tree.
exit 1 exit 1
fi fi
if [ ! -d .git -a ! -f .git/config ]; then if [ ! -d .git ] && [ ! -f .git/config ]; then
echo This script must be run from a git checkout of the source tree. echo This script must be run from a git checkout of the source tree.
exit 1 exit 1
fi fi
# Get the required package info # Get the required package info
APP_RELEASE=`grep "^APP_RELEASE" web/config.py | cut -d"=" -f2 | sed 's/ //g'` APP_RELEASE=$(grep "^APP_RELEASE" web/config.py | cut -d"=" -f2 | sed 's/ //g')
APP_REVISION=`grep "^APP_REVISION" web/config.py | cut -d"=" -f2 | sed 's/ //g'` APP_REVISION=$(grep "^APP_REVISION" web/config.py | cut -d"=" -f2 | sed 's/ //g')
APP_NAME=`grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //'` APP_NAME=$(grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //')
APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION} APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION}
APP_SUFFIX=`grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g"` APP_SUFFIX=$(grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g")
if [ ! -z ${APP_SUFFIX} ]; then if [ -n "${APP_SUFFIX}" ]; then
export APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX} export APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX}
fi fi
# Output basic details to show we're working # Output basic details to show we're working
echo Building tarballs for ${APP_NAME} version ${APP_LONG_VERSION}... echo Building tarballs for "${APP_NAME}" version "${APP_LONG_VERSION}"...
# Create/clearout the build directory # Create/clearout the build directory
echo Creating/cleaning required directories... echo Creating/cleaning required directories...
@ -47,36 +47,39 @@ mkdir pip-build/pgadmin4
mkdir pip-build/pgadmin4/docs mkdir pip-build/pgadmin4/docs
# Build the clean tree # Build the clean tree
cd web cd web || exit
for FILE in `git ls-files` for FILE in $(git ls-files)
do do
echo Adding ${FILE} echo Adding "${FILE}"
# We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents # We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents
tar cf - ${FILE} | (cd ../pip-build/pgadmin4; tar xf -) # shellcheck disable=SC2164
tar cf - "${FILE}" | (cd ../pip-build/pgadmin4; tar xf -)
done done
yarn install yarn install
yarn run bundle yarn run bundle
for FILE in `ls -d pgadmin/static/js/generated/*` for FILE in pgadmin/static/js/generated/*
do do
echo Adding ${FILE} echo Adding "${FILE}"
tar cf - ${FILE} | (cd ../pip-build/pgadmin4; tar xf -) # shellcheck disable=SC2164
tar cf - "${FILE}" | (cd ../pip-build/pgadmin4; tar xf -)
done done
cd ../docs cd ../docs || exit
for FILE in `git ls-files` for FILE in $(git ls-files)
do do
echo Adding ${FILE} echo Adding "${FILE}"
# We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents # We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents
tar cf - ${FILE} | (cd ../pip-build/pgadmin4/docs; tar xf -) # shellcheck disable=SC2164
tar cf - "${FILE}" | (cd ../pip-build/pgadmin4/docs; tar xf -)
done done
for DIR in `ls -d ??_??/` for DIR in ./??_??/
do do
if [ -d ${DIR}/_build/html ]; then if [ -d "${DIR}"/_build/html ]; then
mkdir -p ../pip-build/pgadmin4/docs/${DIR}/_build mkdir -p "../pip-build/pgadmin4/docs/${DIR}/_build"
cp -R ${DIR}/_build/html ../pip-build/pgadmin4/docs/${DIR}/_build cp -R "${DIR}/_build/html" "../pip-build/pgadmin4/docs/${DIR}/_build"
fi fi
done done
@ -85,6 +88,7 @@ for FILE in LICENSE DEPENDENCIES README.md
do do
echo Adding ${FILE} echo Adding ${FILE}
# We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents # We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents
# shellcheck disable=SC2164
tar cf - ${FILE} | (cd pip-build/pgadmin4; tar xf -) tar cf - ${FILE} | (cd pip-build/pgadmin4; tar xf -)
done done
@ -99,7 +103,7 @@ echo recursive-include pgadmin4 \* > pip-build/MANIFEST.in
# Run the build # Run the build
echo Building wheel... echo Building wheel...
cd pip-build cd pip-build || exit
python ../pkg/pip/setup_pip.py bdist_wheel python ../pkg/pip/setup_pip.py bdist_wheel
cd ../ cd ../

View File

@ -10,30 +10,30 @@
######################################################################### #########################################################################
# Runtime checks # Runtime checks
if [ ! -d runtime -a ! -d web ]; then if [ ! -d runtime ] && [ ! -d web ]; then
echo This script must be run from the top-level directory of the source tree. echo This script must be run from the top-level directory of the source tree.
exit 1 exit 1
fi fi
if [ ! -d .git -a ! -f .git/config ]; then if [ ! -d .git ] && [ ! -f .git/config ]; then
echo This script must be run from a git checkout of the source tree. echo This script must be run from a git checkout of the source tree.
exit 1 exit 1
fi fi
# Get the required package info # Get the required package info
APP_RELEASE=`grep "^APP_RELEASE" web/config.py | cut -d"=" -f2 | sed 's/ //g'` APP_RELEASE=$(grep "^APP_RELEASE" web/config.py | cut -d"=" -f2 | sed 's/ //g')
APP_REVISION=`grep "^APP_REVISION" web/config.py | cut -d"=" -f2 | sed 's/ //g'` APP_REVISION=$(grep "^APP_REVISION" web/config.py | cut -d"=" -f2 | sed 's/ //g')
APP_NAME=`grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //'` APP_NAME=$(grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //')
APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION} APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION}
APP_SUFFIX=`grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g"` APP_SUFFIX=$(grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g")
if [ ! -z ${APP_SUFFIX} ]; then if [ -n "${APP_SUFFIX}" ]; then
export APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX} export APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX}
fi fi
TARBALL_NAME=`echo ${APP_NAME}-${APP_LONG_VERSION} | sed 's/ //g' | awk '{print tolower($0)}'` TARBALL_NAME=$(echo "${APP_NAME}-${APP_LONG_VERSION}" | sed 's/ //g' | awk '{print tolower($0)}')
DOC_TARBALL_NAME=`echo ${APP_NAME}-${APP_LONG_VERSION}-docs | sed 's/ //g' | awk '{print tolower($0)}'` DOC_TARBALL_NAME=$(echo "${APP_NAME}-${APP_LONG_VERSION}-docs" | sed 's/ //g' | awk '{print tolower($0)}')
# Output basic details to show we're working # Output basic details to show we're working
echo Building tarballs for ${APP_NAME} version ${APP_LONG_VERSION}... echo "Building tarballs for ${APP_NAME} version ${APP_LONG_VERSION}..."
# Create/clearout the build directory # Create/clearout the build directory
echo Creating/cleaning required directories... echo Creating/cleaning required directories...
@ -41,58 +41,60 @@ if [ ! -d src-build ]; then
mkdir src-build mkdir src-build
fi fi
if [ -d src-build/${TARBALL_NAME} ]; then if [ -d "src-build/${TARBALL_NAME}" ]; then
rm -rf src-build/${TARBALL_NAME} rm -rf "src-build/${TARBALL_NAME}"
fi fi
mkdir src-build/${TARBALL_NAME} mkdir "src-build/${TARBALL_NAME}"
# Create the output directory if not present # Create the output directory if not present
if [ ! -d dist ]; then if [ ! -d dist ]; then
mkdir dist mkdir dist
fi fi
if [ -f dist/${TARBALL_NAME}.tar.gz ]; then if [ -f "dist/${TARBALL_NAME}.tar.gz" ]; then
rm -f dist/${TARBALL_NAME}.tar.gz rm -f "dist/${TARBALL_NAME}.tar.gz"
fi fi
if [ -f dist/${DOC_TARBALL_NAME}.tar.gz ]; then if [ -f "dist/${DOC_TARBALL_NAME}.tar.gz" ]; then
rm -f dist/${DOC_TARBALL_NAME}.tar.gz rm -f "dist/${DOC_TARBALL_NAME}.tar.gz"
fi fi
# Build the clean tree # Build the clean tree
for FILE in `git ls-files` for FILE in $(git ls-files)
do do
echo Adding ${FILE} echo Adding "${FILE}"
# We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents # We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents
tar cf - ${FILE} | (cd src-build/${TARBALL_NAME}; tar xf -) # shellcheck disable=SC2164
tar cf - "${FILE}" | (cd src-build/${TARBALL_NAME}; tar xf -)
done done
pushd web > /dev/null pushd web > /dev/null || exit
yarn install yarn install
yarn run bundle yarn run bundle
for FILE in `ls -d pgadmin/static/js/generated/*` for FILE in pgadmin/static/js/generated/*
do do
echo Adding ${FILE} echo Adding "${FILE}"
tar cf - ${FILE} | (cd ../src-build/${TARBALL_NAME}/web; tar xf -) # shellcheck disable=SC2164
tar cf - "${FILE}" | (cd "../src-build/${TARBALL_NAME}/web"; tar xf -)
done done
popd > /dev/null popd > /dev/null || exit
# Create the tarball # Create the tarball
echo Creating tarball... echo Creating tarball...
cd src-build cd src-build || exit
tar zcvf ../dist/${TARBALL_NAME}.tar.gz ${TARBALL_NAME} tar zcvf "../dist/${TARBALL_NAME}.tar.gz" "${TARBALL_NAME}"
cd .. cd ..
# Create the docs # Create the docs
echo Creating docs... echo Creating docs...
cd src-build/${TARBALL_NAME}/docs/en_US cd "src-build/${TARBALL_NAME}/docs/en_US" || exit
make -f Makefile.sphinx html make -f Makefile.sphinx html
cd _build cd _build || exit
mv html ${DOC_TARBALL_NAME} mv html "${DOC_TARBALL_NAME}"
tar zcvf ../../../../../dist/${DOC_TARBALL_NAME}.tar.gz ${DOC_TARBALL_NAME} tar zcvf "../../../../../dist/${DOC_TARBALL_NAME}.tar.gz" "${DOC_TARBALL_NAME}"
cd ../../../../../ cd ../../../../../
# Fin! # Fin!
echo Created tarball dist/${TARBALL_NAME}.tar.gz and dist/${DOC_TARBALL_NAME}.tar.gz echo "Created tarball dist/${TARBALL_NAME}.tar.gz and dist/${DOC_TARBALL_NAME}.tar.gz"