repoman: Convert all portage._not_installed use to repoman._not_installed
Create REPOMAN_BASE_PATH to replace use of PORTAGE_BASE_PATH.
The repoman code can no longer rely on portage variable set according to the install state.
diff --git a/repoman/.repoman_not_installed b/repoman/.repoman_not_installed
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/repoman/.repoman_not_installed
diff --git a/repoman/bin/repoman b/repoman/bin/repoman
index 91a8d06..7082a96 100755
--- a/repoman/bin/repoman
+++ b/repoman/bin/repoman
@@ -27,13 +27,15 @@
from os import path as osp
here = osp.realpath(__file__)
-if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.dirname(here))), ".portage_not_installed")):
+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)
- # Add the base portage pkg
- pym_path = osp.join(osp.dirname(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
from repoman.main import repoman_main
diff --git a/repoman/pym/repoman/__init__.py b/repoman/pym/repoman/__init__.py
index e69de29..5f0f9f8 100644
--- a/repoman/pym/repoman/__init__.py
+++ b/repoman/pym/repoman/__init__.py
@@ -0,0 +1,6 @@
+
+import os.path
+
+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"))
diff --git a/repoman/pym/repoman/tests/__init__.py b/repoman/pym/repoman/tests/__init__.py
index af234d4..3421493 100644
--- a/repoman/pym/repoman/tests/__init__.py
+++ b/repoman/pym/repoman/tests/__init__.py
@@ -22,19 +22,19 @@
except ImportError:
unittest_skip_shims = True
+import repoman
+from repoman import REPOMAN_BASE_PATH
from repoman._portage import portage
from portage import os
from portage import _encodings
from portage import _unicode_decode
-from portage.const import (EPREFIX, GLOBAL_CONFIG_PATH, PORTAGE_BASE_PATH,
- PORTAGE_BIN_PATH)
+from portage.const import EPREFIX, GLOBAL_CONFIG_PATH, PORTAGE_BIN_PATH
-
-if portage._not_installed:
- cnf_path = os.path.join(PORTAGE_BASE_PATH, 'cnf')
+if repoman._not_installed:
+ cnf_path = os.path.join(REPOMAN_BASE_PATH, 'cnf')
cnf_etc_path = cnf_path
- cnf_bindir = os.path.join(PORTAGE_BASE_PATH, 'repoman/bin')
+ cnf_bindir = os.path.join(REPOMAN_BASE_PATH, 'bin')
cnf_sbindir = cnf_bindir
else:
cnf_path = os.path.join(EPREFIX or '/', GLOBAL_CONFIG_PATH)
diff --git a/repoman/pym/repoman/tests/simple/test_simple.py b/repoman/pym/repoman/tests/simple/test_simple.py
index ae5194f..817d124 100644
--- a/repoman/pym/repoman/tests/simple/test_simple.py
+++ b/repoman/pym/repoman/tests/simple/test_simple.py
@@ -5,18 +5,17 @@
import sys
import time
-import portage
+from repoman._portage import portage
from portage import os
from portage import _unicode_decode
from portage.const import PORTAGE_BASE_PATH, PORTAGE_PYM_PATH
from portage.process import find_binary
from portage.tests.resolver.ResolverPlayground import ResolverPlayground
from portage.util import ensure_dirs
+from repoman import REPOMAN_BASE_PATH
from repoman.copyrights import update_copyright_year
from repoman.tests import TestCase
-REPOMAN_BASE_PATH = os.path.join(PORTAGE_BASE_PATH, 'repoman')
-
class SimpleRepomanTestCase(TestCase):
diff --git a/repoman/setup.py b/repoman/setup.py
index a4726ba..47ed155 100755
--- a/repoman/setup.py
+++ b/repoman/setup.py
@@ -145,7 +145,7 @@
print('removing %s symlink' % repr(conf_dir))
os.unlink(conf_dir)
- pni_file = os.path.join(top_dir, '.portage_not_installed')
+ 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)
@@ -350,9 +350,9 @@
print('Symlinking %s -> %s' % (conf_dir, conf_src))
os.symlink(conf_src, conf_dir)
- # create $build_lib/../.portage_not_installed
+ # create $build_lib/../.repoman_not_installed
# to enable proper paths in tests
- with open(os.path.join(self.top_dir, '.portage_not_installed'), 'w'):
+ with open(os.path.join(self.top_dir, '.repoman_not_installed'), 'w'):
pass