| OLD | NEW | 
|---|
|  | 1 #!/bin/sh | 
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 4 # found in the LICENSE file. | 
| 4 # | 5 # | 
| 5 # Force cleans loopback devices from within your chroot environment.  This | 6 # Force cleans loopback devices from within your chroot environment.  This | 
| 6 # script is to help mitigate losing loopback devices on build_images | 7 # script is to help mitigate losing loopback devices on build_images | 
| 7 # failures.  This script only affects mountpoints and loopback devices | 8 # failures.  This script only affects mountpoints and loopback devices | 
| 8 # that were created within this chroot. | 9 # that were created within this chroot. | 
| 9 | 10 | 
| 10 # Load common constants.  This should be the first executable line. | 11 # --- BEGIN COMMON.SH BOILERPLATE --- | 
| 11 # The path to common.sh should be relative to your script's location. | 12 # Load common CrOS utilities.  Inside the chroot this file is installed in | 
| 12 . "$(dirname "$0")/common.sh" | 13 # /usr/lib/crosutils.  Outside the chroot we find it relative to the script's | 
|  | 14 # location. | 
|  | 15 find_common_sh() { | 
|  | 16   local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) | 
|  | 17   local path | 
|  | 18 | 
|  | 19   SCRIPT_ROOT= | 
|  | 20   for path in "${common_paths[@]}"; do | 
|  | 21     if [ -r "${path}/common.sh" ]; then | 
|  | 22       SCRIPT_ROOT=${path} | 
|  | 23       break | 
|  | 24     fi | 
|  | 25   done | 
|  | 26 } | 
|  | 27 | 
|  | 28 find_common_sh | 
|  | 29 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) | 
|  | 30 # --- END COMMON.SH BOILERPLATE --- | 
| 13 | 31 | 
| 14 # Script must be run inside the chroot. | 32 # Script must be run inside the chroot. | 
| 15 assert_inside_chroot | 33 assert_inside_chroot | 
| 16 | 34 | 
| 17 DEFINE_string output_root "$DEFAULT_BUILD_ROOT/images" \ | 35 DEFINE_string output_root "$DEFAULT_BUILD_ROOT/images" \ | 
| 18   "Directory in which to place image result directories (named by version)" | 36   "Directory in which to place image result directories (named by version)" | 
| 19 DEFINE_string board "$DEFAULT_BOARD" \ | 37 DEFINE_string board "$DEFAULT_BOARD" \ | 
| 20   "The board to build an image for." | 38   "The board to build an image for." | 
| 21 | 39 | 
| 22 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}" | 40 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}" | 
| 23 | 41 | 
| 24 echo "This will unmount any directory under $OUTPUT_DIR:" | 42 echo "This will unmount any directory under $OUTPUT_DIR:" | 
| 25 read -p "Are you sure (y/N)? " SURE | 43 read -p "Are you sure (y/N)? " SURE | 
| 26 SURE="${SURE:0:1}" # Get just the first character | 44 SURE="${SURE:0:1}" # Get just the first character | 
| 27 if [ "${SURE}" != "y" ] | 45 if [ "${SURE}" != "y" ]; then | 
| 28 then |  | 
| 29   echo "Ok, better safe than sorry." | 46   echo "Ok, better safe than sorry." | 
| 30   exit 1 | 47   exit 1 | 
| 31 fi | 48 fi | 
| 32 | 49 | 
| 33 sudo umount "$OUTPUT_DIR"/*/* 2> /dev/null | 50 sudo umount "$OUTPUT_DIR"/*/* 2> /dev/null | 
| 34 sudo losetup -d /dev/loop* 2> /dev/null | 51 sudo losetup -d /dev/loop* 2> /dev/null | 
| OLD | NEW | 
|---|