Skip to content

Commit

Permalink
Bug 1883123: add support for using host platform update-settings.ini …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
bhearsum committed Mar 8, 2024
1 parent b14d4a6 commit 0c7cbe3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
16 changes: 14 additions & 2 deletions tools/update-verify/release/common/check_updates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 17 additions & 7 deletions tools/update-verify/release/common/unpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
20 changes: 19 additions & 1 deletion tools/update-verify/release/updates/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c7cbe3

Please sign in to comment.