7
if [ -z "${CLOUD_INIT_TOP_D}" ]; then
8
topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
10
topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
12
[ $? -eq 0 -a -f "${topd}/setup.py" ] || return
15
fail() { echo "$0:" "$@" 1>&2; exit 1; }
18
fail "Unable to locate 'setup.py' file that should " \
19
"exist in the cloud-init root directory."
22
CHNG_LOG="$ROOT_DIR/ChangeLog"
24
if [ ! -e "$CHNG_LOG" ]; then
25
fail "Unable to find 'ChangeLog' file located at '$CHNG_LOG'"
28
VERSION=$(sed -n '/^[0-9]\+[.][0-9]\+[.][0-9]\+:/ {s/://; p; :a;n; ba; }' \
31
fail "failed to get version from '$CHNG_LOG'"
7
if 'CLOUD_INIT_TOP_D' in os.environ:
8
topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))
10
topd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
12
for fname in ("setup.py", "ChangeLog"):
13
if not os.path.isfile(os.path.join(topd, fname)):
14
sys.stderr.write("Unable to locate '%s' file that should "
15
"exist in cloud-init root directory." % fname)
18
vermatch = re.compile(r"^[0-9]+[.][0-9]+[.][0-9]+:$")
20
with open(os.path.join(topd, "ChangeLog"), "r") as fp:
22
if vermatch.match(line):
23
sys.stdout.write(line.strip()[:-1] + "\n")