some updater fixes

This commit is contained in:
guinux 2013-02-03 15:58:33 +01:00
parent c57bf16d37
commit ed8deca51a
9 changed files with 109 additions and 55 deletions

0
pamac/__init__.py Executable file → Normal file
View File

2
pamac/common.py Executable file → Normal file
View File

@ -16,4 +16,4 @@ def format_pkg_name(name):
index = name.find(i) index = name.find(i)
if index != -1: if index != -1:
name = name[0:index] name = name[0:index]
return name return name

0
pamac/config.py Executable file → Normal file
View File

10
pamac/manager.py Executable file → Normal file
View File

@ -327,7 +327,7 @@ def choose_provides():
break break
for target in to_check: for target in to_check:
for name in target.depends: for name in target.depends:
depends.append(common.format_pkg_name(name)) depends.append(name)
for installed_pkg in transaction.handle.get_localdb().pkgcache: for installed_pkg in transaction.handle.get_localdb().pkgcache:
if installed_pkg.name in depends: if installed_pkg.name in depends:
depends.remove(installed_pkg.name) depends.remove(installed_pkg.name)
@ -340,7 +340,7 @@ def choose_provides():
for pkg in repo.pkgcache: for pkg in repo.pkgcache:
for depend in depends: for depend in depends:
for name in pkg.provides: for name in pkg.provides:
if common.format_pkg_name(name) == depend: if name == depend:
if not provides.__contains__(depend): if not provides.__contains__(depend):
provides[depend] = [] provides[depend] = []
if not pkg.name in provides.get(depend): if not pkg.name in provides.get(depend):
@ -375,7 +375,7 @@ def choose_provides():
already_provided = True already_provided = True
for installed_pkg in transaction.handle.get_localdb().pkgcache: for installed_pkg in transaction.handle.get_localdb().pkgcache:
for name in installed_pkg.provides: for name in installed_pkg.provides:
if common.format_pkg_name(name) == virtualdep: if name == virtualdep:
already_provided = True already_provided = True
if already_provided: if already_provided:
pass pass
@ -415,7 +415,7 @@ class Handler:
print('Transaction locked') print('Transaction locked')
else: else:
if transaction_type is "remove": if transaction_type is "remove":
if transaction.init_transaction(cascade = True): if transaction.init_transaction(cascade = True, unneeded = True):
for pkgname in transaction_dict.keys(): for pkgname in transaction_dict.keys():
transaction.Remove(pkgname) transaction.Remove(pkgname)
error = transaction.Prepare() error = transaction.Prepare()
@ -498,7 +498,7 @@ class Handler:
Gtk.main_iteration() Gtk.main_iteration()
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000) transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
if (transaction_type == "install") or (transaction_type == "update"): if (transaction_type == "install") or (transaction_type == "update"):
if transaction.init_transaction(noconflicts = True, nodeps = True): if transaction.init_transaction(noconflicts = True):#, nodeps = True):
for pkgname in transaction.to_update: for pkgname in transaction.to_update:
transaction.Add(pkgname) transaction.Add(pkgname)
for pkgname in transaction.to_add: for pkgname in transaction.to_add:

0
pamac/pamac-daemon.py Executable file → Normal file
View File

37
pamac/transaction.py Executable file → Normal file
View File

@ -159,36 +159,6 @@ def get_to_add():
global to_add global to_add
to_add = To_Add() to_add = To_Add()
def do_refresh():
"""Sync databases like pacman -Sy"""
global t_lock
get_handle()
if t_lock is False:
t_lock = True
progress_label.set_text('Refreshing...')
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
ProgressWindow.show_all()
while Gtk.events_pending():
Gtk.main_iteration()
Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
def handle_error(error):
global t_lock
if not 'DBus.Error.NoReply' in str(error):
transaction.ErrorDialog.format_secondary_text('Refresh Error:\n'+str(error))
response = transaction.ErrorDialog.run()
if response:
transaction.ErrorDialog.hide()
t_lock = False
Release()
ProgressWindow.hide()
def handle_reply(reply):
global t_lock
t_lock = False
Release()
ProgressWindow.hide()
def get_updates(): def get_updates():
"""Return a list of package objects in local db which can be updated""" """Return a list of package objects in local db which can be updated"""
global do_syncfirst global do_syncfirst
@ -197,9 +167,10 @@ def get_updates():
if config.syncfirst: if config.syncfirst:
for name in config.syncfirst: for name in config.syncfirst:
pkg = handle.get_localdb().get_pkg(name) pkg = handle.get_localdb().get_pkg(name)
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs()) if pkg:
if candidate: candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
list_first.append(candidate) if candidate:
list_first.append(candidate)
if list_first: if list_first:
do_syncfirst = True do_syncfirst = True
return list_first return list_first

0
pamac/tray.py Executable file → Normal file
View File

23
pamac/updater.py Executable file → Normal file
View File

