Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: build/mac/tweak_app_infoplist

Issue 164303: Re-commit r22981 after backout at r22992 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/mac/dump_app_syms ('k') | chrome/app/app-Info.plist » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 set -e 7 set -e
8 8
9 # Pull off the optional args 9 # Pull off the optional args
10 USE_BREAKPAD=0 10 USE_BREAKPAD=0
11 USE_KEYSTONE=0 11 USE_KEYSTONE=0
12 USE_SVN=1
12 OPTERR=0 13 OPTERR=0
13 while getopts ":b:k:" an_opt ; do 14 while getopts ":b:k:s:" an_opt ; do
14 case $an_opt in 15 case $an_opt in
15 b) 16 b)
16 USE_BREAKPAD=$OPTARG 17 USE_BREAKPAD=$OPTARG
17 ;; 18 ;;
18 k) 19 k)
19 USE_KEYSTONE=$OPTARG 20 USE_KEYSTONE=$OPTARG
20 ;; 21 ;;
22 s)
23 USE_SVN=$OPTARG
24 ;;
21 \?) 25 \?)
22 echo "Unknown option $OPTARG" 26 echo "Unknown option $OPTARG"
23 exit 1 27 exit 1
24 ;; 28 ;;
25 :) 29 :)
26 echo "Option $OPTARG missing it's value" 30 echo "Option $OPTARG missing it's value"
27 exit 1 31 exit 1
28 ;; 32 ;;
29 *) 33 *)
30 echo "Not recognized argument $an_opt" 34 echo "Not recognized argument $an_opt"
31 exit 1 35 exit 1
32 ;; 36 ;;
33 esac 37 esac
34 done 38 done
35 shift $(($OPTIND - 1)) 39 shift $(($OPTIND - 1))
36 40
37 # Make sure we got the header to write into passed to us 41 # Make sure the branding argument was supplied.
38 if [ $# -ne 1 ]; then 42 if [ $# -ne 1 ]; then
39 echo "error: missing branding as an argument" >&2 43 echo "error: missing branding as an argument" >&2
40 exit 1 44 exit 1
41 fi 45 fi
42 46
43 # 47 #
44 # Xcode supports build variable substitutions and CPP; sadly, that doesn't work 48 # Xcode supports build variable substitutions and CPP; sadly, that doesn't work
45 # because: 49 # because:
46 # 50 #
47 # 1. Xcode wants to do the Info.plist work before it runs any build phases, 51 # 1. Xcode wants to do the Info.plist work before it runs any build phases,
48 # this means if we were to generate a .h file for INFOPLIST_PREFIX_HEADER 52 # this means if we were to generate a .h file for INFOPLIST_PREFIX_HEADER
49 # we'd have to put it in another target so it runs in time. 53 # we'd have to put it in another target so it runs in time.
50 # 2. Xcode also doesn't check to see if the header being used as a prefix for 54 # 2. Xcode also doesn't check to see if the header being used as a prefix for
51 # the Info.plist has changed. So even if we updated it, it's only looking 55 # the Info.plist has changed. So even if we updated it, it's only looking
52 # at the modtime of the info.plist to see if that's changed. 56 # at the modtime of the info.plist to see if that's changed.
53 # 57 #
54 # So, we work around all of this by making a script build phase that will run 58 # So, we work around all of this by making a script build phase that will run
55 # during the app build, and simply update the info.plist in place. This way 59 # during the app build, and simply update the info.plist in place. This way
56 # by the time the app target is done, the info.plist is correct. 60 # by the time the app target is done, the info.plist is correct.
57 # 61 #
58 62
59 TOP="${SRCROOT}/.." 63 TOP="${SRCROOT}/.."
60 BUILD_BRANDING=$1 64 BUILD_BRANDING=$1
61 BRAND_SCRIPT="${TOP}/build/branding_value.sh" 65 BRAND_SCRIPT="${TOP}/build/branding_value.sh"
62 66
63 set -x 67 set -x
64 68
65 APP_NAME=$("${BRAND_SCRIPT}" "${BUILD_BRANDING}" PRODUCT_FULLNAME) 69 APP_NAME=$("${BRAND_SCRIPT}" "${BUILD_BRANDING}" PRODUCT_FULLNAME)
66 SRC_APP_PATH="${BUILT_PRODUCTS_DIR}/${APP_NAME}.app" 70 SRC_APP_PATH="${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}"
67 71
68 # Visible in the about:version page. 72 if [ "${USE_SVN}" = "1" ] ; then
69 SVN_REVISION=$(svn info "${SRCROOT}" | grep "Revision:" | cut -d" " -f2-) 73 # Visible in the about:version page.
70 if [ -z "${SVN_REVISION}" ] ; then 74 SVN_INFO=$(svn info "${TOP}")
71 echo "Could not determine svn revision. This may be OK." >&2 75 SVN_REVISION=$(echo "${SVN_INFO}" | sed -Ene 's/^Revision: (.*)$/\1/p')
72 # TODO: check for git, and get the version number from it? 76 if [ -z "${SVN_REVISION}" ] ; then
77 echo "Could not determine svn revision. This may be OK." >&2
78 # TODO: check for git, and get the version number from it?
79 fi
80
81 # Grab the path to the source root in the Subversion repository by taking the
82 # URL to the source root directory and the repository root, and removing the
83 # latter from the former. This ensures that SVN_PATH will contain a useful
84 # path regardless of the Subversion server, mirror, and authentication scheme
85 # in use.
86 SVN_URL=$(echo "${SVN_INFO}" | sed -Ene 's/^URL: (.*)$/\1/p')
87 SVN_ROOT=$(echo "${SVN_INFO}" | sed -Ene 's/^Repository Root: (.*)$/\1/p')
88 if [ -n "${SVN_ROOT}" ] && \
89 [ "${SVN_URL:0:${#SVN_ROOT}}" = "${SVN_ROOT}" ] ; then
90 SVN_PATH="${SVN_URL:${#SVN_ROOT}}"
91 fi
73 fi 92 fi
74 93
75 # Pull in the chrome version number 94 # Pull in the Chrome version number.
76 . "${TOP}/chrome/VERSION" 95 . "${TOP}/chrome/VERSION"
77 FULL_VERSION="${MAJOR}.${MINOR}.${BUILD}.${PATCH}" 96 FULL_VERSION="${MAJOR}.${MINOR}.${BUILD}.${PATCH}"
78 SHORT_VERSION="${MAJOR}.${MINOR}.${BUILD}"
79 97
80 # Fetch the copyright 98 # Fetch the copyright.
81 COPYRIGHT_STRING=$("${BRAND_SCRIPT}" "${BUILD_BRANDING}" COPYRIGHT) 99 COPYRIGHT_STRING=$("${BRAND_SCRIPT}" "${BUILD_BRANDING}" COPYRIGHT)
82 # Map (c) or (C) to the copyright sign 100 # Map (c) or (C) to the copyright symbol.
83 COPYRIGHT_STRING=$(echo "${COPYRIGHT_STRING}" | sed -e $'s/([cC])/\302\251/g') 101 COPYRIGHT_STRING=$(echo "${COPYRIGHT_STRING}" | sed -e $'s/([cC])/\302\251/g')
84 102
85 # Build the full copyright string 103 # Build the full copyright string
86 LONG_COPYRIGHT="${APP_NAME} ${FULL_VERSION}, ${COPYRIGHT_STRING}" 104 LONG_COPYRIGHT="${APP_NAME} ${FULL_VERSION}, ${COPYRIGHT_STRING}"
87 105
88 # I really hate how "defaults" doesn't take a real pathname but instead insists 106 # I really hate how "defaults" doesn't take a real pathname but instead insists
89 # on appending ".plist" to everything. 107 # on appending ".plist" to everything.
90 INFO_PLIST_PATH="Contents/Info.plist" 108 INFO_PLIST_PATH="Contents/Info.plist"
91 TMP_INFO_PLIST_DEFAULTS="${TEMP_DIR}/Info" 109 TMP_INFO_PLIST_DEFAULTS="${TEMP_DIR}/Info"
92 TMP_INFO_PLIST="${TMP_INFO_PLIST_DEFAULTS}.plist" 110 TMP_INFO_PLIST="${TMP_INFO_PLIST_DEFAULTS}.plist"
93 cp "${SRC_APP_PATH}/${INFO_PLIST_PATH}" "${TMP_INFO_PLIST}" 111 cp "${SRC_APP_PATH}/${INFO_PLIST_PATH}" "${TMP_INFO_PLIST}"
94 112
95 # Save off the svn version number in case we need it 113 # Save off the Subversion revision number and source root path in case they're
114 # needed.
96 if [ ! -z "${SVN_REVISION}" ] ; then 115 if [ ! -z "${SVN_REVISION}" ] ; then
97 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 116 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
98 SVNRevision -string "${SVN_REVISION}" 117 SVNRevision -string "${SVN_REVISION}"
118 else
119 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" SVNRevision || true
120 fi
121 if [ ! -z "${SVN_PATH}" ] ; then
122 defaults write "${TMP_INFO_PLIST_DEFAULTS}" SVNPath -string "${SVN_PATH}"
123 else
124 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" SVNPath || true
99 fi 125 fi
100 126
101 # Add public version info so "Get Info" works 127 # Add public version info so "Get Info" works
102 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 128 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
103 CFBundleGetInfoString -string "${LONG_COPYRIGHT}" 129 CFBundleGetInfoString -string "${LONG_COPYRIGHT}"
104 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 130 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
105 CFBundleShortVersionString -string "${SHORT_VERSION}" 131 CFBundleShortVersionString -string "${FULL_VERSION}"
106 # Honor the 429496.72.95 limit. The maximum comes from splitting 2^32 - 1 into 132 # Honor the 429496.72.95 limit. The maximum comes from splitting 2^32 - 1 into
107 # 6, 2, 2 digits. The limitation was present in Tiger, but it could have been 133 # 6, 2, 2 digits. The limitation was present in Tiger, but it could have been
108 # fixed in later OS release, but hasn't been tested (it's easy enough to find 134 # fixed in later OS release, but hasn't been tested (it's easy enough to find
109 # out with "lsregister -dump). 135 # out with "lsregister -dump).
110 # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html 136 # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html
111 # BUILD will always be an increasing value, so BUILD_PATH gives us something 137 # BUILD will always be an increasing value, so BUILD_PATH gives us something
112 # unique that meetings what LS wants. 138 # unique that meetings what LS wants.
113 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 139 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
114 CFBundleVersion -string "${BUILD}.${PATCH}" 140 CFBundleVersion -string "${BUILD}.${PATCH}"
115 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 141 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
116 NSHumanReadableCopyright -string "${COPYRIGHT_STRING}" 142 NSHumanReadableCopyright -string "${COPYRIGHT_STRING}"
117 143
118 # Add/Remove the breakpad keys 144 # Add or remove the Breakpad keys.
119 if [ "${USE_BREAKPAD}" = "1" ] ; then 145 if [ "${USE_BREAKPAD}" = "1" ] ; then
120 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 146 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
121 BreakpadURL "https://clients2.google.com/cr/report" 147 BreakpadURL "https://clients2.google.com/cr/report"
122 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadReportInterval "3600" 148 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadReportInterval "3600"
123 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 149 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
124 BreakpadProduct "${BUILD_BRANDING}_Mac" 150 BreakpadProduct "${BUILD_BRANDING}_Mac"
125 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 151 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
126 BreakpadProductDisplay "${BUILD_BRANDING}" 152 BreakpadProductDisplay "${BUILD_BRANDING}"
127 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 153 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
128 BreakpadVersion -string "${FULL_VERSION}" 154 BreakpadVersion -string "${FULL_VERSION}"
129 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSendAndExit "YES" 155 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSendAndExit "YES"
130 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSkipConfirm "YES" 156 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSkipConfirm "YES"
131 else 157 else
132 # Make sure the keys aren't there, || true to avoid errors if they aren't. 158 # Make sure the keys aren't there, || true to avoid errors if they aren't.
133 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadURL || true 159 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadURL || true
134 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadReportInterval || true 160 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadReportInterval || true
135 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadProduct || true 161 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadProduct || true
136 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadProductDisplay || true 162 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadProductDisplay || true
137 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadVersion || true 163 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadVersion || true
138 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSendAndExit || true 164 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSendAndExit || true
139 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSkipConfirm || true 165 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSkipConfirm || true
140 fi 166 fi
141 167
142 # Add/Remove keystone keys (only supported in release builds) 168 # Add or remove the Keystone keys (only supported in release builds).
143 if [ "${USE_KEYSTONE}" = "1" ] && [ "${CONFIGURATION}" = "Release" ] ; then 169 if [ "${USE_KEYSTONE}" = "1" ] && [ "${CONFIGURATION}" = "Release" ] ; then
144 KEYSTONE_URL="https://tools.google.com/service/update2" 170 KEYSTONE_URL="https://tools.google.com/service/update2"
145 KEYSTONE_APP_ID=$(defaults read "${TMP_INFO_PLIST_DEFAULTS}" \ 171 KEYSTONE_APP_ID=$(defaults read "${TMP_INFO_PLIST_DEFAULTS}" \
146 CFBundleIdentifier) 172 CFBundleIdentifier)
147 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ 173 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \
148 KSVersion -string "${FULL_VERSION}" 174 KSVersion -string "${FULL_VERSION}"
149 defaults write "${TMP_INFO_PLIST_DEFAULTS}" KSProductID "${KEYSTONE_APP_ID}" 175 defaults write "${TMP_INFO_PLIST_DEFAULTS}" KSProductID "${KEYSTONE_APP_ID}"
150 defaults write "${TMP_INFO_PLIST_DEFAULTS}" KSUpdateURL "${KEYSTONE_URL}" 176 defaults write "${TMP_INFO_PLIST_DEFAULTS}" KSUpdateURL "${KEYSTONE_URL}"
151 else 177 else
152 # Make sure the keys aren't there, || true to avoid errors if they aren't. 178 # Make sure the keys aren't there, || true to avoid errors if they aren't.
153 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSVersion || true 179 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSVersion || true
154 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSProductID || true 180 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSProductID || true
155 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSUpdateURL || true 181 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSUpdateURL || true
156 fi 182 fi
157 183
158 # Info.plist will work perfectly well in any plist format, but traditionally 184 # Info.plist will work perfectly well in any plist format, but traditionally
159 # applications use xml1 for this, so convert it back after whatever defaults 185 # applications use xml1 for this, so convert it back after whatever defaults
160 # might have done. 186 # might have done.
161 plutil -convert xml1 "${TMP_INFO_PLIST}" 187 plutil -convert xml1 "${TMP_INFO_PLIST}"
162 cp "${TMP_INFO_PLIST}" "${SRC_APP_PATH}/${INFO_PLIST_PATH}" 188 cp "${TMP_INFO_PLIST}" "${SRC_APP_PATH}/${INFO_PLIST_PATH}"
189
190 # Clean up.
191 rm -f "${TMP_INFO_PLIST}"
OLDNEW
« no previous file with comments | « build/mac/dump_app_syms ('k') | chrome/app/app-Info.plist » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698