Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: src/platform/dev/gmergefs

Issue 1515011: Adds gmergefs. A method of remoting to a target and pushing new (Closed)
Patch Set: Fixes for adlr Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/scripts/build_image » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 that emerges packages and their dependencies from a host development
8 # machine onto a target Chromium OS device
9 #
10 # NOTE: This script must be run from the chromiumos build chroot environment.
11 #
12
13 # Load common constants. This should be the first executable line.
14 # The path to common.sh should be relative to your script's location.
15 . "$(dirname "$0")/../../scripts/common.sh"
16
17 # Script must be run inside the chroot
18 assert_inside_chroot
19
20 get_default_board
21
22 # Flags
23 DEFINE_string board "$DEFAULT_BOARD" \
24 "The board to build packages for."
25 DEFINE_boolean usepkg $FLAGS_FALSE \
26 "Use binary packages to bootstrap build when possible."
27 DEFINE_string build_root "/build" \
28 "The root location for board sysroots."
29 DEFINE_integer jobs -1 \
30 "How many packages to build in parallel at maximum."
31 DEFINE_boolean unmerge $FLAGS_FALSE \
32 "Whether to unmerge the package versus emerge it."
33 DEFINE_integer retries -1 \
34 "On build failure, the number of times to retry"
35 DEFINE_boolean onstatefuldev $FLAGS_TRUE \
36 "Build packages and install them into stateful partition on device."
37 DEFINE_boolean installmask $FLAGS_TRUE \
38 "Use INSTALL_MASK to shrink the resulting image."
39 DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance"
40
41 # Parse command line
42 FLAGS_HELP="usage: $0 [flags]"
43 FLAGS "$@" || exit 1
44 eval set -- "${FLAGS_ARGV}"
45
46 # Die on any errors.
47 set -e
48
49 # Checks $1 and prints out $2 is required before exiting if $1 does not exist
50 check_args() {
51 if [ -z "${1}" ] ; then
52 echo "Error: ${2} is required."
53 exit 1
54 fi
55 }
56
57 # Clean up function for mount point
58 cleanup_sshfs_mount() {
59 echo "Cleaning up mount point"
60 sudo umount "${REMOTE_ROOT_DIR}"
61 }
62
63 check_args "${FLAGS_board}"
64 check_args "${FLAGS_ARGV}" "Emerge package name"
65
66 # Just in case we haven't done this before.
67 eval /sbin/modprobe fuse
68
69 EMERGE_FLAGS=""
70 [[ $FLAGS_usepkg -eq $FLAGS_TRUE ]] &&
71 EMERGE_FLAGS="${EMERGE_FLAGS} --getbinpkg --usepkg --with-bdeps y"
72
73 INSTALL_MASK=""
74 [[ ${FLAGS_installmask} -eq ${FLAGS_TRUE} ]] && \
75 INSTALL_MASK="${DEFAULT_INSTALL_MASK}"
76
77 EMERGE_JOBS=
78 [[ ${FLAGS_jobs} -ne -1 ]] && EMERGE_JOBS="--jobs=${FLAGS_jobs}"
79
80 # Duplicate from build_packages to get host packages on system.
81
82 # Skip building on host if we are unmerging.
83 if [ ${FLAGS_unmerge} -eq ${FLAGS_FALSE} ] ; then
84 eretry sudo emerge -uDNv $EMERGE_FLAGS world
85
86 # Build request and install them onto the sysroot
87 for emerge_request in $FLAGS_ARGV; do
88 eretry sudo emerge-${FLAGS_board} -uDNv \
89 $(remove_quotes "${emerge_request}")
90 done
91 fi
92
93 # Name is unique per client. This allows one to run gmergefs in parallel
94 # with multiple clients.
95 REMOTE_ROOT_DIR="${FLAGS_build_root}/${FLAGS_board}/gmergefs/${FLAGS_remote}"
96
97 # Default is to install on stateful dev, otherwise install on root.
98 REMOTE_RELATIVE_PATH=""
99 [ ${FLAGS_onstatefuldev} -eq $FLAGS_TRUE ] && \
100 REMOTE_RELATIVE_PATH="mnt/stateful_partition/dev_image"
101 REMOTE_PATH="${REMOTE_ROOT_DIR}/${REMOTE_RELATIVE_PATH}"
102
103 # Create directory for remote image
104 sudo mkdir -p "${REMOTE_ROOT_DIR}"
105
106 # Mount remote fs into chroot
107 echo "Enter password for remote machine"
108 sudo sshfs -o idmap=user -o allow_other -o nonempty -o transform_symlinks \
109 "root@${FLAGS_remote}:/" "${REMOTE_ROOT_DIR}"
110
111 trap cleanup_sshfs_mount EXIT
112
113 # Ensure root path is created for emerge
114 sudo mkdir -p "${REMOTE_PATH}"
115
116 # Same arguments used in build_image to emerge these packages onto the target
117 for emerge_request in $FLAGS_ARGV; do
118 if [ ${FLAGS_unmerge} -eq ${FLAGS_FALSE} ] ; then
119 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${FLAGS_board} \
120 --root="${REMOTE_PATH}" --root-deps=rdeps \
121 --usepkgonly $(remove_quotes "${emerge_request}") $EMERGE_JOBS
122 else
123 sudo emerge-${FLAGS_board} --unmerge \
124 --root="${REMOTE_PATH}" $(remove_quotes "${emerge_request}")
125 fi
126 done
127
128 sync
129
130 sudo umount "${REMOTE_ROOT_DIR}"
131
132 trap - EXIT
OLDNEW
« no previous file with comments | « no previous file | src/scripts/build_image » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698