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
python3 build_code_snippet.py
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
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 /usr/local/bin/sphinx-build . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
else

View File

@ -9,7 +9,7 @@ if [ "$EUID" -ne 0 ]
exit 1
fi
if [[ "$#" -ne 0 ]] && ([[ "$#" -eq 1 ]] && [[ "$1" != "--yes" ]]); then
if [[ "$#" -gt 1 ]] || { [[ "$#" -eq 1 ]] && [[ "$1" != "--yes" ]]; }; then
echo "Usage: $0 [--yes]"
exit 1
fi
@ -128,8 +128,7 @@ if pgrep ${APACHE} > /dev/null; then
case ${RESPONSE} in
y|Y )
systemctl restart ${APACHE}
if [ $? != 0 ]; then
if ! systemctl restart ${APACHE}; then
echo "Error restarting ${APACHE}. Please check the systemd logs"
else
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
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.
exit 1
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.
exit 1
fi
# Get the required package info
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_NAME=`grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //'`
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_NAME=$(grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //')
APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION}
APP_SUFFIX=`grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g"`
if [ ! -z ${APP_SUFFIX} ]; then
APP_SUFFIX=$(grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g")
if [ -n "${APP_SUFFIX}" ]; then
export APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX}
fi
# 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
echo Creating/cleaning required directories...
@ -47,36 +47,39 @@ mkdir pip-build/pgadmin4
mkdir pip-build/pgadmin4/docs
# Build the clean tree
cd web
for FILE in `git ls-files`
cd web || exit
for FILE in $(git ls-files)
do
echo Adding ${FILE}
echo Adding "${FILE}"
# 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
yarn install
yarn run bundle
for FILE in `ls -d pgadmin/static/js/generated/*`
for FILE in pgadmin/static/js/generated/*
do
echo Adding ${FILE}
tar cf - ${FILE} | (cd ../pip-build/pgadmin4; tar xf -)
echo Adding "${FILE}"
# shellcheck disable=SC2164
tar cf - "${FILE}" | (cd ../pip-build/pgadmin4; tar xf -)
done
cd ../docs
for FILE in `git ls-files`
cd ../docs || exit
for FILE in $(git ls-files)
do
echo Adding ${FILE}
echo Adding "${FILE}"
# 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
for DIR in `ls -d ??_??/`
for DIR in ./??_??/
do
if [ -d ${DIR}/_build/html ]; then
mkdir -p ../pip-build/pgadmin4/docs/${DIR}/_build
cp -R ${DIR}/_build/html ../pip-build/pgadmin4/docs/${DIR}/_build
if [ -d "${DIR}"/_build/html ]; then
mkdir -p "../pip-build/pgadmin4/docs/${DIR}/_build"
cp -R "${DIR}/_build/html" "../pip-build/pgadmin4/docs/${DIR}/_build"
fi
done
@ -85,6 +88,7 @@ for FILE in LICENSE DEPENDENCIES README.md
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 pip-build/pgadmin4; tar xf -)
done
@ -99,7 +103,7 @@ echo recursive-include pgadmin4 \* > pip-build/MANIFEST.in
# Run the build
echo Building wheel...
cd pip-build
cd pip-build || exit
python ../pkg/pip/setup_pip.py bdist_wheel
cd ../

View File

@ -10,30 +10,30 @@
#########################################################################
# 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.
exit 1
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.
exit 1
fi
# Get the required package info
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_NAME=`grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //'`
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_NAME=$(grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //')
APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION}
APP_SUFFIX=`grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g"`
if [ ! -z ${APP_SUFFIX} ]; then
APP_SUFFIX=$(grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g")
if [ -n "${APP_SUFFIX}" ]; then
export APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX}
fi
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)}'`
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)}')
# 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
echo Creating/cleaning required directories...
@ -41,58 +41,60 @@ if [ ! -d src-build ]; then
mkdir src-build
fi
if [ -d src-build/${TARBALL_NAME} ]; then
rm -rf src-build/${TARBALL_NAME}
if [ -d "src-build/${TARBALL_NAME}" ]; then
rm -rf "src-build/${TARBALL_NAME}"
fi
mkdir src-build/${TARBALL_NAME}
mkdir "src-build/${TARBALL_NAME}"
# Create the output directory if not present
if [ ! -d dist ]; then
mkdir dist
fi
if [ -f dist/${TARBALL_NAME}.tar.gz ]; then
rm -f dist/${TARBALL_NAME}.tar.gz
if [ -f "dist/${TARBALL_NAME}.tar.gz" ]; then
rm -f "dist/${TARBALL_NAME}.tar.gz"
fi
if [ -f dist/${DOC_TARBALL_NAME}.tar.gz ]; then
rm -f dist/${DOC_TARBALL_NAME}.tar.gz
if [ -f "dist/${DOC_TARBALL_NAME}.tar.gz" ]; then
rm -f "dist/${DOC_TARBALL_NAME}.tar.gz"
fi
# Build the clean tree
for FILE in `git ls-files`
for FILE in $(git ls-files)
do
echo Adding ${FILE}
echo Adding "${FILE}"
# 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
pushd web > /dev/null
pushd web > /dev/null || exit
yarn install
yarn run bundle
for FILE in `ls -d pgadmin/static/js/generated/*`
for FILE in pgadmin/static/js/generated/*
do
echo Adding ${FILE}
tar cf - ${FILE} | (cd ../src-build/${TARBALL_NAME}/web; tar xf -)
echo Adding "${FILE}"
# shellcheck disable=SC2164
tar cf - "${FILE}" | (cd "../src-build/${TARBALL_NAME}/web"; tar xf -)
done
popd > /dev/null
popd > /dev/null || exit
# Create the tarball
echo Creating tarball...
cd src-build
tar zcvf ../dist/${TARBALL_NAME}.tar.gz ${TARBALL_NAME}
cd src-build || exit
tar zcvf "../dist/${TARBALL_NAME}.tar.gz" "${TARBALL_NAME}"
cd ..
# Create the 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
cd _build
mv html ${DOC_TARBALL_NAME}
tar zcvf ../../../../../dist/${DOC_TARBALL_NAME}.tar.gz ${DOC_TARBALL_NAME}
cd _build || exit
mv html "${DOC_TARBALL_NAME}"
tar zcvf "../../../../../dist/${DOC_TARBALL_NAME}.tar.gz" "${DOC_TARBALL_NAME}"
cd ../../../../../
# 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"