Gentoo Archives: gentoo-portage-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH] repoman: simplify wrapper for running locally
Date: Mon, 13 Jun 2016 04:36:09
Message-Id: 1465792562-18658-1-git-send-email-vapier@gentoo.org
1 Running the repoman program locally is a bit unreliable in its
2 detection. Add a dedicated repoman.git program for people to
3 run directly if they want.
4 ---
5 repoman/.repoman_not_installed | 0
6 repoman/bin/repoman | 10 ----------
7 repoman/bin/repoman.git | 37 +++++++++++++++++++++++++++++++++++++
8 repoman/pym/repoman/__init__.py | 4 ++--
9 repoman/setup.py | 10 ----------
10 5 files changed, 39 insertions(+), 22 deletions(-)
11 delete mode 100644 repoman/.repoman_not_installed
12 create mode 100755 repoman/bin/repoman.git
13
14 diff --git a/repoman/.repoman_not_installed b/repoman/.repoman_not_installed
15 deleted file mode 100644
16 index e69de29bb2d1..000000000000
17 diff --git a/repoman/bin/repoman b/repoman/bin/repoman
18 index 7082a968f502..66211b26bc5e 100755
19 --- a/repoman/bin/repoman
20 +++ b/repoman/bin/repoman
21 @@ -25,16 +25,6 @@ try:
22 except KeyboardInterrupt:
23 sys.exit(1)
24
25 -from os import path as osp
26 -here = osp.realpath(__file__)
27 -if osp.isfile(osp.join(osp.dirname(osp.dirname(here)), ".repoman_not_installed")):
28 - # Add the repoman subpkg
29 - pym_path = osp.join(osp.dirname(osp.dirname(here)), "pym")
30 - sys.path.insert(0, pym_path)
31 - if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.dirname(here))), ".portage_not_installed")):
32 - # Add the base portage pkg
33 - pym_path = osp.join(osp.dirname(osp.dirname(osp.dirname(here))), "pym")
34 - sys.path.insert(0, pym_path)
35
36 import portage
37 portage._internal_caller = True
38 diff --git a/repoman/bin/repoman.git b/repoman/bin/repoman.git
39 new file mode 100755
40 index 000000000000..67d4b17ba295
41 --- /dev/null
42 +++ b/repoman/bin/repoman.git
43 @@ -0,0 +1,37 @@
44 +#!/usr/bin/python -bO
45 +# Copyright 1999-2016 Gentoo Foundation
46 +# Distributed under the terms of the GNU General Public License v2
47 +
48 +"""Run repoman from git using local modules/scripts."""
49 +
50 +from __future__ import print_function
51 +
52 +
53 +import os
54 +import sys
55 +
56 +
57 +def main(argv):
58 + """The main entry point"""
59 + source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
60 +
61 + # Add the repoman source root.
62 + pympath = os.path.join(source_root, 'pym')
63 + pythonpath = os.environ.get('PYTHONPATH')
64 + if pythonpath is None:
65 + pythonpath = pympath
66 + else:
67 + pythonpath = pympath + ':' + pythonpath
68 + # Add the portage source root.
69 + pythonpath += ':' + os.path.join(os.path.dirname(source_root), 'pym')
70 + os.environ['PYTHONPATH'] = pythonpath
71 +
72 + # Signal to some repoman code that we're not installed.
73 + os.environ['REPOMAN_NOT_INSTALLED'] = 'true'
74 +
75 + cmd = [os.path.join(source_root, 'bin', 'repoman')]
76 + os.execvp(cmd[0], cmd + argv)
77 +
78 +
79 +if __name__ == '__main__':
80 + main(sys.argv[1:])
81 diff --git a/repoman/pym/repoman/__init__.py b/repoman/pym/repoman/__init__.py
82 index 5f0f9f873b1b..40259e61f92a 100644
83 --- a/repoman/pym/repoman/__init__.py
84 +++ b/repoman/pym/repoman/__init__.py
85 @@ -1,6 +1,6 @@
86
87 -import os.path
88 +import os
89
90 REPOMAN_BASE_PATH = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__.rstrip("co")).split(os.sep)[:-3]))
91
92 -_not_installed = os.path.isfile(os.path.join(REPOMAN_BASE_PATH, ".repoman_not_installed"))
93 +_not_installed = os.environ.get('REPOMAN_NOT_INSTALLED') == 'true'
94 diff --git a/repoman/setup.py b/repoman/setup.py
95 index 47ed15574de0..930d61060baf 100755
96 --- a/repoman/setup.py
97 +++ b/repoman/setup.py
98 @@ -145,11 +145,6 @@ class x_clean(clean):
99 print('removing %s symlink' % repr(conf_dir))
100 os.unlink(conf_dir)
101
102 - pni_file = os.path.join(top_dir, '.repoman_not_installed')
103 - if os.path.exists(pni_file):
104 - print('removing %s' % repr(pni_file))
105 - os.unlink(pni_file)
106 -
107 def clean_man(self):
108 man_dir = os.path.join(self.build_base, 'man')
109 if os.path.exists(man_dir):
110 @@ -350,11 +345,6 @@ class build_tests(x_build_scripts_custom):
111 print('Symlinking %s -> %s' % (conf_dir, conf_src))
112 os.symlink(conf_src, conf_dir)
113
114 - # create $build_lib/../.repoman_not_installed
115 - # to enable proper paths in tests
116 - with open(os.path.join(self.top_dir, '.repoman_not_installed'), 'w'):
117 - pass
118 -
119
120 class test(Command):
121 """ run tests """
122 --
123 2.8.2