From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- tools/update-verify/release/common/unpack.sh | 68 +++++++++++++++------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'tools/update-verify/release/common/unpack.sh') diff --git a/tools/update-verify/release/common/unpack.sh b/tools/update-verify/release/common/unpack.sh index 3249936493..a0e1204487 100755 --- a/tools/update-verify/release/common/unpack.sh +++ b/tools/update-verify/release/common/unpack.sh @@ -1,11 +1,5 @@ #!/bin/bash -function cleanup() { - hdiutil detach ${DEV_NAME} || - { sleep 5 && hdiutil detach ${DEV_NAME} -force; }; - return $1 && $?; -}; - unpack_build () { unpack_platform="$1" dir_name="$2" @@ -13,27 +7,35 @@ unpack_build () { locale=$4 unpack_jars=$5 update_settings_string=$6 + # If provided, must be a directory containing `update-settings.ini` which + # will be used instead of attempting to find this file in the unpacked + # build. `update_settings_string` modifications will still be performed on + # the file. + local mac_update_settings_dir_override + mac_update_settings_dir_override=$7 + local product + product=$8 if [ ! -f "$pkg_file" ]; then return 1 fi - mkdir -p $dir_name - pushd $dir_name > /dev/null + mkdir -p "$dir_name" + pushd "$dir_name" > /dev/null || exit case $unpack_platform in # $unpack_platform is either # - a balrog platform name (from testing/mozharness/scripts/release/update-verify-config-creator.py) # - a simple platform name (from tools/update-verify/release/updates/verify.sh) mac|Darwin_*) - os=`uname` + os=$(uname) # How we unpack a dmg differs depending on which platform we're on. if [[ "$os" == "Darwin" ]] then cd ../ echo "installing $pkg_file" - ../common/unpack-diskimage.sh "$pkg_file" mnt $dir_name + ../common/unpack-diskimage.sh "$pkg_file" mnt "$dir_name" else 7z x ../"$pkg_file" > /dev/null - if [ `ls -1 | wc -l` -ne 1 ] + if [ "$(find . -mindepth 1 -maxdepth 1 | wc -l)" -ne 1 ] then echo "Couldn't find .app package" return 1 @@ -43,14 +45,18 @@ unpack_build () { mv "${unpack_dir}"/*.app . rm -rf "${unpack_dir}" appdir=$(ls -1) - appdir=$(ls -d *.app) - # The updater guesses the location of these files based on - # its own target architecture, not the mar. If we're not - # unpacking mac-on-mac, we need to copy them so it can find - # them. It's important to copy (and not move), because when - # we diff the installer vs updated build afterwards, the - # installer version will have them in their original place. - cp "${appdir}/Contents/Resources/update-settings.ini" "${appdir}/update-settings.ini" + appdir=$(ls -d ./*.app) + if [ -d "${mac_update_settings_dir_override}" ]; then + cp "${mac_update_settings_dir_override}/update-settings.ini" "${appdir}/update-settings.ini" + else + # The updater guesses the location of these files based on + # its own target architecture, not the mar. If we're not + # unpacking mac-on-mac, we need to copy them so it can find + # them. It's important to copy (and not move), because when + # we diff the installer vs updated build afterwards, the + # installer version will have them in their original place. + cp "${appdir}/Contents/Resources/update-settings.ini" "${appdir}/update-settings.ini" + fi cp "${appdir}/Contents/Resources/precomplete" "${appdir}/precomplete" fi update_settings_file="${appdir}/update-settings.ini" @@ -64,7 +70,7 @@ unpack_build () { cp -rp localized/* bin/ rm -rf nonlocalized rm -rf localized - if [ $(find optional/ | wc -l) -gt 1 ] + if [ "$(find optional/ | wc -l)" -gt 1 ] then cp -rp optional/* bin/ rm -rf optional @@ -77,45 +83,43 @@ unpack_build () { else for file in *.xpi do - unzip -o $file > /dev/null + unzip -o "$file" > /dev/null done - unzip -o ${locale}.xpi > /dev/null + unzip -o "${locale}".xpi > /dev/null fi update_settings_file='bin/update-settings.ini' ;; linux|Linux_*) - if `echo $pkg_file | grep -q "tar.gz"` + if echo "$pkg_file" | grep -q "tar.gz" then tar xfz ../"$pkg_file" > /dev/null - elif `echo $pkg_file | grep -q "tar.bz2"` + elif echo "$pkg_file" | grep -q "tar.bz2" then tar xfj ../"$pkg_file" > /dev/null else echo "Unknown package type for file: $pkg_file" exit 1 fi - update_settings_file=`echo $product | tr '[A-Z]' '[a-z]'`'/update-settings.ini' + update_settings_file=$(echo "$product" | tr '[:upper:]' '[:lower:]')'/update-settings.ini' ;; *) echo "Unknown platform to unpack: $unpack_platform" exit 1 esac - if [ ! -z $unpack_jars ]; then - for f in `find . -name '*.jar' -o -name '*.ja'`; do - unzip -o "$f" -d "$f.dir" > /dev/null - done + if [ -n "$unpack_jars" ]; then + find . \( -name '*.jar' -o -name '*.ja' \) -exec unzip -o {} -d {}.dir \; >/dev/null fi - if [ ! -z $update_settings_string ]; then + if [ -n "$update_settings_string" ]; then echo "Modifying update-settings.ini" - cat "${update_settings_file}" | sed -e "s/^ACCEPTED_MAR_CHANNEL_IDS.*/ACCEPTED_MAR_CHANNEL_IDS=${update_settings_string}/" > "${update_settings_file}.new" + sed -e "s/^ACCEPTED_MAR_CHANNEL_IDS.*/ACCEPTED_MAR_CHANNEL_IDS=${update_settings_string}/" < "${update_settings_file}" > "${update_settings_file}.new" diff -u "${update_settings_file}" "${update_settings_file}.new" echo " " rm "${update_settings_file}" mv "${update_settings_file}.new" "${update_settings_file}" fi - popd > /dev/null + popd > /dev/null || exit } -- cgit v1.2.3