Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / installer / mac / make_signers.sh
blob57d762821c6dabb0487f07162ead335963b7597c
1 #!/bin/bash -p
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 # This script creates sign_app.sh and sign_versioned_dir.sh, the scripts that
8 # will be used to sign the application bundle and inner bundles. It also
9 # creates auxiliary files that these scripts need to do their jobs, such as
10 # the custom resource rules used to sign the outermost application bundle.
11 # The build places these in the "${mac_product_name} Packaging" directory next
12 # to the .app bundle. The packaging system is expected to run these scripts to
13 # sign everything.
15 set -eu
17 # Environment sanitization. Set a known-safe PATH. Clear environment variables
18 # that might impact the interpreter's operation. The |bash -p| invocation
19 # on the #! line takes the bite out of BASH_ENV, ENV, and SHELLOPTS (among
20 # other features), but clearing them here ensures that they won't impact any
21 # shell scripts used as utility programs. SHELLOPTS is read-only and can't be
22 # unset, only unexported.
23 export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
24 unset BASH_ENV CDPATH ENV GLOBIGNORE IFS POSIXLY_CORRECT
25 export -n SHELLOPTS
27 ME="$(basename "${0}")"
28 readonly ME
30 if [[ ${#} -ne 3 ]]; then
31 echo "usage: ${ME} packaging_dir mac_product_name version" >& 2
32 exit 1
35 packaging_dir="${1}"
36 mac_product_name="${2}"
37 version="${3}"
39 script_dir="$(dirname "${0}")"
40 in_files=(
41 "${script_dir}/sign_app.sh.in"
42 "${script_dir}/sign_versioned_dir.sh.in"
43 "${script_dir}/app_resource_rules.plist.in"
46 # Double-backslash each dot: one backslash belongs in the regular expression,
47 # and the other backslash tells sed not to treat the first backslash
48 # specially.
49 version_regex="$(echo "${version}" | sed -e 's/\./\\\\./g')"
51 mkdir -p "${packaging_dir}"
53 for in_file in "${in_files[@]}"; do
54 out_file="${packaging_dir}/$(basename "${in_file:0:${#in_file} - 3}")"
55 sed -e "s/@MAC_PRODUCT_NAME@/${mac_product_name}/g" \
56 -e "s/@VERSION@/${version}/g" \
57 -e "s/@VERSION_REGEX@/${version_regex}/g" \
58 < "${in_file}" \
59 > "${out_file}"
61 if [[ "${out_file: -3}" = ".sh" ]]; then
62 chmod +x "${out_file}"
64 done