3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Test of the Mac Chrome installer.
13 # My installer to test
14 INSTALLER
="${DIR}"/keystone_install.sh
15 if [ ! -f "${INSTALLER}" ]; then
16 echo "Can't find scripts." >& 2
21 PRODNAME
="Google Chrome"
22 APPNAME
="${PRODNAME}.app"
23 FWKNAME
="${PRODNAME} Framework.framework"
25 # The version number for fake ksadmin to pretend to be
26 KSADMIN_VERSION_LIE
="1.0.7.1306"
28 # Temp directory to be used as the disk image (source)
29 TEMPDIR
=$
(mktemp
-d -t $
(basename ${0}))
30 PATH
=$PATH:"${TEMPDIR}"
32 # Clean up the temp directory
33 function cleanup_tempdir
() {
34 chmod u
+w
"${TEMPDIR}"
38 # Run the installer and make sure it fails.
39 # If it succeeds, we fail.
40 # Arg0: string to print
41 function fail_installer
() {
43 "${INSTALLER}" "${TEMPDIR}" >& /dev
/null
45 if [ $RETURN -eq 0 ]; then
46 echo "Did not fail (which is a failure)" >& 2
50 echo "Returns $RETURN"
54 # Make sure installer works!
55 # Arg0: string to print
56 function pass_installer
() {
58 "${INSTALLER}" "${TEMPDIR}" >& /dev
/null
60 if [ $RETURN -ne 0 ]; then
61 echo "FAILED; returned $RETURN but should have worked" >& 2
69 # Make an old-style destination directory, to test updating from old-style
70 # versions to new-style versions.
71 function make_old_dest
() {
72 DEST
="${TEMPDIR}"/Dest.app
74 mkdir
-p "${DEST}"/Contents
75 defaults
write "${DEST}/Contents/Info" KSVersion
0
76 cat >"${TEMPDIR}"/ksadmin
<<EOF
78 if [ "\${1}" = "--ksadmin-version" ] ; then
79 echo "${KSADMIN_VERSION_LIE}"
82 if [ -z "\${FAKE_SYSTEM_TICKET}" ] && [ "\${1}" = "-S" ] ; then
83 echo no system tix! >& 2
86 echo " xc=<KSPathExistenceChecker:0x45 path=${DEST}>"
89 chmod u
+x
"${TEMPDIR}"/ksadmin
92 # Make a new-style destination directory, to test updating between new-style
94 function make_new_dest
() {
95 DEST
="${TEMPDIR}"/Dest.app
97 defaults
write "${DEST}/Contents/Info" CFBundleShortVersionString
0
98 defaults
write "${DEST}/Contents/Info" KSVersion
0
99 cat >"${TEMPDIR}"/ksadmin
<<EOF
101 if [ "\${1}" = "--ksadmin-version" ] ; then
102 echo "${KSADMIN_VERSION_LIE}"
105 if [ -z "\${FAKE_SYSTEM_TICKET}" ] && [ "\${1}" = "-S" ] ; then
106 echo no system tix! >& 2
109 echo " xc=<KSPathExistenceChecker:0x45 path=${DEST}>"
112 chmod u
+x
"${TEMPDIR}"/ksadmin
115 # Make a simple source directory - the update that is to be applied
116 function make_src
() {
117 chmod ugo
+w
"${TEMPDIR}"
118 rm -rf "${TEMPDIR}/${APPNAME}"
119 RSRCDIR
="${TEMPDIR}/${APPNAME}/Contents/Versions/1/${FWKNAME}/Resources"
120 mkdir
-p "${RSRCDIR}"
121 defaults
write "${TEMPDIR}/${APPNAME}/Contents/Info" \
122 CFBundleShortVersionString
"1"
123 defaults
write "${TEMPDIR}/${APPNAME}/Contents/Info" \
124 KSProductID
"com.google.Chrome"
125 defaults
write "${TEMPDIR}/${APPNAME}/Contents/Info" \
129 function make_basic_src_and_dest
() {
134 fail_installer
"No source anything"
136 mkdir
"${TEMPDIR}"/"${APPNAME}"
137 fail_installer
"No source bundle"
139 make_basic_src_and_dest
140 chmod ugo-w
"${TEMPDIR}"
141 fail_installer
"Writable dest directory"
143 make_basic_src_and_dest
144 fail_installer
"Was no KSUpdateURL in dest after copy"
146 make_basic_src_and_dest
147 defaults
write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL
"http://foobar"
148 export FAKE_SYSTEM_TICKET
=1
149 fail_installer
"User and system ticket both present"
150 export -n FAKE_SYSTEM_TICKET
154 defaults
write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL
"http://foobar"
155 pass_installer
"Old-style update"
157 make_basic_src_and_dest
158 defaults
write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL
"http://foobar"