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