@ -18,6 +18,18 @@ bottom_label = interface.get_object('bottom_label')
update_listore = interface.get_object('update_list') update_listore = interface.get_object('update_list')
update_label = interface.get_object('update_label') update_label = interface.get_object('update_label')
def do_refresh():
"""Sync databases like pacman -Sy"""
transaction.get_handle()
if transaction.t_lock is False:
transaction.t_lock = True
transaction.progress_label.set_text('Refreshing...')
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
transaction.ProgressWindow.show_all()
while Gtk.events_pending():
Gtk.main_iteration()
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
def have_updates(): def have_updates():
available_updates = transaction.get_updates() available_updates = transaction.get_updates()
update_listore.clear() update_listore.clear()
@ -90,11 +102,11 @@ def do_sysupgrade():
transaction.get_to_add() transaction.get_to_add()
transaction.check_conflicts() transaction.check_conflicts()
transaction.Release() transaction.Release()
if len(transaction.to_update) == 0: if len(transaction.to_add) == 0:
transaction.t_lock = False transaction.t_lock = False
print("Nothing to update") print("Nothing to update")
else: else:
if transaction.init_transaction(noconflicts = True, nodeps = True): if transaction.init_transaction(noconflicts = True):
for pkgname in transaction.to_update: for pkgname in transaction.to_update:
transaction.Add(pkgname) transaction.Add(pkgname)
for pkgname in transaction.to_add: for pkgname in transaction.to_add:
@ -169,7 +181,7 @@ class Handler:
def on_RefreshButton_clicked(self, *arg): def on_RefreshButton_clicked(self, *arg):
transaction.do_refresh() transaction.do_refresh()
have_updates() #have_updates()
def on_TransCancelButton_clicked(self, *arg): def on_TransCancelButton_clicked(self, *arg):
ConfDialog.hide() ConfDialog.hide()
@ -187,8 +199,9 @@ class Handler:
have_updates() have_updates()
def main(): def main():
transaction.do_refresh() do_refresh()
have_updates() #have_updates()
update_label.set_markup("<big><b>Available updates</b></big>")
interface.connect_signals(Handler()) interface.connect_signals(Handler())
UpdateWindow.show_all() UpdateWindow.show_all()
while Gtk.events_pending(): while Gtk.events_pending():

92
test.py
View File

@ -1,20 +1,90 @@
#! /usr/bin/python #! /usr/bin/python
# -*-coding:utf-8 -*- # -*-coding:utf-8 -*-
from pamac import config import pyalpm
from pamac import config, common
syncpkgs = {} from collections import OrderedDict
syncpkgs = OrderedDict()
localpkgs = OrderedDict()
virtualdeps = {} virtualdeps = {}
for repo in config.handle.get_syncdbs(): for repo in config.handle.get_syncdbs():
for pkg in repo.pkgcache: for pkg in repo.pkgcache:
if not pkg.name in syncpkgs.keys(): if not pkg.name in syncpkgs.keys():
syncpkgs[pkg.name] = pkg syncpkgs[pkg.name] = pkg
for pkg in syncpkgs.values(): for pkg in config.handle.get_localdb().pkgcache:
for name in pkg.depends: if not pkg.name in localpkgs.keys():
if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name): localpkgs[pkg.name] = pkg
if 'module' in name: #~ for pkg in syncpkgs.values():
if not virtualdeps.__contains__(name): #~ for name in pkg.depends:
virtualdeps[name] = [] #~ if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name):
virtualdeps.get(name).append(pkg.name) #~ if 'module' in name:
print(virtualdeps) #~ if not virtualdeps.__contains__(name):
#~ virtualdeps[name] = []
#~ virtualdeps.get(name).append(pkg.name)
to_add = ['libreoffice-writer', 'anjuta']
depends = [[syncpkgs['libreoffice-writer'],syncpkgs['anjuta']]]
to_provide = []
to_remove = []
warning = ''
i = 0
while depends[i]:
depends.append([])
for pkg in depends[i]:
for depend in pkg.depends:
provide = pyalpm.find_satisfier(localpkgs.values(), depend)
if provide:
print(i,'local',provide)
if provide.name != common.format_pkg_name(depend):
if ('-module' in depend) or ('linux' in depend):
to_provide.append(depend)
else:
provide = pyalpm.find_satisfier(syncpkgs.values(), depend)
if provide:
print(i,'sync',provide)
if provide.name != common.format_pkg_name(depend):
print(provide.name,common.format_pkg_name(depend))
to_provide.append(depend)
else:
depends[i+1].append(provide)
for replace in pkg.replaces:
provide = pyalpm.find_satisfier(localpkgs.values(), replace)
if provide:
if not provide.name in to_remove:
to_remove.append(provide.name)
if warning:
warning = warning+'\n'
warning = warning+provide.name+' will be replaced by '+pkg.name
for conflict in pkg.conflicts:
provide = pyalpm.find_satisfier(localpkgs.values(), conflict)
if provide:
if not provide.name in to_remove:
to_remove.append(provide.name)
if warning:
warning = warning+'\n'
warning = warning+pkg.name+' conflicts with '+provide.name
provide = pyalpm.find_satisfier(depends[0], conflict)
if provide:
if not common.format_pkg_name(conflict) in to_remove:
if pkg.name in to_add and common.format_pkg_name(conflict) in to_add:
to_add.remove(common.format_pkg_name(conflict))
to_add.remove(pkg.name)
if warning:
warning = warning+'\n'
warning = warning+pkg.name+' conflicts with '+common.format_pkg_name(conflict)+'\nNone of them will be installed'
i = i + 1
for pkg in localpkgs.values():
for conflict in pkg.conflicts:
provide = pyalpm.find_satisfier(depends[0], conflict)
if provide:
if not provide.name in to_remove:
to_remove.append(pkg.name)
if warning:
warning = warning+'\n'
warning = warning+provide.name+' conflicts with '+pkg.name
print('depends:',depends)
print('to provide:',to_provide)
print('to add:',to_add)
print('to remove:',to_remove)
print(warning)