diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-09 15:36:16 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-07-09 15:36:16 -0400 |
commit | 7cd3e340264365c2e968b72cce78db9ff74b24a7 (patch) | |
tree | 4a7872cde84ca0d29e7e163f768aed564a8fa208 /tools/read-dependencies | |
parent | 492dc7478e0ab3eb03eb3b0b5d0e47812339b83f (diff) | |
parent | c7aeea86fb8a17e4402cfc42626dfff2fb04c1a0 (diff) | |
download | vyos-cloud-init-7cd3e340264365c2e968b72cce78db9ff74b24a7.tar.gz vyos-cloud-init-7cd3e340264365c2e968b72cce78db9ff74b24a7.zip |
rework packaging tools to find the right cloud-init topdir
This also fixes 'brpm' to address --init-system change that
smoser made to setup.py before the large 'rework' merge.
Diffstat (limited to 'tools/read-dependencies')
-rwxr-xr-x | tools/read-dependencies | 80 |
1 files changed, 35 insertions, 45 deletions
diff --git a/tools/read-dependencies b/tools/read-dependencies index 72e1e095..4c88aa87 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -1,45 +1,35 @@ -#!/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 + +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" +} + +if ! find_root; then + echo "Unable to locate 'setup.py' file that should" \ + "exist in the cloud-init root directory." 1>&2 + 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 + + + |