1 |
commit: 4335bf979f374300ac6678765f490f92ee805ab4 |
2 |
Author: slis <lis.slawek <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Jan 21 10:48:32 2014 +0000 |
4 |
Commit: slis <lis.slawek <AT> gmail <DOT> com> |
5 |
CommitDate: Tue Jan 21 10:48:32 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4335bf97 |
7 |
|
8 |
Merged revdep-rebuild branch |
9 |
|
10 |
|
11 |
bin/{enalyze => revdep-ng} | 9 +- |
12 |
pym/gentoolkit/revdep_rebuild/analyse.py | 200 +++++++++++++++++------- |
13 |
pym/gentoolkit/revdep_rebuild/assign.py | 23 ++- |
14 |
pym/gentoolkit/revdep_rebuild/cache.py | 50 +++--- |
15 |
pym/gentoolkit/revdep_rebuild/collect.py | 33 ++-- |
16 |
pym/gentoolkit/revdep_rebuild/rebuild.py | 30 ++-- |
17 |
pym/gentoolkit/revdep_rebuild/revdep-rebuild.py | 17 ++ |
18 |
pym/gentoolkit/revdep_rebuild/runner.py | 114 ++++++++++++++ |
19 |
pym/gentoolkit/revdep_rebuild/stuff.py | 4 + |
20 |
9 files changed, 364 insertions(+), 116 deletions(-) |
21 |
|
22 |
diff --cc pym/gentoolkit/revdep_rebuild/analyse.py |
23 |
index aad8f81,e630bc9..7b17517 |
24 |
--- a/pym/gentoolkit/revdep_rebuild/analyse.py |
25 |
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py |
26 |
@@@ -19,33 -14,35 +19,39 @@@ from .cache import save_cach |
27 |
|
28 |
|
29 |
def prepare_checks(files_to_check, libraries, bits, cmd_max_args): |
30 |
- ''' Calls scanelf for all files_to_check, then returns found libraries and dependencies |
31 |
+ ''' Calls scanelf for all files_to_check, |
32 |
+ then returns found libraries and dependencies |
33 |
''' |
34 |
|
35 |
- libs = [] # libs found by scanelf |
36 |
- dependencies = [] # list of lists of files (from file_to_check) that uses |
37 |
- # library (for dependencies[id] and libs[id] => id==id) |
38 |
+ # libs found by scanelf |
39 |
+ libs = [] |
40 |
+ # list of lists of files (from file_to_check) that uses |
41 |
+ # library (for dependencies[id] and libs[id] => id==id) |
42 |
+ dependencies = [] |
43 |
- for line in scan( |
44 |
- ['-M', str(bits), '-nBF', '%F %n'], |
45 |
- files_to_check, cmd_max_args |
46 |
- ): |
47 |
+ |
48 |
- parts = line.strip().split(' ') |
49 |
- if len(parts) < 2: # no dependencies? |
50 |
+ bits = [] |
51 |
+ |
52 |
+ |
53 |
+ # from runner import ScanRunner |
54 |
+ # sr = ScanRunner(['-M', str(bits), '-nBF', '%F %n'], files_to_check, cmd_max_args) |
55 |
+ # sr.wait() |
56 |
+ |
57 |
+ for line in scan(['-M', str(bits), '-nBF', '%F %n %M'], files_to_check, cmd_max_args): |
58 |
+ #call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'): |
59 |
+ r = line.strip().split(' ') |
60 |
+ if len(r) < 2: # no dependencies? |
61 |
continue |
62 |
|
63 |
- deps = parts[1].split(',') |
64 |
- for dep in deps: |
65 |
- if dep in libs: |
66 |
- index = libs.index(dep) |
67 |
- dependencies[index].append(parts[0]) |
68 |
+ deps = r[1].split(',') |
69 |
+ for d in deps: |
70 |
+ if d in libs: |
71 |
+ i = libs.index(d) |
72 |
+ dependencies[i].append(r[0]) |
73 |
else: |
74 |
- libs.append(dep) |
75 |
- dependencies.append([parts[0],]) |
76 |
- |
77 |
+ #print d, 'bits:', r[2][8:] # 8: -> strlen('ELFCLASS') |
78 |
+ libs.append(d) |
79 |
+ dependencies.append([r[0],]) |
80 |
+ |
81 |
return (libs, dependencies) |
82 |
|
83 |
|
84 |
@@@ -122,21 -136,40 +149,40 @@@ def find_broken(found_libs, system_libr |
85 |
return broken |
86 |
|
87 |
|
88 |
+ def find_broken2(scanned_files, logger): |
89 |
+ broken_libs = {} |
90 |
+ for bits, libs in scanned_files.items(): |
91 |
+ logger.debug('Checking for bits: %s' % bits) |
92 |
+ alllibs = '|'.join(libs.keys()) + '|' |
93 |
+ for soname, needed in libs.items(): |
94 |
+ for l in needed[1]: |
95 |
+ if not l+'|' in alllibs: |
96 |
+ try: |
97 |
+ broken_libs[bits][l].add(soname) |
98 |
+ except KeyError: |
99 |
+ try: |
100 |
+ broken_libs[bits][l] = set([soname]) |
101 |
+ except KeyError: |
102 |
+ broken_libs = {bits: {l: set([soname])}} |
103 |
+ |
104 |
+ return broken_libs |
105 |
+ |
106 |
+ |
107 |
-def main_checks(found_libs, broken, dependencies, logger): |
108 |
+def main_checks(found_libs, broken_list, dependencies, logger): |
109 |
''' Checks for broken dependencies. |
110 |
found_libs have to be the same as returned by prepare_checks |
111 |
- broken is list of libraries found by scanelf |
112 |
+ broken_list is list of libraries found by scanelf |
113 |
dependencies is the value returned by prepare_checks |
114 |
''' |
115 |
|
116 |
broken_pathes = [] |
117 |
|
118 |
- for b in broken: |
119 |
- f = found_libs[b] |
120 |
+ for broken in broken_list: |
121 |
+ found = found_libs[broken] |
122 |
- logger.info('Broken files that requires: ' + bold(found)) |
123 |
+ logger.info('Broken files that requires: ' + bold(f)) |
124 |
- for d in dependencies[b]: |
125 |
- logger.info(yellow(' * ') + d) |
126 |
- broken_pathes.append(d) |
127 |
+ for dep_path in dependencies[broken]: |
128 |
+ logger.info(yellow(' * ') + dep_path) |
129 |
+ broken_pathes.append(dep_path) |
130 |
return broken_pathes |
131 |
|
132 |
|
133 |
@@@ -152,31 -197,20 +210,32 @@@ def analyse(settings, logger, libraries |
134 |
""" |
135 |
|
136 |
if libraries and la_libraries and libraries_links and binaries: |
137 |
- logger.info(blue(' * ') + bold('Found a valid cache, skipping collecting phase')) |
138 |
+ logger.info(blue(' * ') + |
139 |
+ bold('Found a valid cache, skipping collecting phase')) |
140 |
else: |
141 |
- #TODO: add partial cache (for ex. only libraries) when found for some reason |
142 |
+ #TODO: add partial cache (for ex. only libraries) |
143 |
+ # when found for some reason |
144 |
|
145 |
- logger.warn(green(' * ') + bold('Collecting system binaries and libraries')) |
146 |
+ logger.warn(green(' * ') + |
147 |
+ bold('Collecting system binaries and libraries')) |
148 |
bin_dirs, lib_dirs = prepare_search_dirs(logger, settings) |
149 |
|
150 |
- masked_dirs, masked_files, ld = parse_revdep_config(settings['REVDEP_CONFDIR']) |
151 |
+ masked_dirs, masked_files, ld = \ |
152 |
+ parse_revdep_config(settings['REVDEP_CONFDIR']) |
153 |
- lib_dirs.update(ld) |
154 |
- bin_dirs.update(ld) |
155 |
- masked_dirs.update([ |
156 |
- '/lib/modules', |
157 |
- '/lib32/modules', |
158 |
- '/lib64/modules' |
159 |
- ] |
160 |
- ) |
161 |
+ lib_dirs = lib_dirs.union(ld) |
162 |
+ bin_dirs = bin_dirs.union(ld) |
163 |
- masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',])) |
164 |
- |
165 |
- logger.info(green(' * ') + bold('Collecting dynamic linking informations')) |
166 |
- libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logger) |
167 |
++ masked_dirs = masked_dirs.union( |
168 |
++ set([ |
169 |
++ '/lib/modules', |
170 |
++ '/lib32/modules', |
171 |
++ '/lib64/modules', |
172 |
++ ]) |
173 |
++ ) |
174 |
+ |
175 |
+ logger.info(green(' * ') + |
176 |
+ bold('Collecting dynamic linking informations')) |
177 |
+ libraries, la_libraries, libraries_links, symlink_pairs = \ |
178 |
+ collect_libraries_from_dir(lib_dirs, masked_dirs, logger) |
179 |
binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger) |
180 |
|
181 |
if settings['USE_TMP_FILES']: |
182 |
@@@ -188,56 -222,75 +247,79 @@@ |
183 |
) |
184 |
|
185 |
|
186 |
- logger.debug('Found '+ str(len(libraries)) + |
187 |
- ' libraries (+' + str(len(libraries_links)) + |
188 |
- ' symlinks) and ' + str(len(binaries)) + |
189 |
- ' binaries') |
190 |
- logger.debug('Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries') |
191 |
++ logger.debug('Found %i libraries (+%i symlinks) and %i binaries' % |
192 |
++ (len(libraries), len(libraries_links), len(binaries)) |
193 |
++ ) |
194 |
+ logger.info(green(' * ') + bold('Scanning files')) |
195 |
+ |
196 |
+ libs_and_bins = libraries+binaries |
197 |
|
198 |
+ scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS']) |
199 |
+ |
200 |
logger.warn(green(' * ') + bold('Checking dynamic linking consistency')) |
201 |
- logger.debug('Search for ' + str(len(binaries)+len(libraries)) + |
202 |
- ' within ' + str(len(libraries)+len(libraries_links))) |
203 |
- libs_and_bins = libraries+binaries |
204 |
- logger.debug('Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links))) |
205 |
++ logger.debug('Search for %i within %i' % |
206 |
++ (len(binaries)+len(libraries), len(libraries)+len(libraries_links)) |
207 |
++ ) |
208 |
+ |
209 |
+ broken = find_broken2(scanned_files, logger) |
210 |
+ broken_pathes = main_checks2(broken, scanned_files, logger) |
211 |
+ |
212 |
+ broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check, logger) |
213 |
+ broken_pathes += broken_la |
214 |
|
215 |
- found_libs = [] |
216 |
- dependencies = [] |
217 |
+ logger.warn(green(' * ') + bold('Assign files to packages')) |
218 |
+ |
219 |
+ return assign_packages(broken_pathes, logger, settings) |
220 |
|
221 |
- if _libs_to_check: |
222 |
- nltc = [] |
223 |
- for ltc in _libs_to_check: |
224 |
- if os.path.isfile(ltc): |
225 |
- ltc = scan(['-nBSF', '%S'], [ltc,], settings['CMD_MAX_ARGS'])[0].split()[0] |
226 |
- nltc += [ltc,] |
227 |
- _libs_to_check = nltc |
228 |
+ import sys |
229 |
+ sys.exit() |
230 |
+ |
231 |
+ #l = [] |
232 |
+ #for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'): |
233 |
+ #l.append(line) |
234 |
+ #libraries = l |
235 |
|
236 |
- _bits, linkg = platform.architecture() |
237 |
- if _bits.startswith('32'): |
238 |
- bits = 32 |
239 |
- elif _bits.startswith('64'): |
240 |
- bits = 64 |
241 |
+ ## old version from here |
242 |
+ #found_libs = [] |
243 |
+ #dependencies = [] |
244 |
|
245 |
- broken = [] |
246 |
- for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',): |
247 |
- bits = int(av_bits[4:]) |
248 |
+ #if _libs_to_check: |
249 |
+ #nltc = [] |
250 |
+ #for ltc in _libs_to_check: |
251 |
+ #if os.path.isfile(ltc): |
252 |
+ #ltc = scan(['-nBSF', '%S'], [ltc,], settings['CMD_MAX_ARGS'])[0].split()[0] |
253 |
+ #nltc += [ltc,] |
254 |
+ #_libs_to_check = nltc |
255 |
|
256 |
- _libraries = libraries+libraries_links |
257 |
+ #_bits, linkg = platform.architecture() |
258 |
+ #if _bits.startswith('32'): |
259 |
+ #bits = 32 |
260 |
+ #elif _bits.startswith('64'): |
261 |
+ #bits = 64 |
262 |
|
263 |
- found_libs, dependencies = prepare_checks(libs_and_bins, |
264 |
- _libraries, bits, settings['CMD_MAX_ARGS']) |
265 |
- broken = find_broken(found_libs, _libraries, _libs_to_check) |
266 |
+ #import time |
267 |
+ #broken = [] |
268 |
+ #for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',): |
269 |
+ #bits = int(av_bits[4:]) |
270 |
|
271 |
- bits /= 2 |
272 |
- bits = int(bits) |
273 |
+ ##_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, settings['CMD_MAX_ARGS']) |
274 |
+ #_libraries = libraries+libraries_links |
275 |
|
276 |
- broken_la = extract_dependencies_from_la(la_libraries, |
277 |
- libraries+libraries_links, _libs_to_check, logger) |
278 |
+ #found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits, settings['CMD_MAX_ARGS']) |
279 |
+ #broken = find_broken(found_libs, _libraries, _libs_to_check) |
280 |
|
281 |
+ #bits /= 2 |
282 |
+ #bits = int(bits) |
283 |
|
284 |
- broken_pathes = main_checks(found_libs, broken, dependencies, logger) |
285 |
- broken_pathes += broken_la |
286 |
+ #broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check, logger) |
287 |
|
288 |
- logger.warn(green(' * ') + bold('Assign files to packages')) |
289 |
|
290 |
- return assign_packages(broken_pathes, logger, settings) |
291 |
+ #broken_pathes = main_checks(found_libs, broken, dependencies, logger) |
292 |
+ #broken_pathes += broken_la |
293 |
+ |
294 |
+ #logger.warn(green(' * ') + bold('Assign files to packages')) |
295 |
+ |
296 |
+ #return assign_packages(broken_pathes, logger, settings) |
297 |
|
298 |
|
299 |
|
300 |
diff --cc pym/gentoolkit/revdep_rebuild/assign.py |
301 |
index e8e87b3,bb9ec1f..2a93fe1 |
302 |
--- a/pym/gentoolkit/revdep_rebuild/assign.py |
303 |
+++ b/pym/gentoolkit/revdep_rebuild/assign.py |
304 |
@@@ -27,34 -13,26 +27,49 @@@ def assign_packages(broken, logger, set |
305 |
Broken is list of files |
306 |
''' |
307 |
assigned = set() |
308 |
- if not broken: |
309 |
- return assigned |
310 |
+ for group in os.listdir(settings['PKG_DIR']): |
311 |
+ for pkg in os.listdir(settings['PKG_DIR'] + group): |
312 |
+ f = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS' |
313 |
+ if os.path.exists(f): |
314 |
+ try: |
315 |
+ with open(f, 'r') as cnt: |
316 |
+ for line in cnt.readlines(): |
317 |
+ m = re.match('^obj (/[^ ]+)', line) |
318 |
+ if m is not None: |
319 |
+ m = m.group(1) |
320 |
+ if m in broken: |
321 |
+ found = group+'/'+pkg |
322 |
+ if found not in assigned: |
323 |
+ assigned.add(found) |
324 |
+ logger.info('\t' + m + ' -> ' + bold(found)) |
325 |
+ except Exception as e: |
326 |
+ logger.warn(red(' !! Failed to read ' + f)) |
327 |
|
328 |
- pkgset = set(get_installed_cpvs()) |
329 |
+ return assigned |
330 |
|
331 |
+ # Map all files in CONTENTS database to package names |
332 |
+ fname_pkg_dict = {} |
333 |
+ for pkg in pkgset: |
334 |
+ contents = Package(pkg).parsed_contents() |
335 |
+ for fname in contents.keys(): |
336 |
+ if contents[fname][0] == "obj": |
337 |
+ fname_pkg_dict[fname] = str(pkg) |
338 |
+ |
339 |
+ for fname in broken: |
340 |
+ realname = os.path.realpath(fname) |
341 |
+ if realname in fname_pkg_dict.keys(): |
342 |
+ pkgname = fname_pkg_dict[realname] |
343 |
+ elif fname in fname_pkg_dict.keys(): |
344 |
+ pkgname = fname_pkg_dict[fname] |
345 |
+ else: |
346 |
+ pkgname = None |
347 |
+ if pkgname and pkgname not in assigned: |
348 |
+ assigned.add(pkgname) |
349 |
+ if not pkgname: |
350 |
+ pkgname = "(none)" |
351 |
+ logger.info('\t' + fname + ' -> ' + bold(pkgname)) |
352 |
+ |
353 |
+ return assigned |
354 |
|
355 |
def get_best_match(cpv, cp, logger): |
356 |
"""Tries to find another version of the pkg with the same slot |
357 |
diff --cc pym/gentoolkit/revdep_rebuild/cache.py |
358 |
index d6ef7ce,8b1a8ed..1be8cb0 |
359 |
--- a/pym/gentoolkit/revdep_rebuild/cache.py |
360 |
+++ b/pym/gentoolkit/revdep_rebuild/cache.py |
361 |
@@@ -18,54 -12,42 +18,50 @@@ def read_cache(temp_path=DEFAULTS['DEFA |
362 |
This function does not checks if files exists nor timestamps, |
363 |
check_temp_files should be called first |
364 |
@param temp_path: directory where all temp files should reside |
365 |
- @return tuple with values of: libraries, la_libraries, libraries_links, symlink_pairs, binaries |
366 |
+ @return tuple with values of: |
367 |
+ libraries, la_libraries, libraries_links, symlink_pairs, binaries |
368 |
''' |
369 |
|
370 |
- ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]} |
371 |
+ ret = { |
372 |
+ 'libraries':[], |
373 |
+ 'la_libraries':[], |
374 |
+ 'libraries_links':[], |
375 |
+ 'binaries':[] |
376 |
+ } |
377 |
try: |
378 |
- for key, val in list(ret.items()): |
379 |
- _file = open(os.path.join(temp_path, key)) |
380 |
- for line in _file .readlines(): |
381 |
+ for key,val in ret.iteritems(): |
382 |
- f = open(os.path.join(temp_path, key)) |
383 |
- for line in f.readlines(): |
384 |
++ _file = open(os.path.join(temp_path, key)) |
385 |
++ for line in _file.readlines(): |
386 |
val.append(line.strip()) |
387 |
#libraries.remove('\n') |
388 |
- f.close() |
389 |
+ _file .close() |
390 |
except EnvironmentError: |
391 |
pass |
392 |
|
393 |
- return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries']) |
394 |
+ return (ret['libraries'], ret['la_libraries'], |
395 |
+ ret['libraries_links'], ret['binaries']) |
396 |
|
397 |
|
398 |
- def save_cache(logger, to_save=None, temp_path=DEFAULTS['DEFAULT_TMP_DIR']): |
399 |
+ def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']): |
400 |
''' Tries to store caching information. |
401 |
@param logger |
402 |
- @param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries |
403 |
+ @param to_save have to be dict with keys: |
404 |
+ libraries, la_libraries, libraries_links and binaries |
405 |
''' |
406 |
|
407 |
- if to_save is None: |
408 |
- to_save = {} |
409 |
- |
410 |
- # TODO: Don't blindly make the cache directory, see Bug 203414 |
411 |
- # if not os.path.exists(temp_path): |
412 |
- # os.makedirs(temp_path) |
413 |
+ if not os.path.exists(temp_path): |
414 |
+ os.makedirs(temp_path) |
415 |
|
416 |
try: |
417 |
- f = open(os.path.join(temp_path, 'timestamp'), 'w') |
418 |
- f.write(str(int(time.time()))) |
419 |
- f.close() |
420 |
+ _file = open(os.path.join(temp_path, 'timestamp'), 'w') |
421 |
+ _file.write(str(int(time.time()))) |
422 |
+ _file.close() |
423 |
|
424 |
- for key, val in list(to_save.items()): |
425 |
+ for key,val in to_save.iteritems(): |
426 |
- f = open(os.path.join(temp_path, key), 'w') |
427 |
+ _file = open(os.path.join(temp_path, key), 'w') |
428 |
for line in val: |
429 |
- f.write(line + '\n') |
430 |
- f.close() |
431 |
+ _file.write(line + '\n') |
432 |
+ _file.close() |
433 |
except Exception as ex: |
434 |
logger.warn(red('Could not save cache: %s' %str(ex))) |
435 |
|
436 |
@@@ -106,31 -84,23 +101,30 @@@ def check_temp_files(temp_path=DEFAULTS |
437 |
|
438 |
|
439 |
if __name__ == '__main__': |
440 |
- print 'Preparing cache ... ' |
441 |
+ print('Preparing cache ... ') |
442 |
|
443 |
- from collect import * |
444 |
+ from .collect import (prepare_search_dirs, parse_revdep_config, |
445 |
+ collect_libraries_from_dir, collect_binaries_from_dir) |
446 |
- |
447 |
import logging |
448 |
|
449 |
- bin_dirs, lib_dirs = prepare_search_dirs(logging, DEFAULTS) |
450 |
+ bin_dirs, lib_dirs = prepare_search_dirs() |
451 |
|
452 |
- masked_dirs, masked_files, ld = parse_revdep_config("/etc/revdep-rebuild/") |
453 |
- lib_dirs.update(ld) |
454 |
- bin_dirs.update(ld) |
455 |
- masked_dirs = masked_dirs.update([ |
456 |
- '/lib/modules', |
457 |
- '/lib32/modules', |
458 |
- '/lib64/modules' |
459 |
- ] |
460 |
- ) |
461 |
+ masked_dirs, masked_files, ld = parse_revdep_config() |
462 |
+ lib_dirs = lib_dirs.union(ld) |
463 |
+ bin_dirs = bin_dirs.union(ld) |
464 |
- masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',])) |
465 |
++ masked_dirs = masked_dirs.union( |
466 |
++ set([ |
467 |
++ '/lib/modules', |
468 |
++ '/lib32/modules', |
469 |
++ '/lib64/modules', |
470 |
++ ]) |
471 |
++ ) |
472 |
|
473 |
- libraries, la_libraries, libraries_links, symlink_pairs = \ |
474 |
- collect_libraries_from_dir(lib_dirs, masked_dirs, logging) |
475 |
+ libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging) |
476 |
binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging) |
477 |
|
478 |
- save_cache(logger=logging, |
479 |
- to_save={'libraries':libraries, 'la_libraries':la_libraries, |
480 |
+ save_cache(logger=logging, |
481 |
+ to_save={'libraries':libraries, 'la_libraries':la_libraries, |
482 |
'libraries_links':libraries_links, 'binaries':binaries} |
483 |
) |
484 |
|
485 |
diff --cc pym/gentoolkit/revdep_rebuild/collect.py |
486 |
index 740ae32,b7ed469..f8ee60d |
487 |
--- a/pym/gentoolkit/revdep_rebuild/collect.py |
488 |
+++ b/pym/gentoolkit/revdep_rebuild/collect.py |
489 |
@@@ -26,8 -22,8 +26,8 @@@ def parse_conf(conf_file, visited=None |
490 |
|
491 |
for conf in conf_file: |
492 |
try: |
493 |
- with open(conf) as f: |
494 |
- for line in f.readlines(): |
495 |
+ with open(conf) as _file: |
496 |
- for line in _file: |
497 |
++ for line in _file.readlines(): |
498 |
line = line.strip() |
499 |
if line.startswith('#'): |
500 |
continue |
501 |
@@@ -66,13 -62,12 +66,13 @@@ def prepare_search_dirs(logger, setting |
502 |
lib_dirs = set(['/lib', '/usr/lib', ]) |
503 |
|
504 |
#try: |
505 |
- with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r') as f: |
506 |
- for line in f.readlines(): |
507 |
+ with open(os.path.join( |
508 |
+ portage.root, settings['DEFAULT_ENV_FILE']), 'r') as _file: |
509 |
- for line in _file: |
510 |
++ for line in _file.readlines(): |
511 |
line = line.strip() |
512 |
- m = re.match("^export (ROOT)?PATH='([^']+)'", line) |
513 |
- if m is not None: |
514 |
- bin_dirs = bin_dirs.union(set(m.group(2).split(':'))) |
515 |
+ match = re.match("^export (ROOT)?PATH='([^']+)'", line) |
516 |
+ if match is not None: |
517 |
+ bin_dirs.update(set(match.group(2).split(':'))) |
518 |
#except EnvironmentError: |
519 |
#logger.debug(yellow('Could not open file %s' % f)) |
520 |
|
521 |
@@@ -250,21 -230,17 +250,26 @@@ def collect_binaries_from_dir(dirs, mas |
522 |
|
523 |
if __name__ == '__main__': |
524 |
import logging |
525 |
- from .settings import DEFAULTS |
526 |
- mbin_dirs, mlib_dirs = prepare_search_dirs(logging, DEFAULTS) |
527 |
- |
528 |
- mmasked_dirs, mmasked_files, mld = parse_revdep_config("/etc/revdep-rebuild/") |
529 |
- mlib_dirs.update(mld) |
530 |
- mbin_dirs.update(mld) |
531 |
- mmasked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules']) |
532 |
+ bin_dirs, lib_dirs = prepare_search_dirs(logging) |
533 |
+ |
534 |
+ masked_dirs, masked_files, ld = parse_revdep_config() |
535 |
+ lib_dirs = lib_dirs.union(ld) |
536 |
+ bin_dirs = bin_dirs.union(ld) |
537 |
- masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',])) |
538 |
- |
539 |
- libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging) |
540 |
- binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging) |
541 |
- |
542 |
- logging.debug('Found: %i binaries and %i libraries.' %(len(binaries), len(libraries))) |
543 |
++ masked_dirs = masked_dirs.union( |
544 |
++ set([ |
545 |
++ '/lib/modules', |
546 |
++ '/lib32/modules', |
547 |
++ '/lib64/modules', |
548 |
++ ]) |
549 |
++ ) |
550 |
+ |
551 |
+ libraries, la_libraries, libraries_links, msymlink_pairs = \ |
552 |
+ collect_libraries_from_dir(mlib_dirs, mmasked_dirs, logging) |
553 |
+ binaries = collect_binaries_from_dir(mbin_dirs, mmasked_dirs, logging) |
554 |
+ |
555 |
+ logging.debug( |
556 |
+ 'Found: %i binaries and %i libraries.' %( |
557 |
+ len(binaries), len(libraries))) |
558 |
|
559 |
|
560 |
|
561 |
diff --cc pym/gentoolkit/revdep_rebuild/rebuild.py |
562 |
index 8d21b76,a943902..386ac33 |
563 |
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py |
564 |
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py |
565 |
@@@ -103,10 -103,10 +103,11 @@@ def parse_options() |
566 |
'keep-temp', 'library=', 'no-ld-path', 'no-order', |
567 |
'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose']) |
568 |
|
569 |
+ do_help = False |
570 |
for key, val in opts: |
571 |
if key in ('-h', '--help'): |
572 |
- do_help = True |
573 |
+ print_usage() |
574 |
+ sys.exit(0) |
575 |
elif key in ('-q', '--quiet'): |
576 |
settings['quiet'] = True |
577 |
settings['VERBOSITY'] = 0 |
578 |
@@@ -134,9 -134,6 +135,7 @@@ |
579 |
print(red('Unrecognized option\n')) |
580 |
print_usage() |
581 |
sys.exit(2) |
582 |
- if do_help: |
583 |
- print_usage() |
584 |
- sys.exit(0) |
585 |
++ |
586 |
return settings |
587 |
|
588 |
|
589 |
@@@ -195,25 -181,25 +194,33 @@@ def main(settings=None, logger=None) |
590 |
if not settings['stdout'].isatty() or settings['nocolor']: |
591 |
nocolor() |
592 |
|
593 |
+ #TODO: Development warning |
594 |
+ logger.warn(blue(' * ') + |
595 |
+ yellow('This is a development version, ' |
596 |
+ 'so it may not work correctly')) |
597 |
+ logger.warn(blue(' * ') + |
598 |
+ yellow('The original revdep-rebuild script is ' |
599 |
+ 'installed as revdep-rebuild.sh')) |
600 |
+ |
601 |
if os.getuid() != 0 and not settings['PRETEND']: |
602 |
- logger.warn(blue(' * ') + |
603 |
+ logger.warn(blue(' * ') + |
604 |
yellow('You are not root, adding --pretend to portage options')) |
605 |
settings['PRETEND'] = True |
606 |
+ elif not settings['PRETEND'] \ |
607 |
+ and settings['IS_DEV'] \ |
608 |
+ and not settings['NO_PRETEND']: |
609 |
+ logger.warn(blue(' * ') + |
610 |
+ yellow('This is a development version, ' |
611 |
+ 'so it may not work correctly')) |
612 |
+ logger.warn(blue(' * ') + |
613 |
+ yellow('Adding --pretend to portage options anyway')) |
614 |
+ logger.info(blue(' * ') + |
615 |
+ 'If you\'re sure, you can add --no-pretend to revdep options') |
616 |
+ settings['PRETEND'] = True |
617 |
|
618 |
- if settings['library']: |
619 |
- logger.warn(green(' * ') + |
620 |
- "Looking for libraries: %s" % (bold(', '.join(settings['library'])))) |
621 |
- |
622 |
+ analyze_cache = {} |
623 |
if settings['USE_TMP_FILES'] \ |
624 |
- and check_temp_files(settings['DEFAULT_TMP_DIR'], logger=logger): |
625 |
+ and check_temp_files(settings['DEFAULT_TMP_DIR']): |
626 |
libraries, la_libraries, libraries_links, binaries = read_cache( |
627 |
settings['DEFAULT_TMP_DIR']) |
628 |
assigned = analyse( |
629 |
diff --cc pym/gentoolkit/revdep_rebuild/stuff.py |
630 |
index e78748c,7b287b1..0bebce2 |
631 |
--- a/pym/gentoolkit/revdep_rebuild/stuff.py |
632 |
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py |
633 |
@@@ -43,12 -31,11 +43,16 @@@ def scan(params, files, max_args) |
634 |
return out |
635 |
|
636 |
|
637 |
+ def exithandler(signum, frame): |
638 |
+ sys.exit(1) |
639 |
+ |
640 |
+ |
641 |
def get_masking_status(ebuild): |
642 |
+ """returns the masking status of an ebuild |
643 |
+ |
644 |
+ @param ebuild: str |
645 |
+ @return list |
646 |
+ """ |
647 |
try: |
648 |
status = portage.getmaskingstatus(ebuild) |
649 |
except KeyError: |