Fix shellcheck issues with generate_source_tarball.sh

- generate_source_tarball.sh: Set compile-command in Emacs
- generate_source_tarball.sh: Remove REPO_NAME from FILE_NAME_ROOT
- generate_source_tarball.sh: Move PROJECT_NAME and REPO_NAME checks
- generate_source_tarball.sh: shellcheck: Remove x-prefixes since we use Bash (SC2268)
- generate_source_tarball.sh: shellcheck: Double-quote variable references (SC2086)
- generate_source_tarball.sh: shellcheck: Do not use -a (SC2166)
- generate_source_tarball.sh: shellcheck: Do not use $ on arithmetic variables (SC2004)
- generate_source_tarball.sh: Add quoting for SCRIPT_DIR and JCONSOLE_PATCH (SC2086)

Related: RHEL-30937
This commit is contained in:
Andrew Hughes 2024-04-02 17:46:08 +01:00
parent 1df7842e2a
commit 4d5c302e43
2 changed files with 32 additions and 25 deletions

View File

@ -28,7 +28,7 @@
# This script creates a single source tarball out of the repository based on the
# given tag and removes code not allowed in Fedora/RHEL.
SCRIPT_DIR=$(dirname $0)
SCRIPT_DIR=$(dirname "$0")
JCONSOLE_PATCH_DEFAULT=${SCRIPT_DIR}/jconsole-plugin.patch
if [ "x${JCONSOLE_PATCH}" != "x" ] ; then
@ -110,18 +110,18 @@ BUILD_VER=${NUM_VER##*-}
MAJOR_VER=${RELEASE_VER%%u*}
echo "Major version is ${MAJOR_VER}, release ${RELEASE_VER}, build ${BUILD_VER}"
if [ "x$BOOT_JDK" = "x" ] ; then
if [ "$BOOT_JDK" = "" ] ; then
echo "No boot JDK specified".
BOOT_JDK=/usr/lib/jvm/java-1.${MAJOR_VER}.0-openjdk;
echo -n "Checking for ${BOOT_JDK}...";
if [ -d ${BOOT_JDK} -a -x ${BOOT_JDK}/bin/java ] ; then
if [ -d "${BOOT_JDK}" ] && [ -x "${BOOT_JDK}"/bin/java ] ; then
echo "Boot JDK found at ${BOOT_JDK}";
else
echo "Not found";
PREV_VER=$((${MAJOR_VER} - 1));
PREV_VER=$((MAJOR_VER - 1));
BOOT_JDK=/usr/lib/jvm/java-1.${PREV_VER}.0-openjdk;
echo -n "Checking for ${BOOT_JDK}...";
if [ -d ${BOOT_JDK} -a -x ${BOOT_JDK}/bin/java ] ; then
if [ -d ${BOOT_JDK} ] && [ -x ${BOOT_JDK}/bin/java ] ; then
echo "Boot JDK found at ${BOOT_JDK}";
else
echo "Not found";
@ -132,38 +132,36 @@ else
echo "Boot JDK: ${BOOT_JDK}";
fi
# REPO_NAME is only needed when we default on REPO_ROOT and FILE_NAME_ROOT
if [ "x$FILE_NAME_ROOT" = "x" -o "x$REPO_ROOT" = "x" ] ; then
if [ "x$PROJECT_NAME" = "x" ] ; then
echo "No PROJECT_NAME specified"
exit 1
fi
echo "Project name: ${PROJECT_NAME}"
if [ "x$REPO_NAME" = "x" ] ; then
echo "No REPO_NAME specified"
exit 3
fi
echo "Repository name: ${REPO_NAME}"
fi
if [ "x$OPENJDK_URL" = "x" ] ; then
if [ "$OPENJDK_URL" = "" ] ; then
OPENJDK_URL=${OPENJDK_URL_DEFAULT}
echo "No OpenJDK URL specified; defaulting to ${OPENJDK_URL}"
else
echo "OpenJDK URL: ${OPENJDK_URL}"
fi
if [ "x$COMPRESSION" = "x" ] ; then
if [ "$COMPRESSION" = "" ] ; then
# rhel 5 needs tar.gz
COMPRESSION=${COMPRESSION_DEFAULT}
fi
echo "Creating a tar.${COMPRESSION} archive"
if [ "x$FILE_NAME_ROOT" = "x" ] ; then
FILE_NAME_ROOT=${PROJECT_NAME}-${REPO_NAME}-${VERSION}
if [ "$FILE_NAME_ROOT" = "" ] ; then
if [ "$PROJECT_NAME" = "" ] ; then
echo "No PROJECT_NAME specified, needed by FILE_NAME_ROOT"
exit 1
fi
FILE_NAME_ROOT=${PROJECT_NAME}-${VERSION}
echo "No file name root specified; default to ${FILE_NAME_ROOT}"
fi
if [ "x$REPO_ROOT" = "x" ] ; then
if [ "$REPO_ROOT" = "" ] ; then
if [ "$PROJECT_NAME" = "" ] ; then
echo "No PROJECT_NAME specified, needed by REPO_ROOT"
exit 1
fi
if [ "$REPO_NAME" = "" ] ; then
echo "No REPO_NAME specified, needed by REPO_ROOT"
exit 3
fi
REPO_ROOT="${OPENJDK_URL}/${PROJECT_NAME}/${REPO_NAME}.git"
echo "No repository root specified; default to ${REPO_ROOT}"
fi;
@ -203,7 +201,7 @@ if [ -d jdk ]; then
fi
echo "Patching out use of jconsole.js"
git apply --stat --apply -v -p1 ${JCONSOLE_PATCH}
git apply --stat --apply -v -p1 "${JCONSOLE_PATCH}"
find . -name '*.orig' -exec rm -vf '{}' ';'
@ -262,4 +260,5 @@ fi
# Local Variables:
# fill-column: 80
# compile-command: "shellcheck generate_source_tarball.sh"
# End:

View File

@ -2902,6 +2902,7 @@ cjc.mainProgram(args)
- generate_source_tarball.sh: Rename JCONSOLE_JS_PATCH{,_DEFAULT} to JCONSOLE_PATCH{,_DEFAULT} for brevity
- generate_source_tarball.sh: Adapt OPENJDK_LATEST logic to work with 8u Shenandoah fork
- generate_source_tarball.sh: Adapt version logic to work with 8u
- generate_source_tarball.sh: Add quoting for SCRIPT_DIR and JCONSOLE_PATCH (SC2086)
- Related: RHEL-30937
* Fri Mar 22 2024 Thomas Fitzsimmons <fitzsim@redhat.com> - 1:1.8.0.412.b01-0.2.ea
@ -2917,6 +2918,13 @@ cjc.mainProgram(args)
- generate_source_tarball.sh: Make tarball reproducible
- generate_source_tarball.sh: Prefix temporary directory with temp-
- generate_source_tarball.sh: Remove temporary directory exit conditions
- generate_source_tarball.sh: Set compile-command in Emacs
- generate_source_tarball.sh: Remove REPO_NAME from FILE_NAME_ROOT
- generate_source_tarball.sh: Move PROJECT_NAME and REPO_NAME checks
- generate_source_tarball.sh: shellcheck: Remove x-prefixes since we use Bash (SC2268)
- generate_source_tarball.sh: shellcheck: Double-quote variable references (SC2086)
- generate_source_tarball.sh: shellcheck: Do not use -a (SC2166)
- generate_source_tarball.sh: shellcheck: Do not use $ on arithmetic variables (SC2004)
- Related: RHEL-30937
* Thu Mar 21 2024 Andrew Hughes <gnu.andrew@redhat.com> - 1:1.8.0.412.b01-0.2.ea