Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/grss:master commit in: /, utils/
Date: Wed, 01 Jul 2015 21:19:24
Message-Id: 1435785694.78981c587563fc1721b9ebefe5f376355da7d4db.blueness@gentoo
1 commit: 78981c587563fc1721b9ebefe5f376355da7d4db
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 1 21:21:34 2015 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 1 21:21:34 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=78981c58
7
8 make-worldconf: approximately build world.conf from and existing system.
9
10 utils/make-worldconf => make-worldconf | 28 ++++++++++++++++++----------
11 setup.py | 2 +-
12 2 files changed, 19 insertions(+), 11 deletions(-)
13
14 diff --git a/utils/make-worldconf b/make-worldconf
15 similarity index 81%
16 rename from utils/make-worldconf
17 rename to make-worldconf
18 index 29cf5b8..5ab0b46 100755
19 --- a/utils/make-worldconf
20 +++ b/make-worldconf
21 @@ -6,45 +6,52 @@ import os
22 import re
23 import sys
24
25 +from grs import CONST
26 +
27 from _emerge.main import parse_opts
28 from _emerge.actions import load_emerge_config, create_depgraph_params
29 from _emerge.depgraph import backtrack_depgraph
30
31 -PORTAGE_CONFIGDIR = '/etc/portage'
32 -
33
34 def useflags(config, p):
35 # Get all IUSE, enabled USE and EXPAND_HIDDEN flags.
36 try:
37 iuse = list(p.iuse.all)
38 use = list(p.use.enabled)
39 - expand_hidden = list(p.use._expand_hidden)
40 + # expand = list(p.use.expand)
41 + expand_hidden = list(p.use.expand_hidden)
42 except AttributeError:
43 return
44 except TypeError:
45 return
46
47 - # Remove any EXPAND_HIDDEN flags from IUSE flags
48 + # We only include select USE_EXPAND flags. Note becaue of how we match 'abi_',
49 + # for example, will match abi_ppc, abi_mips etc. Hopefully this will not lead
50 + # to any false hits.
51 + expand = [ 'kernel_', 'elibc_', 'userland_', 'abi_', 'linguas_', 'python_' ]
52 +
53 + # Remove any selected USE_EXPAND and any EXPAND_HIDDEN flags from IUSE flags
54 my_iuse = copy.deepcopy(iuse)
55 for u in iuse:
56 - for e in expand_hidden:
57 + for e in expand + expand_hidden:
58 while re.match(e, u):
59 try:
60 my_iuse.remove(u)
61 except ValueError:
62 break
63
64 - # Remove any EXPAND_HIDDEN flags from the enabled USE flags
65 + # Remove the same flags from the enabled USE flags
66 my_use = copy.deepcopy(use)
67 for u in use:
68 - for e in expand_hidden:
69 + for e in expand + expand_hidden:
70 while re.match(e, u):
71 try:
72 my_use.remove(u)
73 except ValueError:
74 break
75
76 - # Remove the arch flag - this needs to be generalized
77 + # Remove the arch flag.
78 + # TODO: this needs to be generalized.
79 my_use.remove('amd64')
80
81 # Go through all the IUSE flags and put a - in front
82 @@ -72,6 +79,7 @@ def keywords(config, p):
83 if p.get_keyword_mask() == 'missing':
84 keyword = '**'
85 if p.get_keyword_mask() == 'unstable':
86 + # This needs to be generalized
87 keyword = '~amd64'
88 except AttributeError:
89 pass
90 @@ -82,7 +90,7 @@ def keywords(config, p):
91
92 def envvars(config, p):
93 try:
94 - fpath = os.path.join(PORTAGE_CONFIGDIR, 'package.env')
95 + fpath = os.path.join(CONST.PORTAGE_CONFIGDIR, 'package.env')
96 with open(fpath, 'r') as g:
97 for l in g.readlines():
98 # This matching needs to be made more strick.
99 @@ -90,7 +98,7 @@ def envvars(config, p):
100 config[p.slot_atom]['+package.env'] = '%s %s' % (p.slot_atom,
101 re.sub('[/:]', '_', p.slot_atom))
102 m = re.search('(\S+)\s+(\S+)', l)
103 - env_file = os.path.join(PORTAGE_CONFIGDIR, 'env')
104 + env_file = os.path.join(CONST.PORTAGE_CONFIGDIR, 'env')
105 env_file = os.path.join(env_file, m.group(2))
106 with open(env_file, 'r') as h:
107 config[p.slot_atom]['env/%s' % re.sub('[/:]', '_', p.slot_atom)] = h.read()
108
109 diff --git a/setup.py b/setup.py
110 index e5934a8..3c5f444 100755
111 --- a/setup.py
112 +++ b/setup.py
113 @@ -17,6 +17,6 @@ setup(
114 author_email = 'blueness@g.o',
115 license = 'GNU General Public License, Version 2',
116 packages = ['grs'],
117 - scripts = ['grsrun', 'grsup', 'clean-worldconf', 'install-worldconf'],
118 + scripts = ['grsrun', 'grsup', 'clean-worldconf', 'install-worldconf', 'make-worldconf'],
119 data_files = [('/etc/grs', ['systems.conf'])]
120 )