| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 2 | |
| 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. | |
| 6 | |
| 7 set -e | |
| 8 | |
| 9 # Pull off the optional args | |
| 10 USE_BREAKPAD=0 | |
| 11 USE_KEYSTONE=0 | |
| 12 USE_SVN=1 | |
| 13 OPTERR=0 | |
| 14 while getopts ":b:k:s:" an_opt ; do | |
| 15 case $an_opt in | |
| 16 b) | |
| 17 USE_BREAKPAD=$OPTARG | |
| 18 ;; | |
| 19 k) | |
| 20 USE_KEYSTONE=$OPTARG | |
| 21 ;; | |
| 22 s) | |
| 23 USE_SVN=$OPTARG | |
| 24 ;; | |
| 25 \?) | |
| 26 echo "Unknown option $OPTARG" | |
| 27 exit 1 | |
| 28 ;; | |
| 29 :) | |
| 30 echo "Option $OPTARG missing it's value" | |
| 31 exit 1 | |
| 32 ;; | |
| 33 *) | |
| 34 echo "Not recognized argument $an_opt" | |
| 35 exit 1 | |
| 36 ;; | |
| 37 esac | |
| 38 done | |
| 39 shift $(($OPTIND - 1)) | |
| 40 | |
| 41 # Make sure the branding argument was supplied. | |
| 42 if [ $# -ne 1 ]; then | |
| 43 echo "error: missing branding as an argument" >&2 | |
| 44 exit 1 | |
| 45 fi | |
| 46 | |
| 47 # | |
| 48 # Xcode supports build variable substitutions and CPP; sadly, that doesn't work | |
| 49 # because: | |
| 50 # | |
| 51 # 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 | |
| 53 # 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 | |
| 55 # 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. | |
| 57 # | |
| 58 # 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 | |
| 60 # by the time the app target is done, the info.plist is correct. | |
| 61 # | |
| 62 | |
| 63 TOP="${SRCROOT}/.." | |
| 64 BUILD_BRANDING=$1 | |
| 65 | |
| 66 set -x | |
| 67 | |
| 68 if [ "${USE_SVN}" = "1" ] ; then | |
| 69 # Visible in the about:version page. | |
| 70 SVN_INFO=$(svn info "${TOP}" 2>/dev/null || true) | |
| 71 SVN_REVISION=$(echo "${SVN_INFO}" | sed -Ene 's/^Revision: (.*)$/\1/p') | |
| 72 if [ -z "${SVN_REVISION}" ] ; then | |
| 73 GIT_INFO=$(git log -1 --grep=git-svn-id --format=%b 2>/dev/null || true) | |
| 74 SVN_REVISION=$(echo "${GIT_INFO}" | \ | |
| 75 sed -Ene 's/^git-svn-id: .*@([0-9]+).*$/\1/p') | |
| 76 # Finding the revision for git and svn has failed. | |
| 77 if [ -z "${SVN_REVISION}" ] ; then | |
| 78 echo "Could not determine svn revision. This may be OK." >&2 | |
| 79 else | |
| 80 SVN_PATH=$(echo "${GIT_INFO}" | \ | |
| 81 sed -Ene 's%^git-svn-id: .*/chrome/(.*)@.*$%/\1%p') | |
| 82 fi | |
| 83 else | |
| 84 # Grab the path to the source root in the Subversion repository by taking | |
| 85 # the URL to the source root directory and the repository root, and | |
| 86 # removing the latter from the former. This ensures that SVN_PATH will | |
| 87 # contain a useful path regardless of the Subversion server, mirror, and | |
| 88 # authentication scheme in use. | |
| 89 SVN_URL=$(echo "${SVN_INFO}" | sed -Ene 's/^URL: (.*)$/\1/p') | |
| 90 SVN_ROOT=$(echo "${SVN_INFO}" | sed -Ene 's/^Repository Root: (.*)$/\1/p') | |
| 91 if [ -n "${SVN_ROOT}" ] && \ | |
| 92 [ "${SVN_URL:0:${#SVN_ROOT}}" = "${SVN_ROOT}" ] ; then | |
| 93 SVN_PATH="${SVN_URL:${#SVN_ROOT}}" | |
| 94 fi | |
| 95 fi | |
| 96 fi | |
| 97 | |
| 98 # Pull in the Chrome version number. | |
| 99 . "${TOP}/chrome/VERSION" | |
| 100 FULL_VERSION="${MAJOR}.${MINOR}.${BUILD}.${PATCH}" | |
| 101 | |
| 102 # I really hate how "defaults" doesn't take a real pathname but instead insists | |
| 103 # on appending ".plist" to everything. | |
| 104 TMP_INFO_PLIST_DEFAULTS="${TEMP_DIR}/Info" | |
| 105 TMP_INFO_PLIST="${TMP_INFO_PLIST_DEFAULTS}.plist" | |
| 106 cp "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" "${TMP_INFO_PLIST}" | |
| 107 | |
| 108 # Save off the Subversion revision number and source root path in case they're | |
| 109 # needed. | |
| 110 if [ ! -z "${SVN_REVISION}" ] ; then | |
| 111 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 112 SVNRevision -string "${SVN_REVISION}" | |
| 113 else | |
| 114 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" SVNRevision || true | |
| 115 fi | |
| 116 if [ ! -z "${SVN_PATH}" ] ; then | |
| 117 defaults write "${TMP_INFO_PLIST_DEFAULTS}" SVNPath -string "${SVN_PATH}" | |
| 118 else | |
| 119 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" SVNPath || true | |
| 120 fi | |
| 121 | |
| 122 # Add public version info so "Get Info" works | |
| 123 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 124 CFBundleShortVersionString -string "${FULL_VERSION}" | |
| 125 # Honor the 429496.72.95 limit. The maximum comes from splitting 2^32 - 1 into | |
| 126 # 6, 2, 2 digits. The limitation was present in Tiger, but it could have been | |
| 127 # fixed in later OS release, but hasn't been tested (it's easy enough to find | |
| 128 # out with "lsregister -dump). | |
| 129 # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html | |
| 130 # BUILD will always be an increasing value, so BUILD_PATH gives us something | |
| 131 # unique that meetings what LS wants. | |
| 132 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 133 CFBundleVersion -string "${BUILD}.${PATCH}" | |
| 134 | |
| 135 # Add or remove the Breakpad keys. | |
| 136 if [ "${USE_BREAKPAD}" = "1" ] ; then | |
| 137 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 138 BreakpadURL "https://clients2.google.com/cr/report" | |
| 139 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadReportInterval "3600" | |
| 140 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 141 BreakpadProduct "${BUILD_BRANDING}_Mac" | |
| 142 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 143 BreakpadProductDisplay "${BUILD_BRANDING}" | |
| 144 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 145 BreakpadVersion -string "${FULL_VERSION}" | |
| 146 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSendAndExit "YES" | |
| 147 defaults write "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSkipConfirm "YES" | |
| 148 else | |
| 149 # Make sure the keys aren't there, || true to avoid errors if they aren't. | |
| 150 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadURL || true | |
| 151 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadReportInterval || true | |
| 152 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadProduct || true | |
| 153 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadProductDisplay || true | |
| 154 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadVersion || true | |
| 155 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSendAndExit || true | |
| 156 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" BreakpadSkipConfirm || true | |
| 157 fi | |
| 158 | |
| 159 # Add or remove the Keystone keys (only supported in release builds). | |
| 160 if [ "${USE_KEYSTONE}" = "1" ] && [ "${CONFIGURATION}" = "Release" ] ; then | |
| 161 KEYSTONE_URL="https://tools.google.com/service/update2" | |
| 162 KEYSTONE_APP_ID=$(defaults read "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 163 CFBundleIdentifier) | |
| 164 defaults write "${TMP_INFO_PLIST_DEFAULTS}" \ | |
| 165 KSVersion -string "${FULL_VERSION}" | |
| 166 defaults write "${TMP_INFO_PLIST_DEFAULTS}" KSProductID "${KEYSTONE_APP_ID}" | |
| 167 defaults write "${TMP_INFO_PLIST_DEFAULTS}" KSUpdateURL "${KEYSTONE_URL}" | |
| 168 else | |
| 169 # Make sure the keys aren't there, || true to avoid errors if they aren't. | |
| 170 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSVersion || true | |
| 171 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSProductID || true | |
| 172 defaults delete "${TMP_INFO_PLIST_DEFAULTS}" KSUpdateURL || true | |
| 173 fi | |
| 174 | |
| 175 # Info.plist will work perfectly well in any plist format, but traditionally | |
| 176 # applications use xml1 for this, so convert it back after whatever defaults | |
| 177 # might have done. | |
| 178 plutil -convert xml1 "${TMP_INFO_PLIST}" | |
| 179 cp "${TMP_INFO_PLIST}" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
| 180 | |
| 181 # Clean up. | |
| 182 rm -f "${TMP_INFO_PLIST}" | |
| OLD | NEW |