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 generate a Chromium OS update for use by the update engine. | 7 # Script to generate a Chromium OS update for use by the update engine. |
8 # If a source .bin is specified, the update is assumed to be a delta update. | 8 # If a source .bin is specified, the update is assumed to be a delta update. |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 patch_kernel "$bin_file" "$kern_out" | 112 patch_kernel "$bin_file" "$kern_out" |
113 fi | 113 fi |
114 extract_partition_to_temp_file "$bin_file" 3 "$root_out" | 114 extract_partition_to_temp_file "$bin_file" 3 "$root_out" |
115 } | 115 } |
116 | 116 |
117 DEFINE_string image "" "The image that should be sent to clients." | 117 DEFINE_string image "" "The image that should be sent to clients." |
118 DEFINE_string src_image "" "Optional: a source image. If specified, this makes\ | 118 DEFINE_string src_image "" "Optional: a source image. If specified, this makes\ |
119 a delta update." | 119 a delta update." |
120 DEFINE_boolean old_style "$FLAGS_TRUE" "Generate an old-style .gz full update." | 120 DEFINE_boolean old_style "$FLAGS_TRUE" "Generate an old-style .gz full update." |
121 DEFINE_string output "" "Output file" | 121 DEFINE_string output "" "Output file" |
| 122 DEFINE_boolean outside_chroot "$FLAGS_FALSE" "Running outside of chroot." |
122 DEFINE_boolean patch_kernel "$FLAGS_FALSE" "Whether or not to patch the kernel \ | 123 DEFINE_boolean patch_kernel "$FLAGS_FALSE" "Whether or not to patch the kernel \ |
123 with the patch from the stateful partition (default: false)" | 124 with the patch from the stateful partition (default: false)" |
124 DEFINE_string private_key "" "Path to private key in .pem format." | 125 DEFINE_string private_key "" "Path to private key in .pem format." |
125 DEFINE_boolean extract "$FLAGS_FALSE" "If set, extract old/new kernel/rootfs \ | 126 DEFINE_boolean extract "$FLAGS_FALSE" "If set, extract old/new kernel/rootfs \ |
126 to [old|new]_[kern|root].dat. Useful for debugging (default: false)" | 127 to [old|new]_[kern|root].dat. Useful for debugging (default: false)" |
127 DEFINE_boolean full_kernel "$FLAGS_FALSE" "Generate a full kernel update even \ | 128 DEFINE_boolean full_kernel "$FLAGS_FALSE" "Generate a full kernel update even \ |
128 if generating a delta update (default: false)" | 129 if generating a delta update (default: false)" |
129 | 130 |
130 # Parse command line | 131 # Parse command line |
131 FLAGS "$@" || exit 1 | 132 FLAGS "$@" || exit 1 |
132 eval set -- "${FLAGS_ARGV}" | 133 eval set -- "${FLAGS_ARGV}" |
133 | 134 |
134 set -e | 135 set -e |
135 | 136 |
136 if [ -n "$FLAGS_src_image" ]; then | 137 if [ -n "$FLAGS_src_image" ] && \ |
137 # We need to be in the chroot for generating delta images | 138 [ "$FLAGS_outside_chroot" -eq "$FLAGS_FALSE" ]; then |
| 139 # We need to be in the chroot for generating delta images. |
| 140 # by specifying --outside_chroot you can choose not to assert |
| 141 # this will allow us to run this script outside chroot. |
| 142 # Running this script outside chroot requires copying delta_generator binary |
| 143 # and also copying few shared libraries with it. |
138 assert_inside_chroot | 144 assert_inside_chroot |
139 fi | 145 fi |
140 | 146 |
141 locate_gpt | 147 locate_gpt |
142 | 148 |
143 if [ "$FLAGS_extract" -eq "$FLAGS_TRUE" ]; then | 149 if [ "$FLAGS_extract" -eq "$FLAGS_TRUE" ]; then |
144 if [ -n "$FLAGS_src_image" ]; then | 150 if [ -n "$FLAGS_src_image" ]; then |
145 extract_kern_root "$FLAGS_src_image" old_kern.dat old_root.dat | 151 extract_kern_root "$FLAGS_src_image" old_kern.dat old_root.dat |
146 fi | 152 fi |
147 if [ -n "$FLAGS_image" ]; then | 153 if [ -n "$FLAGS_image" ]; then |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 fi | 201 fi |
196 DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3) | 202 DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3) |
197 | 203 |
198 if [ "$DELTA" -eq "$FLAGS_TRUE" ]; then | 204 if [ "$DELTA" -eq "$FLAGS_TRUE" ]; then |
199 SRC_MNT=$(mktemp -d /tmp/src_root.XXXXXX) | 205 SRC_MNT=$(mktemp -d /tmp/src_root.XXXXXX) |
200 sudo mount -o loop,ro "$SRC_ROOT" "$SRC_MNT" | 206 sudo mount -o loop,ro "$SRC_ROOT" "$SRC_MNT" |
201 | 207 |
202 DST_MNT=$(mktemp -d /tmp/src_root.XXXXXX) | 208 DST_MNT=$(mktemp -d /tmp/src_root.XXXXXX) |
203 sudo mount -o loop,ro "$DST_ROOT" "$DST_MNT" | 209 sudo mount -o loop,ro "$DST_ROOT" "$DST_MNT" |
204 | 210 |
205 sudo "$GENERATOR" \ | 211 sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} PATH=${PATH} "$GENERATOR" \ |
206 -new_dir "$DST_MNT" -new_image "$DST_ROOT" -new_kernel "$DST_KERNEL" \ | 212 -new_dir "$DST_MNT" -new_image "$DST_ROOT" -new_kernel "$DST_KERNEL" \ |
207 -old_dir "$SRC_MNT" -old_image "$SRC_ROOT" -old_kernel "$SRC_KERNEL" \ | 213 -old_dir "$SRC_MNT" -old_image "$SRC_ROOT" -old_kernel "$SRC_KERNEL" \ |
208 -out_file "$FLAGS_output" -private_key "$FLAGS_private_key" | 214 -out_file "$FLAGS_output" -private_key "$FLAGS_private_key" |
209 else | 215 else |
210 "$GENERATOR" \ | 216 "$GENERATOR" \ |
211 -new_image "$DST_ROOT" -new_kernel "$DST_KERNEL" \ | 217 -new_image "$DST_ROOT" -new_kernel "$DST_KERNEL" \ |
212 -out_file "$FLAGS_output" -private_key "$FLAGS_private_key" | 218 -out_file "$FLAGS_output" -private_key "$FLAGS_private_key" |
213 fi | 219 fi |
214 | 220 |
215 trap - INT TERM EXIT | 221 trap - INT TERM EXIT |
(...skipping 16 matching lines...) Expand all Loading... |
232 | 238 |
233 GENERATOR="$(dirname "$0")/mk_memento_images.sh" | 239 GENERATOR="$(dirname "$0")/mk_memento_images.sh" |
234 | 240 |
235 CROS_GENERATE_UPDATE_PAYLOAD_CALLED=1 "$GENERATOR" "$DST_KERNEL" "$DST_ROOT" | 241 CROS_GENERATE_UPDATE_PAYLOAD_CALLED=1 "$GENERATOR" "$DST_KERNEL" "$DST_ROOT" |
236 mv "$(dirname "$DST_KERNEL")/update.gz" "$FLAGS_output" | 242 mv "$(dirname "$DST_KERNEL")/update.gz" "$FLAGS_output" |
237 | 243 |
238 trap - INT TERM EXIT | 244 trap - INT TERM EXIT |
239 cleanup noexit | 245 cleanup noexit |
240 echo "Done generating full update." | 246 echo "Done generating full update." |
241 fi | 247 fi |
OLD | NEW |