~ubuntu-branches/ubuntu/saucy/cloud-init/saucy

« back to all changes in this revision

Viewing changes to tools/read-version

  • Committer: Scott Moser
  • Date: 2013-09-11 21:04:19 UTC
  • mfrom: (1.4.5)
  • Revision ID: smoser@ubuntu.com-20130911210419-3vt5ze6ph3hu8dz1
* New upstream snapshot.
  * Add OpenNebula datasource.
  * Support reading 'random_seed' from metadata and writing to /dev/urandom
  * fix for bug in log_time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
   [ $? -eq 0 -a -f "${topd}/setup.py" ] || return
13
13
   ROOT_DIR="$topd"
14
14
}
 
15
fail() { echo "$0:" "$@" 1>&2; exit 1; }
15
16
 
16
17
if ! find_root; then
17
 
    echo "Unable to locate 'setup.py' file that should" \
18
 
          "exist in the cloud-init root directory." 1>&2
19
 
    exit 1;
 
18
    fail "Unable to locate 'setup.py' file that should " \
 
19
         "exist in the cloud-init root directory."
20
20
fi
21
21
 
22
22
CHNG_LOG="$ROOT_DIR/ChangeLog"
23
23
 
24
 
if [ ! -e "$CHNG_LOG" ]
25
 
then
26
 
    echo "Unable to find 'ChangeLog' file located at $CHNG_LOG"
27
 
    exit 1
 
24
if [ ! -e "$CHNG_LOG" ]; then
 
25
    fail "Unable to find 'ChangeLog' file located at '$CHNG_LOG'"
28
26
fi
29
27
 
30
 
VERSION=$(grep -P "\d+.\d+.\d+:" "$CHNG_LOG"  | cut -f1 -d ":" | head -n 1)
 
28
VERSION=$(sed -n '/^[0-9]\+[.][0-9]\+[.][0-9]\+:/ {s/://; p; :a;n; ba; }' \
 
29
          "$CHNG_LOG") &&
 
30
   [ -n "$VERSION" ] ||
 
31
   fail "failed to get version from '$CHNG_LOG'"
31
32
echo "$VERSION"