summaryrefslogtreecommitdiff
path: root/tools/read-version
diff options
context:
space:
mode:
Diffstat (limited to 'tools/read-version')
-rwxr-xr-xtools/read-version24
1 files changed, 14 insertions, 10 deletions
diff --git a/tools/read-version b/tools/read-version
index 690666b5..323357fe 100755
--- a/tools/read-version
+++ b/tools/read-version
@@ -2,16 +2,21 @@
set -e
-if [ -e "setup.py" ]
-then
- ROOT_DIR="$PWD"
-elif [ -e "../setup.py" ]
-then
- ROOT_DIR="$PWD/../"
-else
+find_root() {
+ local topd
+ if [ -z "${CLOUD_INIT_TOP_D}" ]; then
+ topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
+ else
+ topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
+ fi
+ [ $? -eq 0 -a -f "${topd}/setup.py" ] || return
+ ROOT_DIR="$topd"
+}
+
+if ! find_root; then
echo "Unable to locate 'setup.py' file that should" \
- "exist in the cloud-init root directory."
- exit 1
+ "exist in the cloud-init root directory." 1>&2
+ exit 1;
fi
CHNG_LOG="$ROOT_DIR/ChangeLog"
@@ -24,4 +29,3 @@ fi
VERSION=$(grep -P "\d+.\d+.\d+:" $CHNG_LOG | cut -f1 -d ":" | head -n 1)
echo $VERSION
-