summaryrefslogtreecommitdiff
path: root/tools/read-dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'tools/read-dependencies')
-rwxr-xr-xtools/read-dependencies75
1 files changed, 30 insertions, 45 deletions
diff --git a/tools/read-dependencies b/tools/read-dependencies
index 72e1e095..3aa6e286 100755
--- a/tools/read-dependencies
+++ b/tools/read-dependencies
@@ -1,45 +1,30 @@
-#!/usr/bin/python
-# vi: ts=4 expandtab
-
-import os
-import sys
-import re
-
-
-def parse_requires(fn):
- requires = []
- with open(fn, 'r') as fh:
- lines = fh.read().splitlines()
- for line in lines:
- line = line.strip()
- if not line or line[0] == '#':
- continue
- else:
- requires.append(line)
- return requires
-
-
-def find_requires(args):
- p_files = []
- if args:
- p_files.append(args[0])
- p_files.append(os.path.join(os.pardir, "Requires"))
- p_files.append(os.path.join(os.getcwd(), 'Requires'))
- found = None
- for fn in p_files:
- if os.path.isfile(fn):
- found = fn
- break
- return found
-
-
-if __name__ == '__main__':
- run_args = sys.argv[1:]
- fn = find_requires(run_args)
- if not fn:
- sys.stderr.write("'Requires' file not found!\n")
- sys.exit(1)
- else:
- deps = parse_requires(fn)
- for entry in deps:
- print entry
+#!/bin/sh
+
+set -e
+
+if [ -e "setup.py" ]
+then
+ ROOT_DIR="$PWD"
+elif [ -e "../setup.py" ]
+then
+ ROOT_DIR="$PWD/../"
+else
+ echo "Unable to locate 'setup.py' file that should" \
+ "exist in the cloud-init root directory."
+ exit 1
+fi
+
+REQUIRES="$ROOT_DIR/Requires"
+
+if [ ! -e "$REQUIRES" ]
+then
+ echo "Unable to find 'Requires' file located at $REQUIRES"
+ exit 1
+fi
+
+# Filter out comments and empty liens
+DEPS=$(cat $REQUIRES | grep -Pv "^\s*#" | grep -Pv '^\s*$')
+echo "$DEPS" | sort -d -f
+
+
+