OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 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 |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # Script to update a running device with an optionally built package out |
| 8 # of your build directory |
| 9 |
| 10 # Load common constants. This should be the first executable line. |
| 11 # The path to common.sh should be relative to your script's location. |
| 12 |
| 13 script_root=$(dirname $0) |
| 14 if [ -f ${script_root}/../common.sh ] ; then |
| 15 script_root=${script_root}/.. |
| 16 fi |
| 17 |
| 18 . "${script_root}/common.sh" |
| 19 . "${script_root}/remote_access.sh" |
| 20 |
| 21 get_default_board |
| 22 |
| 23 DEFINE_boolean verbose ${FLAGS_FALSE} \ |
| 24 "Whether to output verbose information for debugging." |
| 25 DEFINE_boolean build ${FLAGS_FALSE} "Build package before installing" |
| 26 DEFINE_string board "$DEFAULT_BOARD" \ |
| 27 "Board for which the package should be built/found" |
| 28 DEFINE_string build_root "/build" \ |
| 29 "The root location for board sysroots." |
| 30 |
| 31 FLAGS "$@" || exit 1 |
| 32 |
| 33 TMP=$(mktemp -d /tmp/cros_package_to_live.XXXX) |
| 34 |
| 35 function cleanup { |
| 36 cleanup_remote_access |
| 37 rm -rf "${TMP}" |
| 38 } |
| 39 |
| 40 # Make sure we have a package name |
| 41 if [ -z "${FLAGS_ARGV}" ]; then |
| 42 echo "Please specify packages to install. For example:" |
| 43 echo " $0 --remote=MyMachine flimflam" |
| 44 exit 1 |
| 45 fi |
| 46 |
| 47 if [ -z "${FLAGS_board}" ]; then |
| 48 echo "Please specify a board using the --board=MyBoard argument" |
| 49 exit 1 |
| 50 fi |
| 51 |
| 52 set -e |
| 53 trap cleanup EXIT |
| 54 |
| 55 remote_access_init |
| 56 |
| 57 eval set -- "${FLAGS_ARGV}" |
| 58 |
| 59 if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then |
| 60 emerge-${FLAGS_board} $@ |
| 61 fi |
| 62 |
| 63 PKGROOT="${FLAGS_build_root}/${FLAGS_board}/packages" |
| 64 |
| 65 for pkg in $@; do |
| 66 latest_pkg=$(ls -tr $PKGROOT/*/${pkg}-[0-9]* | tail -1) |
| 67 if [ -z "${latest_pkg}" ]; then |
| 68 echo "Could not find latest built version of ${pkg}" |
| 69 exit 1 |
| 70 fi |
| 71 pkg_dir=$(basename $(dirname $latest_pkg)) |
| 72 pkg_name=$(basename $latest_pkg) |
| 73 echo "Installing ${latest_pkg}..." |
| 74 |
| 75 remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" |
| 76 temp_dir=$REMOTE_OUT |
| 77 remote_cp "${latest_pkg}" "${temp_dir}" |
| 78 remote_sh "mount -o remount,rw /" |
| 79 remote_sh "mkdir -p /usr/portage/packages/${pkg_dir} && |
| 80 mv ${temp_dir}/${pkg_name} /usr/portage/packages/${pkg_dir} && |
| 81 env FEATURES=-sandbox emerge --usepkg \ |
| 82 /usr/portage/packages/${pkg_dir}/${pkg_name} 1>&2" |
| 83 echo "${pkg} has been installed" |
| 84 remote_sh "rm -rf ${temp_dir}" |
| 85 remote_sh "mount -o remount,ro /" || /bin/true |
| 86 done |
OLD | NEW |