Change type of kSUIDSandboxApiNumber to int
[chromium-blink-merge.git] / build / update-linux-sandbox.sh
blobfa2d1077af61bd525d69f9fe632da2fc87d45ade
1 #!/bin/sh
3 # Copyright (c) 2012 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 BUILDTYPE="${BUILDTYPE:-Debug}"
8 CHROME_SRC_DIR="${CHROME_SRC_DIR:-$(dirname -- $(readlink -fn -- "$0"))/..}"
9 CHROME_OUT_DIR="${CHROME_SRC_DIR}/${CHROMIUM_OUT_DIR:-out}/${BUILDTYPE}"
10 CHROME_SANDBOX_BUILD_PATH="${CHROME_OUT_DIR}/chrome_sandbox"
11 CHROME_SANDBOX_INST_PATH="/usr/local/sbin/chrome-devel-sandbox"
12 CHROME_SANDBOX_INST_DIR=$(dirname -- "$CHROME_SANDBOX_INST_PATH")
14 TARGET_DIR_TYPE=$(stat -f -c %t -- "${CHROME_SANDBOX_INST_DIR}" 2>/dev/null)
15 if [ $? -ne 0 ]; then
16 echo "Could not get status of ${CHROME_SANDBOX_INST_DIR}"
17 exit 1
20 # Make sure the path is not on NFS.
21 if [ "${TARGET_DIR_TYPE}" = "6969" ]; then
22 echo "Please make sure ${CHROME_SANDBOX_INST_PATH} is not on NFS!"
23 exit 1
26 installsandbox() {
27 echo "(using sudo so you may be asked for your password)"
28 sudo -- cp "${CHROME_SANDBOX_BUILD_PATH}" \
29 "${CHROME_SANDBOX_INST_PATH}" &&
30 sudo -- chown root:root "${CHROME_SANDBOX_INST_PATH}" &&
31 sudo -- chmod 4755 "${CHROME_SANDBOX_INST_PATH}"
32 return $?
35 if [ ! -d "${CHROME_OUT_DIR}" ]; then
36 echo -n "${CHROME_OUT_DIR} does not exist. Use \"BUILDTYPE=Release ${0}\" "
37 echo "If you are building in Release mode"
38 exit 1
41 if [ ! -f "${CHROME_SANDBOX_BUILD_PATH}" ]; then
42 echo "Could not find ${CHROME_SANDBOX_BUILD_PATH}"
43 echo -n "BUILDTYPE is $BUILDTYPE, use \"BUILDTYPE=<value> ${0}\" to override "
44 echo "after you build the chrome_sandbox target"
45 exit 1
48 if [ ! -f "${CHROME_SANDBOX_INST_PATH}" ]; then
49 echo -n "Could not find ${CHROME_SANDBOX_INST_PATH}, "
50 echo "installing it now."
51 installsandbox
54 if [ ! -f "${CHROME_SANDBOX_INST_PATH}" ]; then
55 echo "Failed to install ${CHROME_SANDBOX_INST_PATH}"
56 exit 1
59 CURRENT_API=$("${CHROME_SANDBOX_BUILD_PATH}" --get-api)
60 INSTALLED_API=$("${CHROME_SANDBOX_INST_PATH}" --get-api)
62 if [ "${CURRENT_API}" != "${INSTALLED_API}" ]; then
63 echo "Your installed setuid sandbox is too old, installing it now."
64 if ! installsandbox; then
65 echo "Failed to install ${CHROME_SANDBOX_INST_PATH}"
66 exit 1
68 else
69 echo "Your setuid sandbox is up to date"
70 if [ "${CHROME_DEVEL_SANDBOX}" != "${CHROME_SANDBOX_INST_PATH}" ]; then
71 echo -n "Make sure you have \"export "
72 echo -n "CHROME_DEVEL_SANDBOX=${CHROME_SANDBOX_INST_PATH}\" "
73 echo "somewhere in your .bashrc"
74 echo "This variable is currently: ${CHROME_DEVEL_SANDBOX:-empty}"