summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-09-08 09:31:03 -0400
committerScott Moser <smoser@ubuntu.com>2013-09-08 09:31:03 -0400
commit0843952235072079bb66bd2fe9e96057df11c228 (patch)
tree0590a7ed11d047e48d80b226f6ca158c25ec4c80 /tools
parent1d27cd75eaaeef7b72f3be77de24da815c82a825 (diff)
downloadvyos-cloud-init-0843952235072079bb66bd2fe9e96057df11c228.tar.gz
vyos-cloud-init-0843952235072079bb66bd2fe9e96057df11c228.zip
tools/read-dependencies, read-version: cleanups, and use sed not grep
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.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/read-dependencies14
-rwxr-xr-xtools/read-version16
2 files changed, 15 insertions, 15 deletions
diff --git a/tools/read-dependencies b/tools/read-dependencies
index cadb09a8..87db5d83 100755
--- a/tools/read-dependencies
+++ b/tools/read-dependencies
@@ -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
REQUIRES="$ROOT_DIR/Requires"
if [ ! -e "$REQUIRES" ]; then
- echo "Unable to find 'Requires' file located at $REQUIRES"
- exit 1
+ fail "Unable to find 'Requires' file located at '$REQUIRES'"
fi
-# Filter out comments and empty liens
-DEPS=$(grep -Pv "^\s*#" "$REQUIRES" | grep -Pv '^\s*$')
+# Filter out comments and empty lines
+DEPS=$(sed -n -e 's,#.*,,' -e '/./p' "$REQUIRES") ||
+ fail "failed to read deps from '${REQUIRES}'"
echo "$DEPS" | sort -d -f
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"