xref: /aosp_15_r20/external/toolchain-utils/binary_search_tool/sysroot_wrapper/setup.sh (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1#!/bin/bash -u
2#
3# Copyright 2021 The ChromiumOS Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7# This script is part of the ChromeOS object binary search triage process.
8# It should be the first script called by the user, after the user has set up
9# the two necessary build tree directories (see sysroot_wrapper/README).
10#
11# This script requires three arguments.  The first argument must be the name of
12# the board for which this work is being done (e.g. 'daisy', 'lumpy','parrot',
13# etc.).  The second argument must be the name or IP address of the chromebook
14# on which the ChromeOS images will be pushed and tested. The third argument
15# must be the name of the package being bisected (e.g. 'chromeos-chrome',
16# 'cryptohome', etc.).
17#
18# This script generates common/common.sh, which generates enviroment variables
19# used by the other scripts in the object file binary search triage process.
20#
21
22# Set up basic variables.
23bisect_dir=${BISECT_DIR:-/tmp/sysroot_bisect}
24
25BOARD=$1
26REMOTE=$2
27PACKAGE=$3
28REBOOT_OPTION=$4
29USE_FLAGS=$5
30
31GOOD_BUILD=${bisect_dir}/good
32BAD_BUILD=${bisect_dir}/bad
33GOOD_LIST=${GOOD_BUILD}/_LIST
34BAD_LIST=${BAD_BUILD}/_LIST
35
36#
37# Verify that the necessary directories exist.
38#
39
40if [[ ! -d ${GOOD_BUILD} ]] ; then
41    echo "Error:  ${GOOD_BUILD} does not exist."
42    exit 1
43fi
44
45if [[ ! -d ${BAD_BUILD} ]] ; then
46    echo "Error:  ${BAD_BUILD} does not exist."
47    exit 1
48fi
49
50if [[ ! -e ${GOOD_LIST} ]] ; then
51    echo "Error:  ${GOOD_LIST} does not exist."
52    exit 1
53fi
54
55if [[ ! -e ${BAD_LIST} ]] ; then
56    echo "Error: ${BAD_LIST} does not exist."
57    exit 1
58fi
59
60COMMON_FILE="common/common.sh"
61
62cat <<-EOF > ${COMMON_FILE}
63
64BISECT_BOARD=${BOARD}
65BISECT_REMOTE=${REMOTE}
66BISECT_PACKAGE=${PACKAGE}
67BISECT_REBOOT_OPTION=${REBOOT_OPTION}
68BISECT_USE_FLAGS="${USE_FLAGS}"
69BISECT_MODE="OBJECT_MODE"
70
71bisect_dir=${bisect_dir}
72
73export BISECT_STAGE=TRIAGE
74
75EOF
76
77chmod 755 ${COMMON_FILE}
78
79exit 0
80