
There are just some cleanups here, and use of simply 'sed' rather than grep and cut. The motivation is to support running with non gnu 'grep' that doesn't have -P.
32 lines
748 B
Bash
Executable File
32 lines
748 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
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"
|
|
}
|
|
fail() { echo "$0:" "$@" 1>&2; exit 1; }
|
|
|
|
if ! find_root; then
|
|
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
|
|
fail "Unable to find 'ChangeLog' file located at '$CHNG_LOG'"
|
|
fi
|
|
|
|
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"
|