| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 DELTA=$FLAGS_TRUE | 152 DELTA=$FLAGS_TRUE |
| 153 [ -n "$FLAGS_output" ] || die \ | 153 [ -n "$FLAGS_output" ] || die \ |
| 154 "Error: you must specify an output filename with --output FILENAME" | 154 "Error: you must specify an output filename with --output FILENAME" |
| 155 | 155 |
| 156 if [ -z "$FLAGS_src_image" ]; then | 156 if [ -z "$FLAGS_src_image" ]; then |
| 157 DELTA=$FLAGS_FALSE | 157 DELTA=$FLAGS_FALSE |
| 158 if [ "$FLAGS_old_style" = "$FLAGS_TRUE" ]; then | 158 if [ "$FLAGS_old_style" = "$FLAGS_TRUE" ]; then |
| 159 echo "Generating an old-style full update" | 159 echo "Generating an old-style full update" |
| 160 else | 160 else |
| 161 die "Generating a new-style full update not yet supported" | 161 echo "Generating a new-style full update" |
| 162 fi | 162 fi |
| 163 fi | 163 fi |
| 164 | 164 |
| 165 if [ "$DELTA" -eq "$FLAGS_TRUE" ]; then | 165 if [ "$DELTA" -eq "$FLAGS_TRUE" -o "$FLAGS_old_style" -eq "$FLAGS_FALSE" ]; then |
| 166 echo "Generating a delta update" | 166 echo "Generating a delta update" |
| 167 | 167 |
| 168 # Sanity check that the real generator exists: | 168 # Sanity check that the real generator exists: |
| 169 GENERATOR="$(dirname "$0")/../platform/update_engine/delta_generator" | 169 GENERATOR="$(dirname "$0")/../platform/update_engine/delta_generator" |
| 170 [ -x "$GENERATOR" ] || die "$GENERATOR doesn't exist, or isn't executable" | 170 [ -x "$GENERATOR" ] || die "$GENERATOR doesn't exist, or isn't executable" |
| 171 | 171 |
| 172 trap cleanup INT TERM EXIT | 172 trap cleanup INT TERM EXIT |
| 173 SRC_KERNEL=$(extract_partition_to_temp_file "$FLAGS_src_image" 2) | 173 if [ "$DELTA" -eq "$FLAGS_TRUE" ]; then |
| 174 if [ "$FLAGS_patch_kernel" -eq "$FLAGS_TRUE" ]; then | 174 SRC_KERNEL=$(extract_partition_to_temp_file "$FLAGS_src_image" 2) |
| 175 patch_kernel "$FLAGS_src_image" "$SRC_KERNEL" | 175 if [ "$FLAGS_patch_kernel" -eq "$FLAGS_TRUE" ]; then |
| 176 patch_kernel "$FLAGS_src_image" "$SRC_KERNEL" |
| 177 fi |
| 178 SRC_ROOT=$(extract_partition_to_temp_file "$FLAGS_src_image" 3) |
| 179 |
| 180 echo md5sum of src kernel: |
| 181 md5sum "$SRC_KERNEL" |
| 182 echo md5sum of src root: |
| 183 md5sum "$SRC_ROOT" |
| 176 fi | 184 fi |
| 177 SRC_ROOT=$(extract_partition_to_temp_file "$FLAGS_src_image" 3) | |
| 178 | |
| 179 echo md5sum of src kernel: | |
| 180 md5sum "$SRC_KERNEL" | |
| 181 echo md5sum of src root: | |
| 182 md5sum "$SRC_ROOT" | |
| 183 | 185 |
| 184 DST_KERNEL=$(extract_partition_to_temp_file "$FLAGS_image" 2) | 186 DST_KERNEL=$(extract_partition_to_temp_file "$FLAGS_image" 2) |
| 185 if [ "$FLAGS_patch_kernel" -eq "$FLAGS_TRUE" ]; then | 187 if [ "$FLAGS_patch_kernel" -eq "$FLAGS_TRUE" ]; then |
| 186 patch_kernel "$FLAGS_image" "$DST_KERNEL" | 188 patch_kernel "$FLAGS_image" "$DST_KERNEL" |
| 187 fi | 189 fi |
| 188 DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3) | 190 DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3) |
| 189 | 191 |
| 190 SRC_MNT=$(mktemp -d /tmp/src_root.XXXXXX) | 192 if [ "$DELTA" -eq "$FLAGS_TRUE" ]; then |
| 191 sudo mount -o loop,ro "$SRC_ROOT" "$SRC_MNT" | 193 SRC_MNT=$(mktemp -d /tmp/src_root.XXXXXX) |
| 194 sudo mount -o loop,ro "$SRC_ROOT" "$SRC_MNT" |
| 192 | 195 |
| 193 DST_MNT=$(mktemp -d /tmp/src_root.XXXXXX) | 196 DST_MNT=$(mktemp -d /tmp/src_root.XXXXXX) |
| 194 sudo mount -o loop,ro "$DST_ROOT" "$DST_MNT" | 197 sudo mount -o loop,ro "$DST_ROOT" "$DST_MNT" |
| 195 | 198 |
| 196 sudo "$GENERATOR" \ | 199 sudo "$GENERATOR" \ |
| 197 -new_dir "$DST_MNT" -new_image "$DST_ROOT" -new_kernel "$DST_KERNEL" \ | 200 -new_dir "$DST_MNT" -new_image "$DST_ROOT" -new_kernel "$DST_KERNEL" \ |
| 198 -old_dir "$SRC_MNT" -old_image "$SRC_ROOT" -old_kernel "$SRC_KERNEL" \ | 201 -old_dir "$SRC_MNT" -old_image "$SRC_ROOT" -old_kernel "$SRC_KERNEL" \ |
| 199 -out_file "$FLAGS_output" -private_key "$FLAGS_private_key" | 202 -out_file "$FLAGS_output" -private_key "$FLAGS_private_key" |
| 203 else |
| 204 "$GENERATOR" \ |
| 205 -new_image "$DST_ROOT" -new_kernel "$DST_KERNEL" \ |
| 206 -out_file "$FLAGS_output" -private_key "$FLAGS_private_key" |
| 207 fi |
| 200 | 208 |
| 201 trap - INT TERM EXIT | 209 trap - INT TERM EXIT |
| 202 cleanup noexit | 210 cleanup noexit |
| 203 echo "Done generating delta." | 211 |
| 212 if [ "$DELTA" -eq "$FLAGS_TRUE" ]; then |
| 213 echo "Done generating delta." |
| 214 else |
| 215 echo "Done generating new style full update." |
| 216 fi |
| 204 else | 217 else |
| 205 echo "Generating full update" | 218 echo "Generating full update" |
| 206 | 219 |
| 207 trap cleanup INT TERM EXIT | 220 trap cleanup INT TERM EXIT |
| 208 DST_KERNEL=$(extract_partition_to_temp_file "$FLAGS_image" 2) | 221 DST_KERNEL=$(extract_partition_to_temp_file "$FLAGS_image" 2) |
| 209 if [ "$FLAGS_patch_kernel" -eq "$FLAGS_TRUE" ]; then | 222 if [ "$FLAGS_patch_kernel" -eq "$FLAGS_TRUE" ]; then |
| 210 patch_kernel "$FLAGS_image" "$DST_KERNEL" | 223 patch_kernel "$FLAGS_image" "$DST_KERNEL" |
| 211 fi | 224 fi |
| 212 DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3) | 225 DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3) |
| 213 | 226 |
| 214 GENERATOR="$(dirname "$0")/mk_memento_images.sh" | 227 GENERATOR="$(dirname "$0")/mk_memento_images.sh" |
| 215 | 228 |
| 216 CROS_GENERATE_UPDATE_PAYLOAD_CALLED=1 "$GENERATOR" "$DST_KERNEL" "$DST_ROOT" | 229 CROS_GENERATE_UPDATE_PAYLOAD_CALLED=1 "$GENERATOR" "$DST_KERNEL" "$DST_ROOT" |
| 217 mv "$(dirname "$DST_KERNEL")/update.gz" "$FLAGS_output" | 230 mv "$(dirname "$DST_KERNEL")/update.gz" "$FLAGS_output" |
| 218 | 231 |
| 219 trap - INT TERM EXIT | 232 trap - INT TERM EXIT |
| 220 cleanup noexit | 233 cleanup noexit |
| 221 echo "Done generating full update." | 234 echo "Done generating full update." |
| 222 fi | 235 fi |
| OLD | NEW |