summaryrefslogtreecommitdiff
path: root/packages/brpm
diff options
context:
space:
mode:
Diffstat (limited to 'packages/brpm')
-rwxr-xr-xpackages/brpm17
1 files changed, 8 insertions, 9 deletions
diff --git a/packages/brpm b/packages/brpm
index 7d0dc78f..afd7016f 100755
--- a/packages/brpm
+++ b/packages/brpm
@@ -12,15 +12,14 @@ import re
import argparse
def find_root():
- look_where = [
- os.path.join(os.getcwd(), 'setup.py'),
- os.path.join(os.pardir, 'setup.py'),
- ]
- for fn in look_where:
- if os.path.isfile(fn):
- return os.path.dirname(os.path.abspath(fn))
- raise ImportError(("Unable to determine where your cloud-init 'setup.py'"
- " file is located at!"))
+ # expected path is in <top_dir>/packages/
+ top_dir = os.environ.get("CLOUD_INIT_TOP_D", None)
+ if top_dir is None:
+ top_dir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
+ if os.path.isfile(os.path.join(top_dir, 'setup.py')):
+ return os.path.abspath(top_dir)
+ raise OSError(("Unable to determine where your cloud-init topdir is."
+ " set CLOUD_INIT_TOP_D?"))
# Use the util functions from cloudinit