| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to update a running device with an optionally built package out | 7 # Script to update a running device with an optionally built package out |
| 8 # of your build directory | 8 # of your build directory |
| 9 | 9 |
| 10 # Load common constants. This should be the first executable line. | 10 # --- BEGIN COMMON.SH BOILERPLATE --- |
| 11 # The path to common.sh should be relative to your script's location. | 11 # Load common CrOS utilities. Inside the chroot this file is installed in |
| 12 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 13 # location. |
| 14 find_common_sh() { |
| 15 local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..") |
| 16 local path |
| 12 | 17 |
| 13 script_root=$(dirname $0) | 18 SCRIPT_ROOT= |
| 14 if [ -f ${script_root}/../common.sh ] ; then | 19 for path in "${common_paths[@]}"; do |
| 15 script_root=${script_root}/.. | 20 if [ -r "${path}/common.sh" ]; then |
| 16 fi | 21 SCRIPT_ROOT=${path} |
| 22 break |
| 23 fi |
| 24 done |
| 25 } |
| 17 | 26 |
| 18 . "${script_root}/common.sh" | 27 find_common_sh |
| 19 . "${script_root}/remote_access.sh" | 28 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 29 # --- END COMMON.SH BOILERPLATE --- |
| 30 |
| 31 . "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh" |
| 20 | 32 |
| 21 get_default_board | 33 get_default_board |
| 22 | 34 |
| 23 DEFINE_boolean verbose ${FLAGS_FALSE} \ | 35 DEFINE_boolean verbose ${FLAGS_FALSE} \ |
| 24 "Whether to output verbose information for debugging." | 36 "Whether to output verbose information for debugging." |
| 25 DEFINE_boolean build ${FLAGS_FALSE} "Build package before installing" | 37 DEFINE_boolean build ${FLAGS_FALSE} "Build package before installing" |
| 26 DEFINE_string board "$DEFAULT_BOARD" \ | 38 DEFINE_string board "$DEFAULT_BOARD" \ |
| 27 "Board for which the package should be built/found" | 39 "Board for which the package should be built/found" |
| 28 DEFINE_string build_root "/build" \ | 40 DEFINE_string build_root "/build" \ |
| 29 "The root location for board sysroots." | 41 "The root location for board sysroots." |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 var_mount_noexec=yes | 94 var_mount_noexec=yes |
| 83 remote_sh "mount -o remount,exec /var" | 95 remote_sh "mount -o remount,exec /var" |
| 84 fi | 96 fi |
| 85 | 97 |
| 86 for pkg in $@; do | 98 for pkg in $@; do |
| 87 latest_pkg=$(ls -tr $PKGROOT/*/${pkg}-[0-9]* | tail -1) | 99 latest_pkg=$(ls -tr $PKGROOT/*/${pkg}-[0-9]* | tail -1) |
| 88 if [ -z "${latest_pkg}" ]; then | 100 if [ -z "${latest_pkg}" ]; then |
| 89 echo "Could not find latest built version of ${pkg}" | 101 echo "Could not find latest built version of ${pkg}" |
| 90 exit 1 | 102 exit 1 |
| 91 fi | 103 fi |
| 92 pkg_dir=$(basename $(dirname $latest_pkg)) | 104 pkg_dir=$(basename "$(dirname "$latest_pkg")") |
| 93 pkg_name=$(basename $latest_pkg) | 105 pkg_name=$(basename "$latest_pkg") |
| 94 echo "Installing ${latest_pkg}..." | 106 echo "Installing ${latest_pkg}..." |
| 95 | 107 |
| 96 remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" | 108 remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" |
| 97 temp_dir=$REMOTE_OUT | 109 temp_dir=$REMOTE_OUT |
| 98 remote_cp_to "${latest_pkg}" "${temp_dir}" | 110 remote_cp_to "${latest_pkg}" "${temp_dir}" |
| 99 remote_sh "mkdir -p /usr/portage/packages/${pkg_dir} && | 111 remote_sh "mkdir -p /usr/portage/packages/${pkg_dir} && |
| 100 mv ${temp_dir}/${pkg_name} /usr/portage/packages/${pkg_dir} && | 112 mv ${temp_dir}/${pkg_name} /usr/portage/packages/${pkg_dir} && |
| 101 env FEATURES=-sandbox emerge --usepkg \ | 113 env FEATURES=-sandbox emerge --usepkg \ |
| 102 /usr/portage/packages/${pkg_dir}/${pkg_name} 1>&2" | 114 /usr/portage/packages/${pkg_dir}/${pkg_name} 1>&2" |
| 103 echo "${pkg} has been installed" | 115 echo "${pkg} has been installed" |
| 104 remote_sh "rm -rf ${temp_dir}" | 116 remote_sh "rm -rf ${temp_dir}" |
| 105 done | 117 done |
| OLD | NEW |