aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/cros_pkg/switch_to_good.sh
blob: a9095e995fbdaee53714d50493e018319654b110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash -u
#
# Copyright 2015 Google Inc. All Rights Reserved.
#
# This script is intended to be used by binary_search_state.py, as
# part of the binary search triage on ChromeOS packages.  This script
# copies a list of packages from the 'good' build tree into the working
# build tree, for testing.
#

source common/common.sh

pushd ${WORK_BUILD}

PKG_LIST_FILE=$1

overall_status=0

if [[ -f ${PKG_LIST_FILE} ]] ; then

  # Read every line, and handle case where last line has no newline
  while read pkg || [[ -n "$pkg" ]];
  do
    sudo cp ${GOOD_BUILD}/packages/$pkg ${WORK_BUILD}/packages/$pkg
    status=$?
    if [[ ${status} -ne 0 ]] ; then
      echo "Failed to copy ${pkg} to work build tree."
      overall_status=2
    fi
  done < ${PKG_LIST_FILE}
else

  for o in "$@"
  do
    sudo cp ${GOOD_BUILD}/packages/$o  ${WORK_BUILD}/packages/$o
    status=$?
    if [[ ${status} -ne 0 ]] ; then
      echo "Failed to copy ${pkg} to work build tree."
      overall_status=2
    fi
  done
fi

popd

exit ${overall_status}