Skip to content

Commit 07cbc44

Browse files
committed
Put devstack-version info into separate file
As a follow on to I4c269a7f3d63ee9a976e7c3636fc3e5e8dab9ae3; the quoting gets tricky when putting arbitrary command-substitution strings into saved echo-able strings. As they say, "the only winning move is not to play" :) An alternative proposal is to not write this into a script but just dump info into a file. To my mind, this has several advantages -- avoid getting involved in quoting, not dropping a script into the global environment -- it's just as easy to "cat" -- and the plain-text file can be collected as an artifact during log collection (also moved git commit line to separate line for easier parsing during log search, etc). Change-Id: Ic7391dd087657c0daf74046e4a052c53f4eb6e1a
1 parent 3415521 commit 07cbc44

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

functions

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -750,19 +750,16 @@ function get_random_port {
750750
echo $port
751751
}
752752

753-
753+
# Save some state information
754+
#
755+
# Write out various useful state information to /etc/devstack-version
754756
function write_devstack_version {
755-
pushd $TOP_DIR
756-
local git_version=""
757-
git_version=$(git log --format="%H %ci" -1)
758757
cat - > /tmp/devstack-version <<EOF
759-
#!/bin/bash
760-
761-
echo "DevStack Version: ${DEVSTACK_SERIES} - ${git_version}"
762-
echo "OS Version: ${os_VENDOR} ${os_RELEASE} ${os_CODENAME}"
763-
758+
DevStack Version: ${DEVSTACK_SERIES}
759+
Change: $(git log --format="%H %s %ci" -1)
760+
OS Version: ${os_VENDOR} ${os_RELEASE} ${os_CODENAME}
764761
EOF
765-
sudo install -m 755 /tmp/devstack-version /usr/local/bin/devstack-version
762+
sudo install -m 644 /tmp/devstack-version /etc/devstack-version
766763
rm /tmp/devstack-version
767764
}
768765

stack.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ if [[ ! -r $TOP_DIR/stackrc ]]; then
216216
fi
217217
source $TOP_DIR/stackrc
218218

219-
# this installs a devstack-version script to make it easy to report the version back
219+
# write /etc/devstack-version
220220
write_devstack_version
221221

222222
# Warn users who aren't on an explicitly supported distro, but allow them to
@@ -1538,8 +1538,8 @@ if [[ "$USE_SYSTEMD" == "True" ]]; then
15381538
echo
15391539
fi
15401540

1541-
# devstack version
1542-
devstack-version
1541+
# Useful info on current state
1542+
cat /etc/devstack-version
15431543
echo
15441544

15451545
# Indicate how long this took to run (bash maintained variable ``SECONDS``)

0 commit comments

Comments
 (0)