OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 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 # Prints the path to the most recently built image to stdout. | 7 # Prints the path to the most recently built image to stdout. |
8 | 8 |
9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
11 . "$(dirname "$0")/common.sh" | 11 . "$(dirname "$0")/common.sh" |
12 | 12 |
13 get_default_board | 13 get_default_board |
14 | 14 |
15 DEFINE_string board "$DEFAULT_BOARD" \ | 15 DEFINE_string board "$DEFAULT_BOARD" \ |
16 "The name of the board to check for images." | 16 "The name of the board to check for images." |
17 | 17 |
18 # Parse command line flags | 18 # Parse command line flags |
19 FLAGS "$@" || exit 1 | 19 FLAGS "$@" || exit 1 |
20 eval set -- "${FLAGS_ARGV}" | 20 eval set -- "${FLAGS_ARGV}" |
21 | 21 |
22 # Check on the board that they are trying to set up. | 22 # Check on the board that they are trying to set up. |
23 if [ -z "$FLAGS_board" ] ; then | 23 if [ -z "$FLAGS_board" ] ; then |
24 echo "Error: --board required." | 24 die "Error: --board required." |
25 exit 1 | |
26 fi | 25 fi |
27 | 26 |
28 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" | 27 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
29 | 28 |
30 # If there are no images, return nothing | 29 # If there are no images, return nothing |
31 [ -d $IMAGES_DIR ] || exit 0 | 30 [ -d $IMAGES_DIR ] || exit 0 |
32 | 31 |
33 # Use latest link if it exists, otherwise most recently changed dir | 32 # Use latest link if it exists, otherwise most recently changed dir |
34 if [ -L ${IMAGES_DIR}/latest ] ; then | 33 if [ -L ${IMAGES_DIR}/latest ] ; then |
35 DEFAULT_FROM="${IMAGES_DIR}/`readlink ${IMAGES_DIR}/latest`" | 34 DEFAULT_FROM="${IMAGES_DIR}/`readlink ${IMAGES_DIR}/latest`" |
36 else | 35 else |
37 DEFAULT_FROM="${IMAGES_DIR}/`ls -t $IMAGES_DIR | head -1`" | 36 DEFAULT_FROM="${IMAGES_DIR}/`ls -t $IMAGES_DIR | head -1`" |
38 fi | 37 fi |
39 | 38 |
40 echo $DEFAULT_FROM | 39 echo $DEFAULT_FROM |
OLD | NEW |