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 cleanup_remote_access | 36 if [ "${mount_type}" = ro ]; then |
37 rm -rf "${TMP}" | 37 remote_sh "mount -o remount,ro /" || /bin/true |
| 38 fi |
| 39 cleanup_remote_access |
| 40 rm -rf "${TMP}" |
38 } | 41 } |
39 | 42 |
40 # Make sure we have a package name | 43 # Make sure we have a package name |
41 if [ -z "${FLAGS_ARGV}" ]; then | 44 if [ -z "${FLAGS_ARGV}" ]; then |
42 echo "Please specify packages to install. For example:" | 45 echo "Please specify packages to install. For example:" |
43 echo " $0 --remote=MyMachine flimflam" | 46 echo " $0 --remote=MyMachine flimflam" |
44 exit 1 | 47 exit 1 |
45 fi | 48 fi |
46 | 49 |
47 if [ -z "${FLAGS_board}" ]; then | 50 if [ -z "${FLAGS_board}" ]; then |
48 echo "Please specify a board using the --board=MyBoard argument" | 51 echo "Please specify a board using the --board=MyBoard argument" |
49 exit 1 | 52 exit 1 |
50 fi | 53 fi |
51 | 54 |
52 set -e | 55 set -e |
53 trap cleanup EXIT | 56 trap cleanup EXIT |
54 | 57 |
55 remote_access_init | 58 remote_access_init |
56 | 59 |
57 eval set -- "${FLAGS_ARGV}" | 60 eval set -- "${FLAGS_ARGV}" |
58 | 61 |
59 if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then | 62 if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then |
60 emerge-${FLAGS_board} $@ | 63 emerge-${FLAGS_board} $@ |
61 fi | 64 fi |
62 | 65 |
63 PKGROOT="${FLAGS_build_root}/${FLAGS_board}/packages" | 66 PKGROOT="${FLAGS_build_root}/${FLAGS_board}/packages" |
64 | 67 |
| 68 remote_sh "grep '\S* / ' /proc/mounts | tail -1 | awk '{ print \$4 }' | |
| 69 cut -d, -f1" |
| 70 mount_type=$REMOTE_OUT |
| 71 if [ "${mount_type}" = ro ]; then |
| 72 remote_sh "mount -o remount,rw /" |
| 73 fi |
| 74 |
65 for pkg in $@; do | 75 for pkg in $@; do |
66 latest_pkg=$(ls -tr $PKGROOT/*/${pkg}-[0-9]* | tail -1) | 76 latest_pkg=$(ls -tr $PKGROOT/*/${pkg}-[0-9]* | tail -1) |
67 if [ -z "${latest_pkg}" ]; then | 77 if [ -z "${latest_pkg}" ]; then |
68 echo "Could not find latest built version of ${pkg}" | 78 echo "Could not find latest built version of ${pkg}" |
69 exit 1 | 79 exit 1 |
70 fi | 80 fi |
71 pkg_dir=$(basename $(dirname $latest_pkg)) | 81 pkg_dir=$(basename $(dirname $latest_pkg)) |
72 pkg_name=$(basename $latest_pkg) | 82 pkg_name=$(basename $latest_pkg) |
73 echo "Installing ${latest_pkg}..." | 83 echo "Installing ${latest_pkg}..." |
74 | 84 |
75 remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" | 85 remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" |
76 temp_dir=$REMOTE_OUT | 86 temp_dir=$REMOTE_OUT |
77 remote_cp_to "${latest_pkg}" "${temp_dir}" | 87 remote_cp_to "${latest_pkg}" "${temp_dir}" |
78 remote_sh "mount -o remount,rw /" | |
79 remote_sh "mkdir -p /usr/portage/packages/${pkg_dir} && | 88 remote_sh "mkdir -p /usr/portage/packages/${pkg_dir} && |
80 mv ${temp_dir}/${pkg_name} /usr/portage/packages/${pkg_dir} && | 89 mv ${temp_dir}/${pkg_name} /usr/portage/packages/${pkg_dir} && |
81 env FEATURES=-sandbox emerge --usepkg \ | 90 env FEATURES=-sandbox emerge --usepkg \ |
82 /usr/portage/packages/${pkg_dir}/${pkg_name} 1>&2" | 91 /usr/portage/packages/${pkg_dir}/${pkg_name} 1>&2" |
83 echo "${pkg} has been installed" | 92 echo "${pkg} has been installed" |
84 remote_sh "rm -rf ${temp_dir}" | 93 remote_sh "rm -rf ${temp_dir}" |
85 remote_sh "mount -o remount,ro /" || /bin/true | |
86 done | 94 done |
OLD | NEW |