* this is for Caglar.
This commit is contained in:
+7
-2
@@ -86,11 +86,12 @@ class Index(XmlFile):
|
|||||||
|
|
||||||
def index(self, repo_uri, skip_sources=False):
|
def index(self, repo_uri, skip_sources=False):
|
||||||
self.repo_dir = repo_uri
|
self.repo_dir = repo_uri
|
||||||
|
|
||||||
|
packages = []
|
||||||
for root, dirs, files in os.walk(repo_uri):
|
for root, dirs, files in os.walk(repo_uri):
|
||||||
for fn in files:
|
for fn in files:
|
||||||
if fn.endswith(ctx.const.package_suffix):
|
if fn.endswith(ctx.const.package_suffix):
|
||||||
ctx.ui.info(_('Adding %s to package index') % fn)
|
packages.append(os.path.join(root, fn))
|
||||||
self.add_package(os.path.join(root, fn), repo_uri)
|
|
||||||
if fn == 'component.xml':
|
if fn == 'component.xml':
|
||||||
ctx.ui.info(_('Adding %s to component index') % fn)
|
ctx.ui.info(_('Adding %s to component index') % fn)
|
||||||
self.add_component(os.path.join(root, fn))
|
self.add_component(os.path.join(root, fn))
|
||||||
@@ -99,6 +100,10 @@ class Index(XmlFile):
|
|||||||
if fn == 'distribution.xml':
|
if fn == 'distribution.xml':
|
||||||
self.add_distro(os.path.join(root, fn))
|
self.add_distro(os.path.join(root, fn))
|
||||||
|
|
||||||
|
for pkg in util.filter_latest_packages(packages):
|
||||||
|
ctx.ui.info(_('Adding %s to package index') % pkg)
|
||||||
|
self.add_package(pkg, repo_uri)
|
||||||
|
|
||||||
def update_db(self, repo, txn = None):
|
def update_db(self, repo, txn = None):
|
||||||
# FIXME: updating db takes too much time. So a notify mechanism is used to inform the status
|
# FIXME: updating db takes too much time. So a notify mechanism is used to inform the status
|
||||||
# of the operation.
|
# of the operation.
|
||||||
|
|||||||
@@ -632,3 +632,24 @@ def parse_package_name(package_name):
|
|||||||
version = package_name[len(name) + 1:]
|
version = package_name[len(name) + 1:]
|
||||||
|
|
||||||
return (name, version)
|
return (name, version)
|
||||||
|
|
||||||
|
def filter_latest_packages(package_paths):
|
||||||
|
""" For a given pisi package paths list where there may also be multiple versions
|
||||||
|
of the same package, filters only the latest versioned ones """
|
||||||
|
|
||||||
|
from pisi.version import Version
|
||||||
|
|
||||||
|
latest = {}
|
||||||
|
for path in package_paths:
|
||||||
|
|
||||||
|
root = os.path.dirname(path)
|
||||||
|
name, version = parse_package_name(os.path.basename(path[:-len(".pisi")]))
|
||||||
|
|
||||||
|
if latest.has_key(name):
|
||||||
|
if Version(latest[name][2]) < Version(version):
|
||||||
|
latest[name] = (root, name, version)
|
||||||
|
else:
|
||||||
|
if version:
|
||||||
|
latest[name] = (root, name, version)
|
||||||
|
|
||||||
|
return map(lambda x:"%s/%s-%s.pisi" % x, latest.values())
|
||||||
|
|||||||
Reference in New Issue
Block a user