summaryrefslogtreecommitdiff
path: root/tools/read-version
diff options
context:
space:
mode:
Diffstat (limited to 'tools/read-version')
-rwxr-xr-xtools/read-version16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/read-version b/tools/read-version
index c76b24a9..c37228f8 100755
--- a/tools/read-version
+++ b/tools/read-version
@@ -12,20 +12,20 @@ find_root() {
[ $? -eq 0 -a -f "${topd}/setup.py" ] || return
ROOT_DIR="$topd"
}
+fail() { echo "$0:" "$@" 1>&2; exit 1; }
if ! find_root; then
- echo "Unable to locate 'setup.py' file that should" \
- "exist in the cloud-init root directory." 1>&2
- exit 1;
+ fail "Unable to locate 'setup.py' file that should " \
+ "exist in the cloud-init root directory."
fi
CHNG_LOG="$ROOT_DIR/ChangeLog"
-if [ ! -e "$CHNG_LOG" ]
-then
- echo "Unable to find 'ChangeLog' file located at $CHNG_LOG"
- exit 1
+if [ ! -e "$CHNG_LOG" ]; then
+ fail "Unable to find 'ChangeLog' file located at '$CHNG_LOG'"
fi
-VERSION=$(grep -P "\d+.\d+.\d+:" "$CHNG_LOG" | cut -f1 -d ":" | head -n 1)
+VERSION=$(sed -n '/^[0-9]\+[.][0-9]\+[.][0-9]\+:/ {s/://; p; :a;n; ba}' \
+ "$CHNG_LOG") ||
+ fail "failed to get version from '$CHNG_LOG'"
echo "$VERSION"