From 9eff793724d9431896c147c5197d26777e78fd4c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 27 Aug 2023 08:10:27 +0300 Subject: [PATCH 3/3] meson-winbuild.sh: Improve env variable quotation See osdn #48546 Signed-off-by: Marko Lindqvist --- windows/installer_cross/meson-winbuild.sh | 81 ++++++++++++----------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/windows/installer_cross/meson-winbuild.sh b/windows/installer_cross/meson-winbuild.sh index ea74f4fa7e..742c6c73cd 100755 --- a/windows/installer_cross/meson-winbuild.sh +++ b/windows/installer_cross/meson-winbuild.sh @@ -17,56 +17,56 @@ if test "$1" = "" || test "$1" = "-h" || test "$1" = "--help" ; then fi if test "$1" = "-v" || test "$1" = "--version" ; then - echo "meson-winbuild.sh version $MESON_WINBUILD_VERSION" + echo "meson-winbuild.sh version ${MESON_WINBUILD_VERSION}" exit fi GUI="$2" -if test "$GUI" != "gtk3.22" && test "$GUI" != "gtk4" && - test "$GUI" != "sdl2" && - test "$GUI" != "qt5" && test "$GUI" != "qt6" && - test "$GUI" != "ruledit" ; then +if test "${GUI}" != "gtk3.22" && test "${GUI}" != "gtk4" && + test "${GUI}" != "sdl2" && + test "${GUI}" != "qt5" && test "${GUI}" != "qt6" && + test "${GUI}" != "ruledit" ; then echo "Unknown gui \"$2\"" >&2 exit 1 fi DLLSPATH="$1" -if ! test -d "$DLLSPATH" ; then - echo "Dllstack directory \"$DLLSPATH\" not found!" >&2 +if ! test -d "${DLLSPATH}" ; then + echo "Dllstack directory \"${DLLSPATH}\" not found!" >&2 exit 1 fi -if ! test -f "$DLLSPATH/crosser.txt" ; then - echo "Directory \"$DLLSPATH\" does not look like crosser environment!" >&2 +if ! test -f "${DLLSPATH}/crosser.txt" ; then + echo "Directory \"${DLLSPATH}\" does not look like crosser environment!" >&2 exit 1 fi SRC_ROOT="$(cd ../.. || exit 1 ; pwd)" VERREV="$(${SRC_ROOT}/fc_version)" -if test "$INST_CROSS_MODE" != "release" ; then - if test -d ${SRC_ROOT}/.git || test -f ${SRC_ROOT}/.git ; then - VERREV="$VERREV-$(cd ${SRC_ROOT} && git rev-parse --short HEAD)" +if test "${INST_CROSS_MODE}" != "release" ; then + if test -d "${SRC_ROOT}/.git" || test -f "${SRC_ROOT}/.git" ; then + VERREV="${VERREV}-$(cd "${SRC_ROOT}" && git rev-parse --short HEAD)" fi fi -FLVL=$(grep "CrosserFeatureLevel=" $DLLSPATH/crosser.txt | sed -e 's/CrosserFeatureLevel="//' -e 's/"//') +FLVL=$(grep "CrosserFeatureLevel=" "${DLLSPATH}/crosser.txt" | sed -e 's/CrosserFeatureLevel="//' -e 's/"//') -if test "$FLVL" != "$CROSSER_FEATURE_LEVEL" ; then - echo "Crosser feature level \"$FLVL\", required \"$CROSSER_FEATURE_LEVEL\"!" >&2 +if test "${FLVL}" != "${CROSSER_FEATURE_LEVEL}" ; then + echo "Crosser feature level \"${FLVL}\", required \"${CROSSER_FEATURE_LEVEL}\"!" >&2 exit 1 fi -CSET=$(grep "CrosserSet=" $DLLSPATH/crosser.txt | sed -e 's/CrosserSet="//' -e 's/"//') +CSET=$(grep "CrosserSet=" "${DLLSPATH}/crosser.txt" | sed -e 's/CrosserSet="//' -e 's/"//') -if test "$CSET" != "current" ; then - echo "Crosser set is \"$CSET\", only \"current\" is supported!" >&2 +if test "${CSET}" != "current" ; then + echo "Crosser set is \"${CSET}\", only \"current\" is supported!" >&2 exit 1 fi -SETUP=$(grep "CrosserSetup=" $DLLSPATH/crosser.txt | sed -e 's/CrosserSetup="//' -e 's/"//') +SETUP=$(grep "CrosserSetup=" "${DLLSPATH}/crosser.txt" | sed -e 's/CrosserSetup="//' -e 's/"//') if ! test -f "setups/cross-${SETUP}.tmpl" ; then echo "Unsupported crosser setup \"${SETUP}\"!" >&2 @@ -75,7 +75,7 @@ fi QTPARAMS="" -case "$GUI" in +case "${GUI}" in gtk3.22) FCMP="gtk3" RULEDIT=false ;; gtk4) FCMP="gtk4" @@ -98,11 +98,11 @@ case "$GUI" in QTPARAMS="-Dqtver=qt6" ;; esac -if test "$CLIENT" = "" ; then - CLIENT="$GUI" +if test "${CLIENT}" = "" ; then + CLIENT="${GUI}" fi -if test "$GUI" = "ruledit" ; then +if test "${GUI}" = "ruledit" ; then SERVER="disabled" MWAND="false" else @@ -122,10 +122,10 @@ if ! mkdir -p "${BUILD_DIR}" ; then exit 1 fi -if ! sed "s,,$DLLSPATH,g" setups/cross-${SETUP}.tmpl \ +if ! sed "s,,${DLLSPATH},g" "setups/cross-${SETUP}.tmpl" \ > "${BUILD_DIR}/cross.txt" then - echo "Failed to create cross-file for $SETUP build!" >&2 + echo "Failed to create cross-file for ${SETUP} build!" >&2 exit 1 fi @@ -138,30 +138,30 @@ if ! rm -Rf "${MESON_INSTALL_DIR}" ; then fi echo "----------------------------------" -echo "Building for $SETUP" -echo "Freeciv version $VERREV" +echo "Building for ${SETUP}" +echo "Freeciv version ${VERREV}" echo "----------------------------------" if ! ( cd "${BUILD_DIR}" -export PKG_CONFIG_PATH=${DLLSPATH}/lib/pkgconfig +export PKG_CONFIG_PATH="${DLLSPATH}/lib/pkgconfig" -export PATH="$DLLSPATH/linux/libexec:$PATH" +export PATH="${DLLSPATH}/linux/libexec:${PATH}" if ! meson setup \ --cross-file=cross.txt \ - -Dprefix="$MESON_INSTALL_DIR" \ - -Dmin-win-ver="$MIN_WINVER" \ - -Dclients="$CLIENT" -Dfcmp="$FCMP" \ + -Dprefix="${MESON_INSTALL_DIR}" \ + -Dmin-win-ver="${MIN_WINVER}" \ + -Dclients="${CLIENT}" -Dfcmp="${FCMP}" \ -Dsyslua=false \ -Dmwand="${MWAND}" \ -Dreadline=false \ - -Dserver="$SERVER" \ - -Druledit="$RULEDIT" \ + -Dserver="${SERVER}" \ + -Druledit="${RULEDIT}" \ -Ddefault_library=static \ - $QTPARAMS \ - $EXTRA_CONFIG \ + ${QTPARAMS} \ + ${EXTRA_CONFIG} \ "${SRC_ROOT}" ; then echo "Meson run failed!" >&2 exit 1 @@ -177,17 +177,18 @@ if ! ninja install; then exit 1 fi -if ! cp fc_config.h ${MESON_INSTALL_DIR}/share/freeciv/ ; then +if ! cp fc_config.h "${MESON_INSTALL_DIR}/share/freeciv/" ; then echo "Storing fc_config.h failed" >&2 exit 1 fi -if ! cp ${DLLSPATH}/crosser.txt ${MESON_INSTALL_DIR}/share/freeciv/ ; then +if ! cp "${DLLSPATH}/crosser.txt" "${MESON_INSTALL_DIR}/share/freeciv/" ; then echo "Storing crosser.txt failed" >&2 exit 1 fi -if ! cp ${DLLSPATH}/ComponentVersions.txt ${MESON_INSTALL_DIR}/share/freeciv/CrosserComponents.txt +if ! cp "${DLLSPATH}/ComponentVersions.txt" \ + "${MESON_INSTALL_DIR}/share/freeciv/CrosserComponents.txt" then echo "Storing CrosserComponents.txt failed" >&2 exit 1 @@ -204,7 +205,7 @@ fi ( cd meson/install - if ! 7z a -r ../output/${PACKAGENAME}.7z ${PACKAGENAME} + if ! 7z a -r "../output/${PACKAGENAME}.7z" "${PACKAGENAME}" then echo "7z failed" >&2 exit 1 -- 2.40.1