From 0c7cbe33ecc13d669a19bbf821d1dc7e350c55c9 Mon Sep 17 00:00:00 2001 From: Ben Hearsum Date: Fri, 8 Mar 2024 00:12:29 +0000 Subject: [PATCH] Bug 1883123: add support for using host platform update-settings.ini in update verify r=jcristau This allows macOS update verify to continue working when `update-settings.ini` no longer exists in these packages. Differential Revision: https://phabricator.services.mozilla.com/D203802 --- .../release/common/check_updates.sh | 16 +++++++++++-- tools/update-verify/release/common/unpack.sh | 24 +++++++++++++------ tools/update-verify/release/updates/verify.sh | 20 +++++++++++++++- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/tools/update-verify/release/common/check_updates.sh b/tools/update-verify/release/common/check_updates.sh index 31585e16e21f8..8f9701311fe98 100644 --- a/tools/update-verify/release/common/check_updates.sh +++ b/tools/update-verify/release/common/check_updates.sh @@ -12,17 +12,29 @@ check_updates () { channel=$8 mar_channel_IDs=$9 update_to_dep=${10} + local mac_update_settings_dir_override + mac_update_settings_dir_override=${11} # cleanup rm -rf source/* rm -rf target/* - unpack_build $update_platform source "$source_package" $locale '' $mar_channel_IDs + # $mac_update_settings_dir_override allows unpack_build to find a host platform appropriate + # `update-settings.ini` file, which is needed to successfully run the updater later in this + # function. + unpack_build $update_platform source "$source_package" $locale '' "$mar_channel_IDs" $mac_update_settings_dir_override if [ "$?" != "0" ]; then echo "FAILED: cannot unpack_build $update_platform source $source_package" return 1 fi - unpack_build $update_platform target "$target_package" $locale + + # Unlike unpacking the `source` build, we don't actually _need_ $mac_update_settings_dir_override + # here to succesfully apply the update, but its usage in `source` causes an `update-settings.ini` + # file to be present in the directory we diff, which means we either also need it present in the + # `target` directory, or to remove it after the update is applied. The latter was chosen + # because it keeps the workaround close together (as opposed to just above this, and then much + # further down). + unpack_build $update_platform target "$target_package" $locale '' '' $mac_update_settings_dir_override if [ "$?" != "0" ]; then echo "FAILED: cannot unpack_build $update_platform target $target_package" return 1 diff --git a/tools/update-verify/release/common/unpack.sh b/tools/update-verify/release/common/unpack.sh index 3249936493d27..7728e23d888de 100755 --- a/tools/update-verify/release/common/unpack.sh +++ b/tools/update-verify/release/common/unpack.sh @@ -13,6 +13,12 @@ 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 if [ ! -f "$pkg_file" ]; then return 1 @@ -44,13 +50,17 @@ unpack_build () { 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" + 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" diff --git a/tools/update-verify/release/updates/verify.sh b/tools/update-verify/release/updates/verify.sh index 3f8556b4248f5..ee6aaf6b47274 100755 --- a/tools/update-verify/release/updates/verify.sh +++ b/tools/update-verify/release/updates/verify.sh @@ -114,6 +114,7 @@ do use_old_updater=0 mar_channel_IDs="" updater_package="" + mac_update_settings_dir_override="" eval $entry # the arguments for updater changed in Gecko 34/SeaMonkey 2.31 @@ -177,18 +178,35 @@ do platform_dirname="*.app" updater_bins="Contents/MacOS/updater.app/Contents/MacOS/updater Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater" updater_platform="mac" + mac_update_settings_dir_override="" ;; *exe) updater_package_url=`echo "${updater_package_url}" | sed "s/ja-JP-mac/ja/"` platform_dirname="bin" updater_bins="updater.exe" updater_platform="win32" + case $platform in + Darwin_*) + mac_update_settings_dir_override="${PWD}/updater/${platform_dirname}" + ;; + *) + mac_update_settings_dir_override="" + ;; + esac ;; *bz2) updater_package_url=`echo "${updater_package_url}" | sed "s/ja-JP-mac/ja/"` platform_dirname=`echo $product | tr '[A-Z]' '[a-z]'` updater_bins="updater" updater_platform="linux" + case $platform in + Darwin_*) + mac_update_settings_dir_override="${PWD}/updater/${platform_dirname}" + ;; + *) + mac_update_settings_dir_override="" + ;; + esac ;; *) echo "Couldn't detect updater platform" @@ -256,7 +274,7 @@ do if [ -e ${diff_file} ]; then rm ${diff_file} fi - check_updates "${platform}" "downloads/${source_file}" "downloads/${target_file}" ${locale} ${use_old_updater} ${updater} ${diff_file} ${channel} "${mar_channel_IDs}" ${update_to_dep} + check_updates "${platform}" "downloads/${source_file}" "downloads/${target_file}" ${locale} ${use_old_updater} ${updater} ${diff_file} ${channel} "${mar_channel_IDs}" ${update_to_dep} ${mac_update_settings_dir_override} err=$? if [ "$err" == "0" ]; then continue