Kaydet (Commit) 1bdd4e1b authored tarafından Eray Özkural's avatar Eray Özkural

* a new fast tool to find library dependencies!

* some comments
üst 4971b3ae
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-3.8.dtd">
<!-- Project file for project pisi -->
<!-- Saved: 2005-11-13, 00:06:19 -->
<!-- Saved: 2005-11-15, 01:32:57 -->
<!-- Copyright (C) 2005 PiSi Development Team, -->
<Project version="3.8">
<ProgLanguage mixed="0">Python</ProgLanguage>
......@@ -418,6 +418,14 @@
<Dir>pxml</Dir>
<Name>xmlfilepiks.py</Name>
</Source>
<Source>
<Dir>tools</Dir>
<Name>cat-source-repo.py</Name>
</Source>
<Source>
<Dir>tools</Dir>
<Name>find-lib-deps.py</Name>
</Source>
</Sources>
<Forms>
</Forms>
......@@ -459,10 +467,10 @@
<VcsOtherData>{'standardLayout': 1}</VcsOtherData>
</Vcs>
<FiletypeAssociations>
<FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ui.h" type="FORMS" />
<FiletypeAssociation pattern="*.ui" type="FORMS" />
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
<FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ui" type="FORMS" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
</FiletypeAssociations>
</Project>
......@@ -952,6 +952,8 @@ Finds the installed package which contains the specified file.
self.parser.add_option("-f", "--fuzzy", action="store_true",
default=False, help=_("fuzzy search"))
# and what does exact mean? -- exa
@staticmethod #fuck python 2.3 compatibility I don't care about it
def search_exact(path):
files = []
path = path.lstrip('/') #FIXME: this shouldn't be necessary :/
......@@ -960,18 +962,18 @@ Finds the installed package which contains the specified file.
if ctx.filesdb.has_file(path):
files.append(ctx.filesdb.get_file(path))
else:
#FIXME: this linear search thing is not working well -- exa
files = ctx.filesdb.get_files(path)
if files:
for (pkg_name, file_info) in files:
#FIXME: files of the same package can be grouped under package name
ctx.ui.info(_('Package: %s has File: %s') % (pkg_name, file_info.path))
ctx.ui.info(_("Package %s has file %s") % (pkg_name, file_info.path))
if ctx.config.options.long:
ctx.ui.info(_('Type: %s, Hash: %s') % (file_info.type,
file_info.hash))
else:
ctx.ui.error(_('Path %s does not belong to an installed package') % path)
search_exact=staticmethod(search_exact)
ctx.ui.error(_("Path '%s' does not belong to an installed package") % path)
def run(self):
......
......@@ -45,7 +45,7 @@ class Package:
dest = ctx.config.packages_dir()
self.filepath = join(dest, url.filename())
# FIXME: exists is not enough, also sha1sum check needed \
# FIXME: exists is not enough, also sha1sum check needed
# when implemented in pisi-index.xml
if not exists(self.filepath):
fetch_url(url, dest, ctx.ui.Progress)
......
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
# find library dependencies of a package
# author: exa (Eray Özkural)
import locale
import sys
import os
import fnmatch
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi
import pisi.api
import pisi.config
import pisi.specfile as specfile
import pisi.context as ctx
import pisi.util as util
from pisi.package import Package
locale.setlocale(locale.LC_ALL, '')
options = pisi.config.Options()
if len(sys.argv) > 2:
options.destdir=sys.argv[2]
else:
options.destdir = '/'
pisi.api.init(database=True, comar=False, options=options)
filename = sys.argv[1]
package = Package(filename)
package.read()
util.clean_dir('/tmp/install')
package.extract_dir_flat('install', '/tmp/install')
deps = set()
needed = set()
for file in package.files.list:
#print file.path, file.type
if file.type == 'binary':
(ret, lines) = util.run_batch('objdump -p %s' % util.join_path('/tmp/install', file.path))
for x in lines:
if x.startswith(' NEEDED'):
needed.add(x[8:].strip())
#print 'needed guys', needed
for lib in needed:
(ret, out) = util.run_batch('locate %s' % lib)
path = out[0].strip().lstrip('/')
try:
(pkg_name, file_info) = ctx.filesdb.get_file(path)
ctx.ui.info("Library dependency: '%s' due to library '%s'" % (pkg_name, file_info.path))
except:
ctx.ui.warning('Cannot find an installed package for library %s' % lib)
pisi.api.finalize()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment