Running the repoman program locally is a bit unreliable in its detection. Add a dedicated repoman.git program for people to run directly if they want. --- repoman/.repoman_not_installed | 0 repoman/bin/repoman | 10 ---------- repoman/bin/repoman.git | 37 +++++++++++++++++++++++++++++++++++++ repoman/pym/repoman/__init__.py | 4 ++-- repoman/setup.py | 10 ---------- 5 files changed, 39 insertions(+), 22 deletions(-) delete mode 100644 repoman/.repoman_not_installed create mode 100755 repoman/bin/repoman.git
diff --git a/repoman/.repoman_not_installed b/repoman/.repoman_not_installed deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/repoman/bin/repoman b/repoman/bin/repoman index 7082a968f502..66211b26bc5e 100755 --- a/repoman/bin/repoman +++ b/repoman/bin/repoman @@ -25,16 +25,6 @@ try: except KeyboardInterrupt: sys.exit(1) -from os import path as osp -here = osp.realpath(__file__) -if osp.isfile(osp.join(osp.dirname(osp.dirname(here)), ".repoman_not_installed")): - # Add the repoman subpkg - pym_path = osp.join(osp.dirname(osp.dirname(here)), "pym") - sys.path.insert(0, pym_path) - if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.dirname(here))), ".portage_not_installed")): - # Add the base portage pkg - pym_path = osp.join(osp.dirname(osp.dirname(osp.dirname(here))), "pym") - sys.path.insert(0, pym_path) import portage portage._internal_caller = True diff --git a/repoman/bin/repoman.git b/repoman/bin/repoman.git new file mode 100755 index 000000000000..67d4b17ba295 --- /dev/null +++ b/repoman/bin/repoman.git @@ -0,0 +1,37 @@ +#!/usr/bin/python -bO +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +"""Run repoman from git using local modules/scripts.""" + +from __future__ import print_function + + +import os +import sys + + +def main(argv): + """The main entry point""" + source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + + # Add the repoman source root. + pympath = os.path.join(source_root, 'pym') + pythonpath = os.environ.get('PYTHONPATH') + if pythonpath is None: + pythonpath = pympath + else: + pythonpath = pympath + ':' + pythonpath + # Add the portage source root. + pythonpath += ':' + os.path.join(os.path.dirname(source_root), 'pym') + os.environ['PYTHONPATH'] = pythonpath + + # Signal to some repoman code that we're not installed. + os.environ['REPOMAN_NOT_INSTALLED'] = 'true' + + cmd = [os.path.join(source_root, 'bin', 'repoman')] + os.execvp(cmd[0], cmd + argv) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/repoman/pym/repoman/__init__.py b/repoman/pym/repoman/__init__.py index 5f0f9f873b1b..40259e61f92a 100644 --- a/repoman/pym/repoman/__init__.py +++ b/repoman/pym/repoman/__init__.py @@ -1,6 +1,6 @@ -import os.path +import os REPOMAN_BASE_PATH = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__.rstrip("co")).split(os.sep)[:-3])) -_not_installed = os.path.isfile(os.path.join(REPOMAN_BASE_PATH, ".repoman_not_installed")) +_not_installed = os.environ.get('REPOMAN_NOT_INSTALLED') == 'true' diff --git a/repoman/setup.py b/repoman/setup.py index 47ed15574de0..930d61060baf 100755 --- a/repoman/setup.py +++ b/repoman/setup.py @@ -145,11 +145,6 @@ class x_clean(clean): print('removing %s symlink' % repr(conf_dir)) os.unlink(conf_dir) - pni_file = os.path.join(top_dir, '.repoman_not_installed') - if os.path.exists(pni_file): - print('removing %s' % repr(pni_file)) - os.unlink(pni_file) - def clean_man(self): man_dir = os.path.join(self.build_base, 'man') if os.path.exists(man_dir): @@ -350,11 +345,6 @@ class build_tests(x_build_scripts_custom): print('Symlinking %s -> %s' % (conf_dir, conf_src)) os.symlink(conf_src, conf_dir) - # create $build_lib/../.repoman_not_installed - # to enable proper paths in tests - with open(os.path.join(self.top_dir, '.repoman_not_installed'), 'w'): - pass - class test(Command): """ run tests """ -- 2.8.2