fix write dependencies if exist in repository

This commit is contained in:
Dimitris Zlatanidis 2015-01-22 03:50:09 +02:00
parent 425fa236d4
commit 590f15e8bb
3 changed files with 24 additions and 10 deletions

View file

@ -25,16 +25,27 @@ import sys
from slpkg.toolbar import status from slpkg.toolbar import status
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.splitting import split_package
from greps import Requires from greps import Requires
class Dependencies(object): class Dependencies(object):
def __init__(self): def __init__(self, PACKAGES_TXT, repo):
self.repo = repo
self.dep_results = [] self.dep_results = []
self.packages = []
for line in PACKAGES_TXT.splitlines():
# index += 1
# toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME:"):
if repo == "slackr":
self.packages.append(line[15:].strip())
else:
self.packages.append(split_package(line[15:].strip())[0])
def others(self, name, repo): def others(self, name):
''' '''
Build all dependencies of a package Build all dependencies of a package
''' '''
@ -42,18 +53,18 @@ class Dependencies(object):
sys.setrecursionlimit(10000) sys.setrecursionlimit(10000)
dependencies = [] dependencies = []
blacklist = BlackList().packages() blacklist = BlackList().packages()
requires = Requires(name, repo).get_deps() requires = Requires(name, self.repo).get_deps()
toolbar_width, index = 2, 0 toolbar_width, index = 2, 0
if requires: if requires:
for req in requires: for req in requires:
index += 1 index += 1
toolbar_width = status(index, toolbar_width, 7) toolbar_width = status(index, toolbar_width, 7)
if req and req not in blacklist: if req and req in self.packages and req not in blacklist:
dependencies.append(req) dependencies.append(req)
if dependencies: if dependencies:
self.dep_results.append(dependencies) self.dep_results.append(dependencies)
for dep in dependencies: for dep in dependencies:
self.others(dep, repo) self.others(dep)
return self.dep_results return self.dep_results
except KeyboardInterrupt: except KeyboardInterrupt:
print("") # new line at exit print("") # new line at exit

View file

@ -208,6 +208,9 @@ class Requires(object):
f.close() f.close()
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"): if line.startswith("PACKAGE NAME:"):
if self.repo == "slackr":
pkg_name = fix_slackers_pkg(line[15:])
else:
pkg_name = split_package(line[14:].strip())[0] pkg_name = split_package(line[14:].strip())[0]
if line.startswith("PACKAGE REQUIRED:"): if line.startswith("PACKAGE REQUIRED:"):
if pkg_name == self.name: if pkg_name == self.name:

View file

@ -222,8 +222,8 @@ class OthersInstall(object):
sys.stdout.flush() sys.stdout.flush()
for dep in self.packages: for dep in self.packages:
dependencies = [] dependencies = []
dependencies = dimensional_list(Dependencies().others(dep, dependencies = dimensional_list(Dependencies(self.PACKAGES_TXT,
self.repo)) self.repo).others(dep))
requires += dependencies requires += dependencies
self.deps_dict[dep] = remove_dbs(dependencies) self.deps_dict[dep] = remove_dbs(dependencies)
return remove_dbs(requires) return remove_dbs(requires)
@ -280,7 +280,7 @@ class OthersInstall(object):
for pkg in packages: for pkg in packages:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]): data[3]):
if pkg == split_package(name)[0] and pkg not in black: if name and pkg == split_package(name)[0] and pkg not in black:
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name) install.append(name)
comp_sum.append(comp) comp_sum.append(comp)
@ -289,7 +289,7 @@ class OthersInstall(object):
for pkg in packages: for pkg in packages:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]): data[3]):
if pkg in split_package(name)[0]: if name and pkg in split_package(name)[0]:
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name) install.append(name)
comp_sum.append(comp) comp_sum.append(comp)