| 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 # Load common constants. This should be the first executable line. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 DEFINE_string board "$DEFAULT_BOARD" \ | 26 DEFINE_string board "$DEFAULT_BOARD" \ |
| 27 "Board for which the package should be built/found" | 27 "Board for which the package should be built/found" |
| 28 DEFINE_string build_root "/build" \ | 28 DEFINE_string build_root "/build" \ |
| 29 "The root location for board sysroots." | 29 "The root location for board sysroots." |
| 30 | 30 |
| 31 FLAGS "$@" || exit 1 | 31 FLAGS "$@" || exit 1 |
| 32 | 32 |
| 33 TMP=$(mktemp -d /tmp/cros_package_to_live.XXXX) | 33 TMP=$(mktemp -d /tmp/cros_package_to_live.XXXX) |
| 34 | 34 |
| 35 function cleanup { | 35 function cleanup { |
| 36 if [ "${mount_type}" = ro ]; then | 36 if [ "${root_mount_type}" = ro ]; then |
| 37 remote_sh "mount -o remount,ro /" || /bin/true | 37 remote_sh "mount -o remount,ro /" || /bin/true |
| 38 fi | 38 fi |
| 39 if [ "${var_mount_noexec}" = yes ]; then |
| 40 remote_sh "mount -o remount,noexec /var" || /bin/true |
| 41 fi |
| 39 cleanup_remote_access | 42 cleanup_remote_access |
| 40 rm -rf "${TMP}" | 43 rm -rf "${TMP}" |
| 41 } | 44 } |
| 42 | 45 |
| 43 # Make sure we have a package name | 46 # Make sure we have a package name |
| 44 if [ -z "${FLAGS_ARGV}" ]; then | 47 if [ -z "${FLAGS_ARGV}" ]; then |
| 45 echo "Please specify packages to install. For example:" | 48 echo "Please specify packages to install. For example:" |
| 46 echo " $0 --remote=MyMachine flimflam" | 49 echo " $0 --remote=MyMachine flimflam" |
| 47 exit 1 | 50 exit 1 |
| 48 fi | 51 fi |
| 49 | 52 |
| 50 if [ -z "${FLAGS_board}" ]; then | 53 if [ -z "${FLAGS_board}" ]; then |
| 51 echo "Please specify a board using the --board=MyBoard argument" | 54 echo "Please specify a board using the --board=MyBoard argument" |
| 52 exit 1 | 55 exit 1 |
| 53 fi | 56 fi |
| 54 | 57 |
| 55 set -e | 58 set -e |
| 56 trap cleanup EXIT | 59 trap cleanup EXIT |
| 57 | 60 |
| 58 remote_access_init | 61 remote_access_init |
| 59 | 62 |
| 60 eval set -- "${FLAGS_ARGV}" | 63 eval set -- "${FLAGS_ARGV}" |
| 61 | 64 |
| 62 if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then | 65 if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then |
| 63 emerge-${FLAGS_board} $@ | 66 emerge-${FLAGS_board} $@ |
| 64 fi | 67 fi |
| 65 | 68 |
| 66 PKGROOT="${FLAGS_build_root}/${FLAGS_board}/packages" | 69 PKGROOT="${FLAGS_build_root}/${FLAGS_board}/packages" |
| 67 | 70 |
| 71 # Temporarily clear read-only flag on / if it is set |
| 68 remote_sh "grep '\S* / ' /proc/mounts | tail -1 | awk '{ print \$4 }' | | 72 remote_sh "grep '\S* / ' /proc/mounts | tail -1 | awk '{ print \$4 }' | |
| 69 cut -d, -f1" | 73 cut -d, -f1" |
| 70 mount_type=$REMOTE_OUT | 74 root_mount_type=${REMOTE_OUT} |
| 71 if [ "${mount_type}" = ro ]; then | 75 if [ "${root_mount_type}" = ro ]; then |
| 72 remote_sh "mount -o remount,rw /" | 76 remote_sh "mount -o remount,rw /" |
| 73 fi | 77 fi |
| 74 | 78 |
| 79 # Temporarily clear noexec flag on /var if it is set |
| 80 remote_sh "grep '\S* /var ' /proc/mounts | tail -1 | awk '{ print \$4 }'" |
| 81 if expr "${REMOTE_OUT}" : '.*noexec' >/dev/null; then |
| 82 var_mount_noexec=yes |
| 83 remote_sh "mount -o remount,exec /var" |
| 84 fi |
| 85 |
| 75 for pkg in $@; do | 86 for pkg in $@; do |
| 76 latest_pkg=$(ls -tr $PKGROOT/*/${pkg}-[0-9]* | tail -1) | 87 latest_pkg=$(ls -tr $PKGROOT/*/${pkg}-[0-9]* | tail -1) |
| 77 if [ -z "${latest_pkg}" ]; then | 88 if [ -z "${latest_pkg}" ]; then |
| 78 echo "Could not find latest built version of ${pkg}" | 89 echo "Could not find latest built version of ${pkg}" |
| 79 exit 1 | 90 exit 1 |
| 80 fi | 91 fi |
| 81 pkg_dir=$(basename $(dirname $latest_pkg)) | 92 pkg_dir=$(basename $(dirname $latest_pkg)) |
| 82 pkg_name=$(basename $latest_pkg) | 93 pkg_name=$(basename $latest_pkg) |
| 83 echo "Installing ${latest_pkg}..." | 94 echo "Installing ${latest_pkg}..." |
| 84 | 95 |
| 85 remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" | 96 remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" |
| 86 temp_dir=$REMOTE_OUT | 97 temp_dir=$REMOTE_OUT |
| 87 remote_cp_to "${latest_pkg}" "${temp_dir}" | 98 remote_cp_to "${latest_pkg}" "${temp_dir}" |
| 88 remote_sh "mkdir -p /usr/portage/packages/${pkg_dir} && | 99 remote_sh "mkdir -p /usr/portage/packages/${pkg_dir} && |
| 89 mv ${temp_dir}/${pkg_name} /usr/portage/packages/${pkg_dir} && | 100 mv ${temp_dir}/${pkg_name} /usr/portage/packages/${pkg_dir} && |
| 90 env FEATURES=-sandbox emerge --usepkg \ | 101 env FEATURES=-sandbox emerge --usepkg \ |
| 91 /usr/portage/packages/${pkg_dir}/${pkg_name} 1>&2" | 102 /usr/portage/packages/${pkg_dir}/${pkg_name} 1>&2" |
| 92 echo "${pkg} has been installed" | 103 echo "${pkg} has been installed" |
| 93 remote_sh "rm -rf ${temp_dir}" | 104 remote_sh "rm -rf ${temp_dir}" |
| 94 done | 105 done |
| OLD | NEW |