Commit d28a42ed authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Update keystone install script for SxS.

Provide the keystone install script with a list of names that might
be the names of the updated Chrome app.

Update handling of brand codes by allowing side-by-side Chromes their
own brand codes.

Bug: 1061486
Change-Id: Ia1bcc1bf1326e7a35c332a61e9569ece32396662
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2233599
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776125}
parent 42b4abad
......@@ -595,10 +595,9 @@ main() {
trap cleanup EXIT HUP INT QUIT TERM
readonly PRODUCT_NAME="Google Chrome"
readonly APP_DIR="${PRODUCT_NAME}.app"
readonly ALTERNATE_APP_DIR="${PRODUCT_NAME} Canary.app"
readonly FRAMEWORK_NAME="${PRODUCT_NAME} Framework"
readonly APP_DIR_NAMES=( "Google Chrome.app" "Google Chrome Beta.app"
"Google Chrome Dev.app" "Google Chrome Canary.app" )
readonly FRAMEWORK_NAME="Google Chrome Framework"
readonly FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework"
readonly PATCH_DIR=".patch"
readonly CONTENTS_DIR="Contents"
......@@ -617,6 +616,7 @@ main() {
readonly KS_PRODUCT_KEY="KSProductID"
readonly KS_URL_KEY="KSUpdateURL"
readonly KS_BRAND_KEY="KSBrandID"
readonly USER_DATA_DIR_PATH_KEY="CrProductDirName"
readonly QUARANTINE_ATTR="com.apple.quarantine"
......@@ -705,7 +705,22 @@ main() {
local update_version_app update_version_ks product_id update_layout_new
if [[ -z "${is_patch}" ]]; then
update_app="${update_dmg_mount_point}/${APP_DIR}"
local found_app
for app_dir_name in "${APP_DIR_NAMES[@]}"; do
note "looking for ${app_dir_name}"
update_app="${update_dmg_mount_point}/${app_dir_name}"
if [[ -d "${update_app}" ]]; then
note "found ${app_dir_name}"
found_app="y"
break
fi
done
if [[ -z "${found_app}" ]]; then
err "couldn't locate any app on the update dmg"
exit 2
fi
note "update_app = ${update_app}"
# Make sure that it's an absolute path.
......@@ -714,22 +729,6 @@ main() {
exit 2
fi
# Make sure there's something to copy from.
if ! [[ -d "${update_app}" ]]; then
update_app="${update_dmg_mount_point}/${ALTERNATE_APP_DIR}"
note "update_app = ${update_app}"
if [[ "${update_app:0:1}" != "/" ]]; then
err "update_app (alternate) must be an absolute path"
exit 2
fi
if ! [[ -d "${update_app}" ]]; then
err "update_app must be a directory"
exit 2
fi
fi
# Get some information about the update.
note "reading update values"
......@@ -1120,8 +1119,12 @@ framework_${update_version_app_old}_${update_version_app}.dirpatch"
# exists, and ${installed_app} needs to be used as input to dirpatcher
# in any event. The new application will be rsynced into place once
# dirpatcher creates it.
ensure_temp_dir
update_app="${g_temp_dir}/${APP_DIR}"
# The name of the app for ${update_app} does not matter, as the user's
# choice of name for their installed app will not be changed. Choose the
# first of the ${APP_DIR_NAMES} as an arbitrary choice.
update_app="${g_temp_dir}/${APP_DIR_NAMES[0]}"
note "update_app = ${update_app}"
note "dirpatching app directory"
......@@ -1249,6 +1252,13 @@ framework_${update_version_app_old}_${update_version_app}.dirpatch"
note "tag = ${tag}"
note "tag_key = ${tag_key}"
# The user data dir path key is only present for some Chromes. Suppress
# stderr to prevent Keystone from seeing possible error output.
local is_sxs_capable
is_sxs_capable="$(infoplist_read "${installed_app_plist}" \
"${USER_DATA_DIR_PATH_KEY}" 2> /dev/null || true)"
note "is_sxs_capable = ${is_sxs_capable}"
# Make sure that the update was successful by comparing the version found in
# the update with the version now on disk.
if [[ "${new_version_ks}" != "${update_version_ks}" ]]; then
......@@ -1291,19 +1301,19 @@ framework_${update_version_app_old}_${update_version_app}.dirpatch"
local ksadmin_brand_plist_path
local ksadmin_brand_key
# Only the stable channel, identified by an empty channel string, has a
# brand code. On the beta and dev channels, remove the brand plist if
# present. Its presence means that the ticket used to manage a
# stable-channel Chrome but the user has since replaced it with a beta or
# dev channel version. Since the canary channel can run side-by-side with
# another Chrome installation, don't remove the brand plist on that channel,
# but skip the rest of the brand logic.
if [[ "${channel}" = "beta" ]] || [[ "${channel}" = "dev" ]]; then
# Only side-by-side capable channels, either the stable channel (identified by
# an empty channel string) or a Chrome that has a custom user data dir, has a
# brand code. On non-side-by-side beta and dev channels, remove the brand
# plist if present. Its presence means that the ticket used to manage a
# stable-channel Chrome but the user has since replaced it with a beta or dev
# channel version. With side-by-side channels, don't remove the brand plist on
# that channel, but skip the rest of the brand logic.
if [[ -n "${is_sxs_capable}" ]]; then
# Side-by-side capable Chrome.
note "skipping brand code on side-by-side channel ${channel}"
elif [[ "${channel}" = "beta" ]] || [[ "${channel}" = "dev" ]]; then
note "defeating brand code on channel ${channel}"
rm -f "${brand_plist_path}" 2>/dev/null || true
elif [[ -n "${channel}" ]]; then
# Canary channel.
note "skipping brand code on channel ${channel}"
else
# Stable channel.
# If the user manually updated their copy of Chrome, there might be new
......
......@@ -18,9 +18,9 @@ if [ ! -f "${INSTALLER}" ]; then
fi
# What I test
PRODNAME="Google Chrome"
APPNAME="${PRODNAME}.app"
FWKNAME="${PRODNAME} Framework.framework"
APPNAME_STABLE="Google Chrome.app"
APPNAME_CANARY="Google Chrome Canary.app"
FWKNAME="Google Chrome Framework.framework"
# The version number for fake ksadmin to pretend to be
KSADMIN_VERSION_LIE="1.0.7.1306"
......@@ -38,16 +38,21 @@ function cleanup_tempdir() {
# Run the installer and make sure it fails.
# If it succeeds, we fail.
# Arg0: string to print
# Arg1: expected error code
function fail_installer() {
echo $1
"${INSTALLER}" "${TEMPDIR}" >& /dev/null
RETURN=$?
if [ $RETURN -eq 0 ]; then
echo "Did not fail (which is a failure)" >& 2
echo " Did not fail (which is a failure)" >& 2
cleanup_tempdir
exit 1
elif [[ $RETURN -ne $2 ]]; then
echo " Failed with unexpected return code ${RETURN} rather than $2" >& 2
cleanup_tempdir
exit 1
else
echo "Returns $RETURN"
echo " Successfully failed with return code ${RETURN}"
fi
}
......@@ -58,11 +63,11 @@ function pass_installer() {
"${INSTALLER}" "${TEMPDIR}" >& /dev/null
RETURN=$?
if [ $RETURN -ne 0 ]; then
echo "FAILED; returned $RETURN but should have worked" >& 2
echo " FAILED; returned $RETURN but should have worked" >& 2
cleanup_tempdir
exit 1
else
echo "worked"
echo " Succeeded"
fi
}
......@@ -113,49 +118,62 @@ EOF
}
# Make a simple source directory - the update that is to be applied
# Arg0: the name of the application directory
function make_src() {
local appname="${1}"
chmod ugo+w "${TEMPDIR}"
rm -rf "${TEMPDIR}/${APPNAME}"
RSRCDIR="${TEMPDIR}/${APPNAME}/Contents/Versions/1/${FWKNAME}/Resources"
rm -rf "${TEMPDIR}/${APPNAME_STABLE}"
rm -rf "${TEMPDIR}/${APPNAME_CANARY}"
RSRCDIR="${TEMPDIR}/${appname}/Contents/Versions/1/${FWKNAME}/Resources"
mkdir -p "${RSRCDIR}"
defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" \
defaults write "${TEMPDIR}/${appname}/Contents/Info" \
CFBundleShortVersionString "1"
defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" \
defaults write "${TEMPDIR}/${appname}/Contents/Info" \
KSProductID "com.google.Chrome"
defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" \
defaults write "${TEMPDIR}/${appname}/Contents/Info" \
KSVersion "2"
}
function make_basic_src_and_dest() {
make_src
make_src "${APPNAME_STABLE}"
make_new_dest
}
fail_installer "No source anything"
fail_installer "No source anything" 2
mkdir "${TEMPDIR}"/"${APPNAME}"
fail_installer "No source bundle"
mkdir "${TEMPDIR}"/"${APPNAME_STABLE}"
fail_installer "No source bundle" 2
make_basic_src_and_dest
chmod ugo-w "${TEMPDIR}"
fail_installer "Writable dest directory"
fail_installer "Writable dest directory" 9
make_basic_src_and_dest
fail_installer "Was no KSUpdateURL in dest after copy"
fail_installer "Was no KSUpdateURL in dest after copy" 9
make_basic_src_and_dest
defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL "http://foobar"
defaults write "${TEMPDIR}/${APPNAME_STABLE}/Contents/Info" \
KSUpdateURL "http://foobar"
export FAKE_SYSTEM_TICKET=1
fail_installer "User and system ticket both present"
fail_installer "User and system ticket both present" 4
export -n FAKE_SYSTEM_TICKET
make_src
make_src "${APPNAME_STABLE}"
make_old_dest
defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL "http://foobar"
defaults write "${TEMPDIR}/${APPNAME_STABLE}/Contents/Info" \
KSUpdateURL "http://foobar"
pass_installer "Old-style update"
make_basic_src_and_dest
defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL "http://foobar"
pass_installer "ALL"
defaults write "${TEMPDIR}/${APPNAME_STABLE}/Contents/Info" \
KSUpdateURL "http://foobar"
pass_installer "New-style Stable"
make_src "${APPNAME_CANARY}"
make_new_dest
defaults write "${TEMPDIR}/${APPNAME_CANARY}/Contents/Info" \
KSUpdateURL "http://foobar"
pass_installer "New-style Canary"
cleanup_tempdir
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment