1 |
commit: 367f271f463e16515aee0a31d59001cc4fac5008 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jul 5 15:39:47 2015 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jul 5 15:39:47 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=367f271f |
7 |
|
8 |
grs/WorldConf.py: remove decorated package.env. |
9 |
|
10 |
grs/WorldConf.py | 46 ++++++---------------------------------------- |
11 |
grsup | 4 ++-- |
12 |
2 files changed, 8 insertions(+), 42 deletions(-) |
13 |
|
14 |
diff --git a/grs/WorldConf.py b/grs/WorldConf.py |
15 |
index 481d3a3..f20609b 100644 |
16 |
--- a/grs/WorldConf.py |
17 |
+++ b/grs/WorldConf.py |
18 |
@@ -20,22 +20,11 @@ class WorldConf(): |
19 |
""" |
20 |
try: |
21 |
for (f, v) in config[s].items(): |
22 |
- # a '+' at the beginging means append to the file |
23 |
- undecorated_f = re.sub('^\+', '', f) |
24 |
- |
25 |
- filepath = os.path.join(portage_confdir, undecorated_f) |
26 |
+ filepath = os.path.join(portage_confdir, f) |
27 |
dirpath = os.path.dirname(filepath) |
28 |
os.makedirs(dirpath, mode=0o755, exist_ok=True) |
29 |
- if f == undecorated_f or not os.path.exists(filepath): |
30 |
- with open(filepath, 'w') as g: |
31 |
- g.write('%s\n' % v) |
32 |
- else: |
33 |
- with open(filepath, 'r+') as g: |
34 |
- for l in g.readlines(): |
35 |
- if v == l.strip(): |
36 |
- break |
37 |
- else: |
38 |
- g.write('%s\n' % v) |
39 |
+ with open(filepath, 'w') as g: |
40 |
+ g.write('%s\n' % v) |
41 |
except KeyError: |
42 |
pass |
43 |
|
44 |
@@ -78,39 +67,16 @@ class WorldConf(): |
45 |
slot = slotvar |
46 |
slot_atoms.append(re.sub('[/:]', '_', '%s:%s' % (p, slot))) |
47 |
|
48 |
- env_slot_atoms = [] |
49 |
for dirpath, dirnames, filenames in os.walk(CONST.PORTAGE_CONFIGDIR): |
50 |
# Only look at select files and directories. |
51 |
# TODO: This needs to be expanded. |
52 |
- skip = True |
53 |
- for p in ['env', 'package.accept_keywords', 'package.use', 'package.mask', 'package.unmask']: |
54 |
- if os.path.basename(dirpath) == p: |
55 |
- skip = False |
56 |
- if skip: |
57 |
+ if not os.path.basename(dirpath) in ['env', 'package.env', \ |
58 |
+ 'package.accept_keywords', 'package.use', 'package.mask', \ |
59 |
+ 'package.unmask']: |
60 |
continue |
61 |
|
62 |
for f in filenames: |
63 |
fpath = os.path.realpath(os.path.join(dirpath, f)) |
64 |
if f in slot_atoms: |
65 |
os.remove(fpath) |
66 |
- if os.path.basename(dirpath) == 'env': |
67 |
- env_slot_atoms.append(f) |
68 |
continue |
69 |
- |
70 |
- fpath = os.path.join(CONST.PORTAGE_CONFIGDIR, 'package.env') |
71 |
- if os.path.isfile(fpath): |
72 |
- update = False |
73 |
- with open(fpath, 'r') as g: |
74 |
- lines = g.readlines() |
75 |
- mylines = copy.deepcopy(lines) |
76 |
- for l in lines: |
77 |
- for slot_atom in env_slot_atoms: |
78 |
- if re.search(re.escape(slot_atom), l): |
79 |
- try: |
80 |
- mylines.remove(l) |
81 |
- update = True |
82 |
- except ValueError: |
83 |
- pass |
84 |
- if update: |
85 |
- with open(fpath, 'w') as g: |
86 |
- g.writelines(mylines) |
87 |
|
88 |
diff --git a/grsup b/grsup |
89 |
index 69decfc..57029a7 100755 |
90 |
--- a/grsup |
91 |
+++ b/grsup |
92 |
@@ -18,7 +18,7 @@ from grs import WorldConf |
93 |
|
94 |
from _emerge.main import emerge_main, parse_opts |
95 |
from portage.exception import IsADirectory, ParseError, PermissionDenied |
96 |
-from portage import setting |
97 |
+from portage import settings |
98 |
|
99 |
|
100 |
def install_kernel(version = 'latest', logfile = CONST.LOGFILE): |
101 |
@@ -38,7 +38,7 @@ def install_kernel(version = 'latest', logfile = CONST.LOGFILE): |
102 |
def get_kernels(self): |
103 |
return self.kernels |
104 |
|
105 |
- baseurl = setting['PORTAGE_BINHOST'] |
106 |
+ baseurl = settings['PORTAGE_BINHOST'] |
107 |
if baseurl == '': |
108 |
print('PORTAGE_BINHOST is not set. Install kernel manually.') |
109 |
return |