Merge lp:~jml/pkgme-devportal/remove-ldd into lp:pkgme-devportal

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 19
Merged at revision: 21
Proposed branch: lp:~jml/pkgme-devportal/remove-ldd
Merge into: lp:pkgme-devportal
Diff against target: 128 lines (+2/-95)
2 files modified
devportalbinary/binary.py (+2/-57)
devportalbinary/tests/test_binary.py (+0/-38)
To merge this branch: bzr merge lp:~jml/pkgme-devportal/remove-ldd
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+84942@code.launchpad.net

Commit message

Remove the obsolete ldd code and tests.

Description of the change

Bug 901439 points out that the ldd tests fail on lucid. Since ldd is no longer actually used by pkgme-binary, this branch just deletes the code and the tests.

In addition, it removes the strategy pattern from get_shared_library_dependencies. Instead of taking a function that calculates libraries, it's now hard-coded to use objdump.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'devportalbinary/binary.py'
2--- devportalbinary/binary.py 2011-11-23 12:25:33 +0000
3+++ devportalbinary/binary.py 2011-12-08 13:02:26 +0000
4@@ -190,66 +190,11 @@
5 return libraries
6
7
8-def ldd(binary_paths):
9- # ldd has output of the form:
10- #
11- # path/to/elf/object:
12- # linux-vdso.so.1 => (0x00007fff4a7ff000)
13- # libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7472623000)
14- # /lib64/ld-linux-x86-64.so.2 (0x00007f74729e5000)
15- #
16- # i.e.
17- # <name> => (not found|<path> (<address>))
18- #
19- # where <name> and <path> are both optional. If <name> is not given, then
20- # there is no arrow (=>).
21- binary_paths = list(binary_paths)
22- if not binary_paths:
23- return {}
24- cmd = ['ldd'] + binary_paths
25- output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
26- libraries = {}
27- current = []
28- if len(binary_paths) == 1:
29- libraries[binary_paths[0]] = current
30- for line in output.splitlines():
31- if line.endswith(':'):
32- current.sort()
33- current = libraries[line.strip(':')] = []
34- continue
35- tokens = line.split()
36- name, path = None, None
37- if '=>' in tokens:
38- name = tokens[0]
39- if (len(tokens) > 2
40- and tokens[2:] != ['not', 'found']
41- and not (tokens[2].startswith('(')
42- and tokens[2].endswith(')'))):
43- path = tokens[2]
44- else:
45- path = tokens[0]
46- current.append((name, path))
47- current.sort()
48- return libraries
49-
50-
51-def needed_libraries_from_ldd(binary_paths):
52- # We don't consider virtual DSOs generated by the kernel, or libraries
53- # without actual names to be dependencies.
54- BLACKLIST = ['linux-vdso.so.1', 'linux-gate.so.1', None]
55- libs = ldd(binary_paths)
56- new_libs = {}
57- for path in libs:
58- new_libs[path] = [
59- name for name, path in libs[path] if name not in BLACKLIST]
60- return new_libs
61-
62-
63-def get_shared_library_dependencies(paths, library_finder=needed_libraries_from_objdump):
64+def get_shared_library_dependencies(paths):
65 """Find all of the shared libraries depended on the ELF binaries in 'paths'.
66 """
67 so_names = set()
68- libraries = library_finder(paths)
69+ libraries = needed_libraries_from_objdump(paths)
70 for libs in libraries.values():
71 for name in libs:
72 so_names.add(name)
73
74=== modified file 'devportalbinary/tests/test_binary.py'
75--- devportalbinary/tests/test_binary.py 2011-11-23 12:25:33 +0000
76+++ devportalbinary/tests/test_binary.py 2011-12-08 13:02:26 +0000
77@@ -22,7 +22,6 @@
78 guess_executable,
79 iter_binaries,
80 iter_executables,
81- ldd,
82 METADATA_FILE,
83 needed_libraries_from_objdump,
84 NoBinariesFound,
85@@ -295,43 +294,6 @@
86
87 class GetSharedLibraryDependenciesTests(TestCase):
88
89- def test_ldd_none(self):
90- deps = ldd([])
91- self.assertEqual({}, deps)
92-
93- def test_ldd(self):
94- hello = os.path.join(os.path.dirname(__file__), 'hello')
95- deps = ldd([hello])
96- self.assertEqual(
97- {hello: [(None, '/lib64/ld-linux-x86-64.so.2'),
98- ('libc.so.6', '/lib/x86_64-linux-gnu/libc.so.6'),
99- ('linux-vdso.so.1', None)]},
100- deps)
101-
102- def test_ldd_not_found(self):
103- hello = os.path.join(os.path.dirname(__file__), 'hello-missing-deps')
104- deps = ldd([hello])
105- self.assertEqual(
106- {hello: [(None, '/lib64/ld-linux-x86-64.so.2'),
107- ('libc.so.6', '/lib/x86_64-linux-gnu/libc.so.6'),
108- ('libnowaythisexists.so.1', None),
109- ('linux-vdso.so.1', None),
110- ]},
111- deps)
112-
113- def test_ldd_multiple(self):
114- hello = os.path.join(os.path.dirname(__file__), 'hello')
115- simple = os.path.join(os.path.dirname(__file__), 'simple.so.1')
116- deps = ldd([hello, simple])
117- self.assertEqual(
118- {hello: [(None, '/lib64/ld-linux-x86-64.so.2'),
119- ('libc.so.6', '/lib/x86_64-linux-gnu/libc.so.6'),
120- ('linux-vdso.so.1', None)],
121- simple: [(None, '/lib64/ld-linux-x86-64.so.2'),
122- ('libc.so.6', '/lib/x86_64-linux-gnu/libc.so.6'),
123- ('linux-vdso.so.1', None)]},
124- deps)
125-
126 def test_get_shared_library_dependencies(self):
127 hello = os.path.join(os.path.dirname(__file__), 'hello')
128 deps = get_shared_library_dependencies([hello])

Subscribers

People subscribed via source and target branches