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)

Related: RHEL-30946
This commit is contained in:
Andrew Hughes 2024-03-20 20:23:41 +00:00
parent f3802e52a4
commit 31ea1e8cdf
2 changed files with 30 additions and 24 deletions

View File

@ -105,18 +105,18 @@ BUILD_VER=${NUM_VER##*+}
MAJOR_VER=${RELEASE_VER%%.*} MAJOR_VER=${RELEASE_VER%%.*}
echo "Major version is ${MAJOR_VER}, release ${RELEASE_VER}, build ${BUILD_VER}" 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". echo "No boot JDK specified".
BOOT_JDK=/usr/lib/jvm/java-${MAJOR_VER}-openjdk; BOOT_JDK=/usr/lib/jvm/java-${MAJOR_VER}-openjdk;
echo -n "Checking for ${BOOT_JDK}..."; 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}"; echo "Boot JDK found at ${BOOT_JDK}";
else else
echo "Not found"; echo "Not found";
PREV_VER=$((${MAJOR_VER} - 1)); PREV_VER=$((MAJOR_VER - 1));
BOOT_JDK=/usr/lib/jvm/java-${PREV_VER}-openjdk; BOOT_JDK=/usr/lib/jvm/java-${PREV_VER}-openjdk;
echo -n "Checking for ${BOOT_JDK}..."; 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}"; echo "Boot JDK found at ${BOOT_JDK}";
else else
echo "Not found"; echo "Not found";
@ -127,43 +127,41 @@ else
echo "Boot JDK: ${BOOT_JDK}"; echo "Boot JDK: ${BOOT_JDK}";
fi fi
# REPO_NAME is only needed when we default on REPO_ROOT and FILE_NAME_ROOT if [ "$OPENJDK_URL" = "" ] ; then
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
OPENJDK_URL=${OPENJDK_URL_DEFAULT} OPENJDK_URL=${OPENJDK_URL_DEFAULT}
echo "No OpenJDK URL specified; defaulting to ${OPENJDK_URL}" echo "No OpenJDK URL specified; defaulting to ${OPENJDK_URL}"
else else
echo "OpenJDK URL: ${OPENJDK_URL}" echo "OpenJDK URL: ${OPENJDK_URL}"
fi fi
if [ "x$COMPRESSION" = "x" ] ; then if [ "$COMPRESSION" = "" ] ; then
# rhel 5 needs tar.gz # rhel 5 needs tar.gz
COMPRESSION=${COMPRESSION_DEFAULT} COMPRESSION=${COMPRESSION_DEFAULT}
fi fi
echo "Creating a tar.${COMPRESSION} archive" echo "Creating a tar.${COMPRESSION} archive"
if [ "x$FILE_NAME_ROOT" = "x" ] ; then if [ "$FILE_NAME_ROOT" = "" ] ; then
FILE_NAME_ROOT=${PROJECT_NAME}-${REPO_NAME}-${VERSION} 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}" echo "No file name root specified; default to ${FILE_NAME_ROOT}"
fi 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" REPO_ROOT="${OPENJDK_URL}/${PROJECT_NAME}/${REPO_NAME}.git"
echo "No repository root specified; default to ${REPO_ROOT}" echo "No repository root specified; default to ${REPO_ROOT}"
fi; fi;
if [ "x$TO_COMPRESS" = "x" ] ; then if [ "$TO_COMPRESS" = "" ] ; then
TO_COMPRESS="${VERSION}" TO_COMPRESS="${VERSION}"
echo "No targets to be compressed specified ; default to ${TO_COMPRESS}" echo "No targets to be compressed specified ; default to ${TO_COMPRESS}"
fi; fi;
@ -251,4 +249,5 @@ fi
# Local Variables: # Local Variables:
# fill-column: 80 # fill-column: 80
# compile-command: "shellcheck generate_source_tarball.sh"
# End: # End:

View File

@ -2505,6 +2505,13 @@ cjc.mainProgram(args)
- generate_source_tarball.sh: Prefix temporary directory with temp- - generate_source_tarball.sh: Prefix temporary directory with temp-
- generate_source_tarball.sh: Remove temporary directory exit conditions - generate_source_tarball.sh: Remove temporary directory exit conditions
- generate_source_tarball.sh: Fix -ea logic to add dash - generate_source_tarball.sh: Fix -ea logic to add dash
- 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-30946 - Related: RHEL-30946
* Sun Apr 14 2024 Andrew Hughes <gnu.andrew@redhat.com> - 1:21.0.3.0.1-0.2.ea * Sun Apr 14 2024 Andrew Hughes <gnu.andrew@redhat.com> - 1:21.0.3.0.1-0.2.ea