Browse Source

CI: Quote all bash variables containing paths

SCG82 4 years ago
parent
commit
7225d248c3
1 changed files with 22 additions and 22 deletions
  1. 22 22
      CI/full-build-macos.sh

+ 22 - 22
CI/full-build-macos.sh

@@ -41,12 +41,12 @@ BUILD_DIR="${BUILD_DIR:-build}"
 BUILD_CONFIG=${BUILD_CONFIG:-RelWithDebInfo}
 CI_SCRIPTS="${CHECKOUT_DIR}/CI/scripts/macos"
 CI_WORKFLOW="${CHECKOUT_DIR}/.github/workflows/main.yml"
-CI_MACOS_CEF_VERSION=$(/bin/cat ${CI_WORKFLOW} | /usr/bin/sed -En "s/[ ]+MACOS_CEF_BUILD_VERSION: '([0-9]+)'/\1/p")
-CI_DEPS_VERSION=$(/bin/cat ${CI_WORKFLOW} | /usr/bin/sed -En "s/[ ]+MACOS_DEPS_VERSION: '([0-9\-]+)'/\1/p")
-CI_VLC_VERSION=$(/bin/cat ${CI_WORKFLOW} | /usr/bin/sed -En "s/[ ]+VLC_VERSION: '([0-9\.]+)'/\1/p")
-CI_SPARKLE_VERSION=$(/bin/cat ${CI_WORKFLOW} | /usr/bin/sed -En "s/[ ]+SPARKLE_VERSION: '([0-9\.]+)'/\1/p")
-CI_QT_VERSION=$(/bin/cat ${CI_WORKFLOW} | /usr/bin/sed -En "s/[ ]+QT_VERSION: '([0-9\.]+)'/\1/p" | /usr/bin/head -1)
-CI_MIN_MACOS_VERSION=$(/bin/cat ${CI_WORKFLOW} | /usr/bin/sed -En "s/[ ]+MIN_MACOS_VERSION: '([0-9\.]+)'/\1/p")
+CI_MACOS_CEF_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+MACOS_CEF_BUILD_VERSION: '([0-9]+)'/\1/p")
+CI_DEPS_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+MACOS_DEPS_VERSION: '([0-9\-]+)'/\1/p")
+CI_VLC_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+VLC_VERSION: '([0-9\.]+)'/\1/p")
+CI_SPARKLE_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+SPARKLE_VERSION: '([0-9\.]+)'/\1/p")
+CI_QT_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+QT_VERSION: '([0-9\.]+)'/\1/p" | /usr/bin/head -1)
+CI_MIN_MACOS_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+MIN_MACOS_VERSION: '([0-9\.]+)'/\1/p")
 NPROC="${NPROC:-$(sysctl -n hw.ncpu)}"
 
 BUILD_DEPS=(
@@ -99,7 +99,7 @@ exists() {
 }
 
 ensure_dir() {
-    [[ -n ${1} ]] && /bin/mkdir -p ${1} && builtin cd ${1}
+    [[ -n "${1}" ]] && /bin/mkdir -p "${1}" && builtin cd "${1}"
 }
 
 cleanup() {
@@ -142,7 +142,7 @@ install_homebrew_deps() {
         brew untap local/python2
     fi
 
-    brew bundle --file ${CI_SCRIPTS}/Brewfile
+    brew bundle --file "${CI_SCRIPTS}/Brewfile"
 
     check_curl
 }
@@ -160,23 +160,23 @@ check_curl() {
 }
 
 check_ccache() {
-    export PATH=/usr/local/opt/ccache/libexec:${PATH}
+    export PATH="/usr/local/opt/ccache/libexec:${PATH}"
     CCACHE_STATUS=$(ccache -s >/dev/null 2>&1 && /bin/echo "CCache available." || /bin/echo "CCache is not available.")
     info "${CCACHE_STATUS}"
 }
 
 install_obs-deps() {
     hr "Setting up pre-built macOS OBS dependencies v${1}"
-    ensure_dir ${DEPS_BUILD_DIR}
+    ensure_dir "${DEPS_BUILD_DIR}"
     step "Download..."
     ${CURLCMD} --progress-bar -L -C - -O https://github.com/obsproject/obs-deps/releases/download/${1}/macos-deps-${1}.tar.gz
     step "Unpack..."
-    /usr/bin/tar -xf ./macos-deps-${1}.tar.gz -C /tmp
+    /usr/bin/tar -xf "./macos-deps-${1}.tar.gz" -C /tmp
 }
 
 install_qt-deps() {
     hr "Setting up pre-built dependency QT v${1}"
-    ensure_dir ${DEPS_BUILD_DIR}
+    ensure_dir "${DEPS_BUILD_DIR}"
     step "Download..."
     ${CURLCMD} --progress-bar -L -C - -O https://github.com/obsproject/obs-deps/releases/download/${2}/macos-qt-${1}-${2}.tar.gz
     step "Unpack..."
@@ -186,7 +186,7 @@ install_qt-deps() {
 
 install_vlc() {
     hr "Setting up dependency VLC v${1}"
-    ensure_dir ${DEPS_BUILD_DIR}
+    ensure_dir "${DEPS_BUILD_DIR}"
     step "Download..."
     ${CURLCMD} --progress-bar -L -C - -O https://downloads.videolan.org/vlc/${1}/vlc-${1}.tar.xz
     step "Unpack ..."
@@ -195,7 +195,7 @@ install_vlc() {
 
 install_sparkle() {
     hr "Setting up dependency Sparkle v${1} (might prompt for password)"
-    ensure_dir ${DEPS_BUILD_DIR}/sparkle
+    ensure_dir "${DEPS_BUILD_DIR}/sparkle"
     step "Download..."
     ${CURLCMD} --progress-bar -L -C - -o sparkle.tar.bz2 https://github.com/sparkle-project/Sparkle/releases/download/${1}/Sparkle-${1}.tar.bz2
     step "Unpack..."
@@ -210,7 +210,7 @@ install_sparkle() {
 
 install_cef() {
     hr "Building dependency CEF v${1}"
-    ensure_dir ${DEPS_BUILD_DIR}
+    ensure_dir "${DEPS_BUILD_DIR}"
     step "Download..."
     ${CURLCMD} --progress-bar -L -C - -O https://cdn-fastly.obsproject.com/downloads/cef_binary_${1}_macosx64.tar.bz2
     step "Unpack..."
@@ -257,13 +257,13 @@ configure_obs_build() {
 
     if [ -d ./OBS.app ]; then
         ensure_dir "${NIGHTLY_DIR}"
-        /bin/mv ../${BUILD_DIR}/OBS.app .
+        /bin/mv "../${BUILD_DIR}/OBS.app" .
         info "You can find OBS.app in ${NIGHTLY_DIR}"
     fi
     ensure_dir "${CHECKOUT_DIR}/${BUILD_DIR}"
     if ([ -n "${PACKAGE_NAME}" ] && [ -f ${PACKAGE_NAME} ]); then
         ensure_dir "${NIGHTLY_DIR}"
-        /bin/mv ../${BUILD_DIR}/$(basename "${PACKAGE_NAME}") .
+        /bin/mv "../${BUILD_DIR}/$(basename "${PACKAGE_NAME}")" .
         info "You can find ${PACKAGE_NAME} in ${NIGHTLY_DIR}"
     fi
 
@@ -330,13 +330,13 @@ bundle_dylibs() {
         ./OBS.app/Contents/PlugIns/obs-outputs.so
         )
     if ! [ "${MACOS_CEF_BUILD_VERSION:-${CI_MACOS_CEF_VERSION}}" -le 3770 ]; then
-        ${CI_SCRIPTS}/app/dylibbundler -cd -of -a ./OBS.app -q -f \
+        "${CI_SCRIPTS}/app/dylibbundler" -cd -of -a ./OBS.app -q -f \
             -s ./OBS.app/Contents/MacOS \
             -s "${DEPS_BUILD_DIR}/sparkle/Sparkle.framework" \
             -s ./rundir/${BUILD_CONFIG}/bin/ \
             $(echo "${BUNDLE_PLUGINS[@]/#/-x }")
     else
-        ${CI_SCRIPTS}/app/dylibbundler -cd -of -a ./OBS.app -q -f \
+        "${CI_SCRIPTS}/app/dylibbundler" -cd -of -a ./OBS.app -q -f \
             -s ./OBS.app/Contents/MacOS \
             -s "${DEPS_BUILD_DIR}/sparkle/Sparkle.framework" \
             -s ./rundir/${BUILD_CONFIG}/bin/ \
@@ -401,9 +401,9 @@ prepare_macos_bundle() {
         /bin/cp -R "rundir/${BUILD_CONFIG}/bin/OBS Helper (Renderer).app" "./OBS.app/Contents/Frameworks/OBS Helper (Renderer).app"
     fi
     /bin/cp -R rundir/${BUILD_CONFIG}/data ./OBS.app/Contents/Resources
-    /bin/cp ${CI_SCRIPTS}/app/AppIcon.icns ./OBS.app/Contents/Resources
+    /bin/cp "${CI_SCRIPTS}/app/AppIcon.icns" ./OBS.app/Contents/Resources
     /bin/cp -R rundir/${BUILD_CONFIG}/obs-plugins/ ./OBS.app/Contents/PlugIns
-    /bin/cp ${CI_SCRIPTS}/app/Info.plist ./OBS.app/Contents
+    /bin/cp "${CI_SCRIPTS}/app/Info.plist" ./OBS.app/Contents
     # Scripting plugins are required to be placed in same directory as binary
     if [ -d ./OBS.app/Contents/Resources/data/obs-scripting ]; then
         /bin/mv ./OBS.app/Contents/Resources/data/obs-scripting/obslua.so ./OBS.app/Contents/MacOS/
@@ -415,7 +415,7 @@ prepare_macos_bundle() {
     bundle_dylibs
     install_frameworks
 
-    /bin/cp ${CI_SCRIPTS}/app/OBSPublicDSAKey.pem ./OBS.app/Contents/Resources
+    /bin/cp "${CI_SCRIPTS}/app/OBSPublicDSAKey.pem" ./OBS.app/Contents/Resources
 
     step "Set bundle meta information..."
     /usr/bin/plutil -insert CFBundleVersion -string ${GIT_TAG}-${GIT_HASH} ./OBS.app/Contents/Info.plist