somes check-conflicts fixes and errors handler test

This commit is contained in:
guinux 2013-02-25 17:39:43 +01:00
parent 53168a6015
commit 6d29958378
2 changed files with 51 additions and 35 deletions

View File

@ -397,43 +397,57 @@ def check_conflicts(pkg_list):
while depends[i]: while depends[i]:
depends.append([]) depends.append([])
for pkg in depends[i]: for pkg in depends[i]:
if 'linux3' in pkg.name:
for _pkg in transaction.localpkgs.values():
for depend in _pkg.depends:
if '-modules' in depend:
for __pkg in transaction.syncpkgs.values():
if not __pkg.name in transaction.localpkgs.keys():
for name in __pkg.provides:
for linux in installed_linux:
if linux in __pkg.name:
if common.format_pkg_name(depend) == common.format_pkg_name(name):
if not __pkg.name in transaction.to_add:
print(i,'module',__pkg)
depends[i+1].append(__pkg)
transaction.to_add.append(__pkg.name)
for depend in pkg.depends: for depend in pkg.depends:
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), depend) provide = pyalpm.find_satisfier(transaction.localpkgs.values(), depend)
if provide: if provide:
print(i,'local',provide) print(i,'local',provide)
if provide.name != common.format_pkg_name(depend): if provide.name != common.format_pkg_name(depend):
if '-modules' in depend: if ('-modules' in depend) or ('linux' in depend):
for pkg in transaction.syncpkgs.values(): for _pkg in transaction.syncpkgs.values():
if not pkg.name in transaction.localpkgs.keys(): if not _pkg.name in transaction.localpkgs.keys():
for name in pkg.provides: for name in _pkg.provides:
for linux in installed_linux: for linux in installed_linux:
if linux in pkg.name: if linux in _pkg.name:
if common.format_pkg_name(depend) == common.format_pkg_name(name): if common.format_pkg_name(depend) == common.format_pkg_name(name):
if not pkg.name in transaction.to_add: if not _pkg.name in transaction.to_add:
depends[i+1].append(pkg) depends[i+1].append(_pkg)
transaction.to_add.append(pkg.name) transaction.to_add.append(_pkg.name)
else: else:
provide = pyalpm.find_satisfier(transaction.syncpkgs.values(), depend) provide = pyalpm.find_satisfier(transaction.syncpkgs.values(), depend)
if provide: if provide:
print(i,'sync',provide) print(i,'sync',provide)
if provide.name != common.format_pkg_name(depend): if provide.name != common.format_pkg_name(depend):
if '-modules' in depend: if ('-modules' in depend) or ('linux' in depend):
for pkg in transaction.syncpkgs.values(): for _pkg in transaction.syncpkgs.values():
if not pkg.name in transaction.localpkgs.keys(): if not _pkg.name in transaction.localpkgs.keys():
for name in pkg.provides: for name in _pkg.provides:
for linux in installed_linux: for linux in installed_linux:
if linux in pkg.name: if linux in _pkg.name:
if common.format_pkg_name(depend) == common.format_pkg_name(name): if common.format_pkg_name(depend) == common.format_pkg_name(name):
if not pkg.name in transaction.to_add: if not _pkg.name in transaction.to_add:
depends[i+1].append(pkg) depends[i+1].append(_pkg)
transaction.to_add.append(pkg.name) transaction.to_add.append(_pkg.name)
else: else:
to_add_to_depends = choose_provides(depend) to_add_to_depends = choose_provides(depend)
print(to_add_to_depends) print(to_add_to_depends)
for pkg in to_add_to_depends: for _pkg in to_add_to_depends:
if not pkg.name in transaction.to_add: if not _pkg.name in transaction.to_add:
depends[i+1].append(pkg) depends[i+1].append(_pkg)
transaction.to_add.append(pkg.name) transaction.to_add.append(_pkg.name)
else: else:
depends[i+1].append(provide) depends[i+1].append(provide)
for replace in pkg.replaces: for replace in pkg.replaces:
@ -456,6 +470,7 @@ def check_conflicts(pkg_list):
warning = warning+pkg.name+' conflicts with '+provide.name warning = warning+pkg.name+' conflicts with '+provide.name
provide = pyalpm.find_satisfier(depends[0], conflict) provide = pyalpm.find_satisfier(depends[0], conflict)
if provide: if provide:
if not common.format_pkg_name(conflict) == pkg.name:
if not common.format_pkg_name(conflict) in transaction.to_remove: if not common.format_pkg_name(conflict) in transaction.to_remove:
if pkg.name in transaction.to_add and common.format_pkg_name(conflict) in transaction.to_add: if pkg.name in transaction.to_add and common.format_pkg_name(conflict) in transaction.to_add:
transaction.to_add.remove(common.format_pkg_name(conflict)) transaction.to_add.remove(common.format_pkg_name(conflict))

View File

@ -112,10 +112,10 @@ class PamacDBusService(dbus.service.Object):
if not (level & _logmask): if not (level & _logmask):
return return
if level & pyalpm.LOG_ERROR: if level & pyalpm.LOG_ERROR:
self.error = "ERROR: "+line self.error += "ERROR: "+line
#t.release() #t.release()
elif level & pyalpm.LOG_WARNING: elif level & pyalpm.LOG_WARNING:
self.warning = "WARNING: "+line self.warning += "WARNING: "+line
elif level & pyalpm.LOG_DEBUG: elif level & pyalpm.LOG_DEBUG:
line = "DEBUG: " + line line = "DEBUG: " + line
print(line) print(line)
@ -187,18 +187,19 @@ class PamacDBusService(dbus.service.Object):
@dbus.service.method('org.manjaro.pamac', '', 's') @dbus.service.method('org.manjaro.pamac', '', 's')
def Refresh(self): def Refresh(self):
global t global t
global error #~ global error
error = '' #~ error = ''
for db in config.handle.get_syncdbs(): for db in config.handle.get_syncdbs():
try: try:
t = config.handle.init_transaction() t = config.handle.init_transaction()
db.update(force=False) db.update(force=False)
t.release() t.release()
except pyalpm.error: except pyalpm.error as e:
error = traceback.format_exc() self.error += str(e)+'\n'
break t.release()
#break
self.CheckUpdates() self.CheckUpdates()
return error return self.error
@dbus.service.method('org.manjaro.pamac', 'a{sb}', 's', sender_keyword='sender', connection_keyword='connexion') @dbus.service.method('org.manjaro.pamac', 'a{sb}', 's', sender_keyword='sender', connection_keyword='connexion')
def Init(self, options, sender=None, connexion=None): def Init(self, options, sender=None, connexion=None):