forked from cromer/pamac-classic
incredibily improve check conflicts
This commit is contained in:
parent
ed8deca51a
commit
5741cf9f5e
@ -17,3 +17,4 @@ def format_pkg_name(name):
|
|||||||
if index != -1:
|
if index != -1:
|
||||||
name = name[0:index]
|
name = name[0:index]
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
290
pamac/manager.py
290
pamac/manager.py
@ -4,6 +4,7 @@
|
|||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
import pyalpm
|
import pyalpm
|
||||||
|
from collections import OrderedDict
|
||||||
from time import strftime, localtime
|
from time import strftime, localtime
|
||||||
|
|
||||||
from pamac import config, common, transaction
|
from pamac import config, common, transaction
|
||||||
@ -35,7 +36,6 @@ installed_column.set_sort_column_id(1)
|
|||||||
name_column.set_sort_column_id(0)
|
name_column.set_sort_column_id(0)
|
||||||
|
|
||||||
transaction.get_handle()
|
transaction.get_handle()
|
||||||
|
|
||||||
tmp_list = []
|
tmp_list = []
|
||||||
for repo in transaction.handle.get_syncdbs():
|
for repo in transaction.handle.get_syncdbs():
|
||||||
for name, pkgs in repo.grpcache:
|
for name, pkgs in repo.grpcache:
|
||||||
@ -128,7 +128,6 @@ def refresh_packages_list():
|
|||||||
|
|
||||||
def set_packages_list():
|
def set_packages_list():
|
||||||
global list_dict
|
global list_dict
|
||||||
transaction.get_handle()
|
|
||||||
if list_dict == "search":
|
if list_dict == "search":
|
||||||
search_strings_list = search_entry.get_text().split()
|
search_strings_list = search_entry.get_text().split()
|
||||||
set_list_dict_search(*search_strings_list)
|
set_list_dict_search(*search_strings_list)
|
||||||
@ -242,6 +241,7 @@ def handle_error(error):
|
|||||||
transaction.to_remove = []
|
transaction.to_remove = []
|
||||||
transaction_dict.clear()
|
transaction_dict.clear()
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
|
transaction.get_handle()
|
||||||
set_packages_list()
|
set_packages_list()
|
||||||
print('error',error)
|
print('error',error)
|
||||||
|
|
||||||
@ -253,26 +253,24 @@ def handle_reply(reply):
|
|||||||
response = transaction.ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
if transaction.do_syncfirst is True:
|
|
||||||
transaction.do_syncfirst = False
|
|
||||||
transaction.list_first = []
|
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
transaction.ProgressWindow.hide()
|
transaction.ProgressWindow.hide()
|
||||||
transaction.to_add = []
|
transaction.to_add = []
|
||||||
transaction.to_remove = []
|
transaction.to_remove = []
|
||||||
transaction_dict.clear()
|
transaction_dict.clear()
|
||||||
|
transaction.get_handle()
|
||||||
if (transaction_type == "install") or (transaction_type == "remove"):
|
if (transaction_type == "install") or (transaction_type == "remove"):
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
set_packages_list()
|
set_packages_list()
|
||||||
else:
|
else:
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
if transaction.get_updates():
|
do_syncfirst, updates = transaction.get_updates()
|
||||||
do_sysupgrade()
|
if updates:
|
||||||
|
do_sysupgrade(do_syncfirst, updates)
|
||||||
|
|
||||||
def do_refresh():
|
def do_refresh():
|
||||||
"""Sync databases like pacman -Sy"""
|
"""Sync databases like pacman -Sy"""
|
||||||
transaction.get_handle()
|
|
||||||
if transaction.t_lock is False:
|
if transaction.t_lock is False:
|
||||||
transaction.t_lock = True
|
transaction.t_lock = True
|
||||||
transaction.progress_label.set_text('Refreshing...')
|
transaction.progress_label.set_text('Refreshing...')
|
||||||
@ -282,112 +280,183 @@ def do_refresh():
|
|||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||||
|
|
||||||
def do_sysupgrade():
|
def do_sysupgrade(do_syncfirst, updates_list):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
"""Upgrade a system like pacman -Su"""
|
"""Upgrade a system like pacman -Su"""
|
||||||
if transaction.t_lock is False:
|
if transaction.t_lock is False:
|
||||||
transaction_type = "update"
|
transaction_type = "update"
|
||||||
if transaction.do_syncfirst is True:
|
do_syncfirst, updates = transaction.get_updates()
|
||||||
|
if updates:
|
||||||
|
transaction.to_add = []
|
||||||
|
transaction.to_remove = []
|
||||||
|
check_conflicts(updates)
|
||||||
|
if do_syncfirst is True:
|
||||||
|
for pkg in updates:
|
||||||
|
transaction.to_add.append(pkg.name)
|
||||||
if transaction.init_transaction(recurse = True):
|
if transaction.init_transaction(recurse = True):
|
||||||
for pkg in transaction.list_first:
|
for pkgname in transaction.to_add:
|
||||||
transaction.Add(pkg.name)
|
transaction.Add(pkgname)
|
||||||
transaction.get_to_remove()
|
for pkgname in transaction.to_remove:
|
||||||
transaction.get_to_add()
|
transaction.Remove(pkgname)
|
||||||
transaction.check_conflicts()
|
error = transaction.Prepare()
|
||||||
transaction.Release()
|
|
||||||
set_transaction_sum()
|
|
||||||
ConfDialog.show_all()
|
|
||||||
else:
|
|
||||||
if transaction.init_transaction():
|
|
||||||
error = transaction.Sysupgrade()
|
|
||||||
if error:
|
if error:
|
||||||
handle_error(error)
|
handle_error(error)
|
||||||
else:
|
else:
|
||||||
transaction.get_to_remove()
|
transaction.get_to_remove()
|
||||||
transaction.get_to_add()
|
transaction.get_to_add()
|
||||||
transaction.check_conflicts()
|
|
||||||
transaction.Release()
|
|
||||||
if len(transaction.to_add) + len(transaction.to_update) + len(transaction.to_remove) != 0:
|
|
||||||
set_transaction_sum()
|
set_transaction_sum()
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
else:
|
else:
|
||||||
transaction.Release()
|
if transaction.init_transaction(noconflicts = True):
|
||||||
transaction.t_lock = False
|
error = transaction.Sysupgrade()
|
||||||
|
if error:
|
||||||
def choose_provides():
|
handle_error(error)
|
||||||
to_check = []
|
else:
|
||||||
depends = []
|
|
||||||
provides = {}
|
|
||||||
already_provided = False
|
|
||||||
for pkgname in transaction.to_add:
|
for pkgname in transaction.to_add:
|
||||||
for repo in transaction.handle.get_syncdbs():
|
transaction.Add(pkgname)
|
||||||
pkg = repo.get_pkg(pkgname)
|
for pkgname in transaction.to_remove:
|
||||||
if pkg:
|
transaction.Remove(pkgname)
|
||||||
to_check.append(pkg)
|
error = transaction.Prepare()
|
||||||
break
|
if error:
|
||||||
for target in to_check:
|
handle_error(error)
|
||||||
for name in target.depends:
|
else:
|
||||||
depends.append(name)
|
transaction.get_to_remove()
|
||||||
for installed_pkg in transaction.handle.get_localdb().pkgcache:
|
transaction.get_to_add()
|
||||||
if installed_pkg.name in depends:
|
set_transaction_sum()
|
||||||
depends.remove(installed_pkg.name)
|
ConfDialog.show_all()
|
||||||
for repo in transaction.handle.get_syncdbs():
|
|
||||||
for pkg in repo.pkgcache:
|
def check_conflicts(pkg_list):
|
||||||
if pkg.name in depends:
|
#~ global to_add
|
||||||
depends.remove(pkg.name)
|
#~ global to_remove
|
||||||
if depends:
|
#~ global to_provide
|
||||||
for repo in transaction.handle.get_syncdbs():
|
depends = [pkg_list]
|
||||||
for pkg in repo.pkgcache:
|
warning = ''
|
||||||
for depend in depends:
|
#transaction.get_handle()
|
||||||
for name in pkg.provides:
|
|
||||||
if name == depend:
|
|
||||||
if not provides.__contains__(depend):
|
|
||||||
provides[depend] = []
|
|
||||||
if not pkg.name in provides.get(depend):
|
|
||||||
provides.get(depend).append(pkg.name)
|
|
||||||
if provides:
|
|
||||||
for virtualdep, liste in provides.items():
|
|
||||||
if ('-module' in virtualdep) or ('linux' in virtualdep):
|
|
||||||
pkgs = transaction.handle.get_localdb().search('linux3')
|
pkgs = transaction.handle.get_localdb().search('linux3')
|
||||||
installed_linux = []
|
installed_linux = []
|
||||||
to_remove_from_add = []
|
|
||||||
for i in pkgs:
|
for i in pkgs:
|
||||||
if len(i.name) == 7:
|
if len(i.name) == 7:
|
||||||
installed_linux.append(i.name)
|
installed_linux.append(i.name)
|
||||||
for to_install in transaction.to_add:
|
for to_install in transaction.to_add:
|
||||||
if 'linux3' in to_install:
|
if 'linux3' in to_install:
|
||||||
if len(to_install) == 7:
|
if len(to_install) == 7:
|
||||||
if to_install in transaction_dict.keys():
|
|
||||||
installed_linux.append(to_install)
|
installed_linux.append(to_install)
|
||||||
else:
|
i = 0
|
||||||
to_remove_from_add.append(to_install)
|
while depends[i]:
|
||||||
for name in liste:
|
depends.append([])
|
||||||
if name == to_install:
|
for pkg in depends[i]:
|
||||||
if not to_install in transaction_dict.keys():
|
for depend in pkg.depends:
|
||||||
to_remove_from_add.append(to_install)
|
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), depend)
|
||||||
for to_remove in to_remove_from_add:
|
if provide:
|
||||||
transaction.to_add.remove(to_remove)
|
print(i,'local',provide)
|
||||||
for name in liste:
|
if provide.name != common.format_pkg_name(depend):
|
||||||
|
if ('linux' in depend) or ('-module' 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:
|
for linux in installed_linux:
|
||||||
if not transaction.handle.get_localdb().get_pkg(name):
|
if linux in pkg.name:
|
||||||
if linux in name:
|
if common.format_pkg_name(depend) == common.format_pkg_name(name):
|
||||||
transaction.to_add.append(name)
|
depends[i+1].append(pkg)
|
||||||
already_provided = True
|
transaction.to_add.append(pkg.name)
|
||||||
for installed_pkg in transaction.handle.get_localdb().pkgcache:
|
|
||||||
for name in installed_pkg.provides:
|
|
||||||
if name == virtualdep:
|
|
||||||
already_provided = True
|
|
||||||
if already_provided:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
choose_label.set_markup('<b>{} is provided by {} packages.\nPlease choose the one(s) you want to install:</b>'.format(virtualdep,str(len(liste))))
|
provide = pyalpm.find_satisfier(transaction.syncpkgs.values(), depend)
|
||||||
|
if provide:
|
||||||
|
print(i,'sync',provide)
|
||||||
|
if provide.name != common.format_pkg_name(depend):
|
||||||
|
if ('linux' in depend) or ('-module' 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):
|
||||||
|
depends[i+1].append(pkg)
|
||||||
|
transaction.to_add.append(pkg.name)
|
||||||
|
else:
|
||||||
|
to_add_to_depends = choose_provides(depend)
|
||||||
|
print(to_add_to_depends)
|
||||||
|
for pkg in to_add_to_depends:
|
||||||
|
depends[i+1].append(pkg)
|
||||||
|
transaction.to_add.append(pkg.name)
|
||||||
|
else:
|
||||||
|
depends[i+1].append(provide)
|
||||||
|
for replace in pkg.replaces:
|
||||||
|
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
|
||||||
|
if provide:
|
||||||
|
if provide.name != pkg.name:
|
||||||
|
if not provide.name in transaction.to_remove:
|
||||||
|
transaction.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(transaction.localpkgs.values(), conflict)
|
||||||
|
if provide:
|
||||||
|
if provide.name != pkg.name:
|
||||||
|
if not provide.name in transaction.to_remove:
|
||||||
|
transaction.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 transaction.to_remove:
|
||||||
|
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(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 += 1
|
||||||
|
for pkg in transaction.localpkgs.values():
|
||||||
|
for conflict in pkg.conflicts:
|
||||||
|
provide = pyalpm.find_satisfier(depends[0], conflict)
|
||||||
|
if provide:
|
||||||
|
if provide.name != pkg.name:
|
||||||
|
if not provide.name in transaction.to_remove:
|
||||||
|
transaction.to_remove.append(pkg.name)
|
||||||
|
if warning:
|
||||||
|
warning = warning+'\n'
|
||||||
|
warning = warning+provide.name+' conflicts with '+pkg.name
|
||||||
|
for pkg in transaction.syncpkgs.values():
|
||||||
|
for replace in pkg.replaces:
|
||||||
|
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
|
||||||
|
if provide:
|
||||||
|
if provide.name != pkg.name:
|
||||||
|
if not provide.name in transaction.localpkgs.keys():
|
||||||
|
if not provide.name in transaction.to_remove:
|
||||||
|
transaction.to_remove.append(provide.name)
|
||||||
|
if warning:
|
||||||
|
warning = warning+'\n'
|
||||||
|
warning = warning+provide.name+' will be replaced by '+pkg.name
|
||||||
|
if not pkg.name in transaction.to_add:
|
||||||
|
transaction.to_add.append(pkg.name)
|
||||||
|
print(transaction.to_add,transaction.to_remove)
|
||||||
|
if warning:
|
||||||
|
transaction.WarningDialog.format_secondary_text(warning)
|
||||||
|
response = transaction.WarningDialog.run()
|
||||||
|
if response:
|
||||||
|
transaction.WarningDialog.hide()
|
||||||
|
|
||||||
|
def choose_provides(name):
|
||||||
|
provides = OrderedDict()
|
||||||
|
already_add = []
|
||||||
|
for pkg in transaction.syncpkgs.values():
|
||||||
|
for provide in pkg.provides:
|
||||||
|
if common.format_pkg_name(name) == common.format_pkg_name(provide):
|
||||||
|
if not pkg.name in provides.keys():
|
||||||
|
provides[pkg.name] = pkg
|
||||||
|
if provides:
|
||||||
|
choose_label.set_markup('<b>{} is provided by {} packages.\nPlease choose the one(s) you want to install:</b>'.format(name,str(len(provides.keys()))))
|
||||||
choose_list.clear()
|
choose_list.clear()
|
||||||
for name in liste:
|
for name in provides.keys():
|
||||||
if transaction.handle.get_localdb().get_pkg(name):
|
if transaction.handle.get_localdb().get_pkg(name):
|
||||||
choose_list.append([True, name])
|
choose_list.append([True, name])
|
||||||
else:
|
else:
|
||||||
choose_list.append([False, name])
|
choose_list.append([False, name])
|
||||||
ChooseDialog.run()
|
ChooseDialog.run()
|
||||||
|
return [provides[pkgname] for pkgname in transaction.to_provide]
|
||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
def on_MainWindow_delete_event(self, *arg):
|
def on_MainWindow_delete_event(self, *arg):
|
||||||
@ -427,19 +496,12 @@ class Handler:
|
|||||||
set_transaction_sum()
|
set_transaction_sum()
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
if transaction_type is "install":
|
if transaction_type is "install":
|
||||||
if transaction.init_transaction(noconflicts = True):
|
transaction.to_add = []
|
||||||
for pkgname in transaction_dict.keys():
|
for pkgname in transaction_dict.keys():
|
||||||
transaction.Add(pkgname)
|
transaction.to_add.append(pkgname)
|
||||||
error = transaction.Prepare()
|
transaction.to_remove = []
|
||||||
if error:
|
check_conflicts(transaction_dict.values())
|
||||||
handle_error(error)
|
if transaction.to_add:
|
||||||
else:
|
|
||||||
transaction.get_to_remove()
|
|
||||||
transaction.get_to_add()
|
|
||||||
transaction.Release()
|
|
||||||
choose_provides()
|
|
||||||
transaction.check_conflicts()
|
|
||||||
if set(transaction_dict.keys()).intersection(transaction.to_add):
|
|
||||||
if transaction.init_transaction(noconflicts = True):
|
if transaction.init_transaction(noconflicts = True):
|
||||||
for pkgname in transaction.to_add:
|
for pkgname in transaction.to_add:
|
||||||
transaction.Add(pkgname)
|
transaction.Add(pkgname)
|
||||||
@ -451,18 +513,14 @@ class Handler:
|
|||||||
else:
|
else:
|
||||||
transaction.get_to_remove()
|
transaction.get_to_remove()
|
||||||
transaction.get_to_add()
|
transaction.get_to_add()
|
||||||
transaction.Release()
|
|
||||||
if len(transaction.to_add) + len(transaction.to_remove) != 0:
|
|
||||||
set_transaction_sum()
|
set_transaction_sum()
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
else:
|
else:
|
||||||
transaction.WarningDialog.format_secondary_text('Nothing to do due to packages conflicts')
|
transaction.WarningDialog.format_secondary_text('Nothing to do')
|
||||||
response = transaction.WarningDialog.run()
|
response = transaction.WarningDialog.run()
|
||||||
if response:
|
if response:
|
||||||
transaction.WarningDialog.hide()
|
transaction.WarningDialog.hide()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
else:
|
|
||||||
transaction.t_lock = False
|
|
||||||
|
|
||||||
def on_EraseButton_clicked(self, *arg):
|
def on_EraseButton_clicked(self, *arg):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
@ -473,7 +531,7 @@ class Handler:
|
|||||||
refresh_packages_list()
|
refresh_packages_list()
|
||||||
|
|
||||||
def on_RefreshButton_clicked(self, *arg):
|
def on_RefreshButton_clicked(self, *arg):
|
||||||
transaction.do_refresh()
|
do_refresh()
|
||||||
set_packages_list()
|
set_packages_list()
|
||||||
|
|
||||||
def on_TransCancelButton_clicked(self, *arg):
|
def on_TransCancelButton_clicked(self, *arg):
|
||||||
@ -490,25 +548,6 @@ class Handler:
|
|||||||
transaction.progress_label.set_text('Preparing...')
|
transaction.progress_label.set_text('Preparing...')
|
||||||
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
||||||
transaction.progress_bar.set_text('')
|
transaction.progress_bar.set_text('')
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
if transaction_type == "remove":
|
|
||||||
transaction.ProgressWindow.show_all()
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
|
||||||
if (transaction_type == "install") or (transaction_type == "update"):
|
|
||||||
if transaction.init_transaction(noconflicts = True):#, nodeps = True):
|
|
||||||
for pkgname in transaction.to_update:
|
|
||||||
transaction.Add(pkgname)
|
|
||||||
for pkgname in transaction.to_add:
|
|
||||||
transaction.Add(pkgname)
|
|
||||||
for pkgname in transaction.to_remove:
|
|
||||||
transaction.Remove(pkgname)
|
|
||||||
error = transaction.Prepare()
|
|
||||||
if error:
|
|
||||||
handle_error(error)
|
|
||||||
else:
|
|
||||||
transaction.ProgressWindow.show_all()
|
transaction.ProgressWindow.show_all()
|
||||||
while Gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
@ -599,14 +638,15 @@ class Handler:
|
|||||||
def on_ChooseButton_clicked(self, *arg):
|
def on_ChooseButton_clicked(self, *arg):
|
||||||
ChooseDialog.hide()
|
ChooseDialog.hide()
|
||||||
line = 0
|
line = 0
|
||||||
|
transaction.to_provide = []
|
||||||
while line < len(choose_list):
|
while line < len(choose_list):
|
||||||
if choose_list[line][0] is True:
|
if choose_list[line][0] is True:
|
||||||
if not choose_list[line][1] in transaction.to_add:
|
if not choose_list[line][1] in transaction.to_provide:
|
||||||
if not transaction.handle.get_localdb().get_pkg(choose_list[line][1]):
|
if not choose_list[line][1] in transaction.localpkgs.keys():
|
||||||
transaction.to_add.append(choose_list[line][1])
|
transaction.to_provide.append(choose_list[line][1])
|
||||||
if choose_list[line][0] is False:
|
if choose_list[line][0] is False:
|
||||||
if choose_list[line][1] in transaction.to_add:
|
if choose_list[line][1] in transaction.to_provide:
|
||||||
transaction.to_add.remove(choose_list[line][1])
|
transaction.to_provide.remove(choose_list[line][1])
|
||||||
line += 1
|
line += 1
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -198,6 +198,7 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
error = ''
|
error = ''
|
||||||
try:
|
try:
|
||||||
t.sysupgrade(downgrade=False)
|
t.sysupgrade(downgrade=False)
|
||||||
|
print('to_upgrade:',t.to_add)
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
finally:
|
finally:
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
import pyalpm
|
import pyalpm
|
||||||
|
from collections import OrderedDict
|
||||||
import dbus
|
import dbus
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
|
|
||||||
@ -22,16 +23,29 @@ action_icon = interface.get_object('action_icon')
|
|||||||
ProgressCancelButton = interface.get_object('ProgressCancelButton')
|
ProgressCancelButton = interface.get_object('ProgressCancelButton')
|
||||||
|
|
||||||
t_lock = False
|
t_lock = False
|
||||||
do_syncfirst = False
|
|
||||||
list_first = []
|
|
||||||
to_remove = []
|
to_remove = []
|
||||||
to_add = []
|
to_add = []
|
||||||
|
to_provide = []
|
||||||
to_update = []
|
to_update = []
|
||||||
handle = None
|
handle = None
|
||||||
|
syncpkgs = OrderedDict()
|
||||||
|
localpkgs = OrderedDict()
|
||||||
|
|
||||||
def get_handle():
|
def get_handle():
|
||||||
global handle
|
global handle
|
||||||
|
global syncpkgs
|
||||||
|
global localpkgs
|
||||||
|
syncpkgs = OrderedDict()
|
||||||
|
localpkgs = OrderedDict()
|
||||||
handle = config.pacman_conf.initialize_alpm()
|
handle = config.pacman_conf.initialize_alpm()
|
||||||
|
for repo in handle.get_syncdbs():
|
||||||
|
for pkg in repo.pkgcache:
|
||||||
|
if not pkg.name in syncpkgs.keys():
|
||||||
|
syncpkgs[pkg.name] = pkg
|
||||||
|
for pkg in handle.get_localdb().pkgcache:
|
||||||
|
if not pkg.name in localpkgs.keys():
|
||||||
|
localpkgs[pkg.name] = pkg
|
||||||
|
print('get handle')
|
||||||
|
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
@ -88,69 +102,6 @@ def init_transaction(**options):
|
|||||||
ErrorDialog.hide()
|
ErrorDialog.hide()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_conflicts():
|
|
||||||
global to_add
|
|
||||||
global to_remove
|
|
||||||
to_check = []
|
|
||||||
installed_pkg_name = []
|
|
||||||
syncdbs_pkg_name = []
|
|
||||||
warning = ''
|
|
||||||
for pkgname in to_add:
|
|
||||||
for repo in handle.get_syncdbs():
|
|
||||||
pkg = repo.get_pkg(pkgname)
|
|
||||||
if pkg:
|
|
||||||
to_check.append(pkg)
|
|
||||||
break
|
|
||||||
for installed_pkg in handle.get_localdb().pkgcache:
|
|
||||||
installed_pkg_name.append(installed_pkg.name)
|
|
||||||
for target in to_check:
|
|
||||||
for name in target.replaces:
|
|
||||||
if name in installed_pkg_name:
|
|
||||||
if not name in to_remove:
|
|
||||||
to_remove.append(name)
|
|
||||||
if warning:
|
|
||||||
warning = warning+'\n'
|
|
||||||
warning = warning+name+' will be replaced by '+target.name
|
|
||||||
for name in target.conflicts:
|
|
||||||
#if common.format_pkg_name(name) in to_add:
|
|
||||||
if name in to_add:
|
|
||||||
#to_add.remove(common.format_pkg_name(name))
|
|
||||||
to_add.remove(name)
|
|
||||||
to_add.remove(target.name)
|
|
||||||
if warning:
|
|
||||||
warning = warning+'\n'
|
|
||||||
warning = warning+name+' conflicts with '+target.name+'\nNone of them will be installed'
|
|
||||||
if name in installed_pkg_name:
|
|
||||||
if not name in to_remove:
|
|
||||||
to_remove.append(name)
|
|
||||||
if warning:
|
|
||||||
warning = warning+'\n'
|
|
||||||
warning = warning+name+' conflicts with '+target.name
|
|
||||||
for installed_pkg in handle.get_localdb().pkgcache:
|
|
||||||
for name in installed_pkg.conflicts:
|
|
||||||
if name == target.name:
|
|
||||||
if not name in to_remove:
|
|
||||||
to_remove.append(installed_pkg.name)
|
|
||||||
if warning:
|
|
||||||
warning = warning+'\n'
|
|
||||||
warning = warning+installed_pkg.name+' conflicts with '+target.name
|
|
||||||
for repo in handle.get_syncdbs():
|
|
||||||
for pkg in repo.pkgcache:
|
|
||||||
for name in pkg.replaces:
|
|
||||||
if name in installed_pkg_name:
|
|
||||||
if not name in to_remove:
|
|
||||||
to_remove.append(name)
|
|
||||||
if warning:
|
|
||||||
warning = warning+'\n'
|
|
||||||
warning = warning+name+' will be replaced by '+pkg.name
|
|
||||||
if not pkg.name in to_add:
|
|
||||||
to_add.append(pkg.name)
|
|
||||||
if warning:
|
|
||||||
WarningDialog.format_secondary_text(warning)
|
|
||||||
response = WarningDialog.run()
|
|
||||||
if response:
|
|
||||||
WarningDialog.hide()
|
|
||||||
|
|
||||||
def get_to_remove():
|
def get_to_remove():
|
||||||
global to_remove
|
global to_remove
|
||||||
to_remove = To_Remove()
|
to_remove = To_Remove()
|
||||||
@ -161,30 +112,31 @@ def get_to_add():
|
|||||||
|
|
||||||
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
|
do_syncfirst = False
|
||||||
global list_first
|
list_first = []
|
||||||
get_handle()
|
#get_handle()
|
||||||
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)
|
||||||
if pkg:
|
if pkg:
|
||||||
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||||
if candidate:
|
if candidate:
|
||||||
list_first.append(candidate)
|
for repo in handle.get_syncdbs():
|
||||||
|
pkg = repo.get_pkg(candidate.name)
|
||||||
|
if pkg:
|
||||||
|
list_first.append(pkg)
|
||||||
|
break
|
||||||
if list_first:
|
if list_first:
|
||||||
do_syncfirst = True
|
do_syncfirst = True
|
||||||
return list_first
|
return do_syncfirst, list_first
|
||||||
result = []
|
result = []
|
||||||
installed_pkglist = handle.get_localdb().pkgcache
|
installed_pkglist = handle.get_localdb().pkgcache
|
||||||
for pkg in installed_pkglist:
|
for pkg in installed_pkglist:
|
||||||
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||||
if candidate:
|
if candidate:
|
||||||
result.append(candidate)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def get_new_version_available(pkgname):
|
|
||||||
for repo in handle.get_syncdbs():
|
for repo in handle.get_syncdbs():
|
||||||
pkg = repo.get_pkg(pkgname)
|
pkg = repo.get_pkg(candidate.name)
|
||||||
if pkg is not None:
|
if pkg:
|
||||||
return pkg.version
|
result.append(pkg)
|
||||||
break
|
break
|
||||||
|
return do_syncfirst, result
|
||||||
|
161
test.py
161
test.py
@ -4,17 +4,28 @@
|
|||||||
import pyalpm
|
import pyalpm
|
||||||
from pamac import config, common
|
from pamac import config, common
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
syncpkgs = OrderedDict()
|
#~ syncpkgs = OrderedDict()
|
||||||
localpkgs = OrderedDict()
|
#~ localpkgs = OrderedDict()
|
||||||
virtualdeps = {}
|
#~ virtualdeps = {}
|
||||||
|
|
||||||
for repo in config.handle.get_syncdbs():
|
class MyOrderedDict(OrderedDict):
|
||||||
for pkg in repo.pkgcache:
|
def keys(self):
|
||||||
if not pkg.name in syncpkgs.keys():
|
return [i for i in self]
|
||||||
syncpkgs[pkg.name] = pkg
|
def values(self):
|
||||||
for pkg in config.handle.get_localdb().pkgcache:
|
return [self[i] for i in self]
|
||||||
if not pkg.name in localpkgs.keys():
|
|
||||||
localpkgs[pkg.name] = pkg
|
d=MyOrderedDict()
|
||||||
|
d['pear']=3
|
||||||
|
d['apple']=2
|
||||||
|
print(d.items())
|
||||||
|
|
||||||
|
#~ for repo in config.handle.get_syncdbs():
|
||||||
|
#~ for pkg in repo.pkgcache:
|
||||||
|
#~ if not pkg.name in syncpkgs.keys():
|
||||||
|
#~ syncpkgs[pkg.name] = pkg
|
||||||
|
#~ for pkg in config.handle.get_localdb().pkgcache:
|
||||||
|
#~ if not pkg.name in localpkgs.keys():
|
||||||
|
#~ localpkgs[pkg.name] = pkg
|
||||||
#~ for pkg in syncpkgs.values():
|
#~ for pkg in syncpkgs.values():
|
||||||
#~ for name in pkg.depends:
|
#~ for name in pkg.depends:
|
||||||
#~ if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name):
|
#~ if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name):
|
||||||
@ -23,68 +34,68 @@ for pkg in config.handle.get_localdb().pkgcache:
|
|||||||
#~ virtualdeps[name] = []
|
#~ virtualdeps[name] = []
|
||||||
#~ virtualdeps.get(name).append(pkg.name)
|
#~ virtualdeps.get(name).append(pkg.name)
|
||||||
|
|
||||||
to_add = ['libreoffice-writer', 'anjuta']
|
#~ to_add = ['libreoffice-writer', 'anjuta']
|
||||||
depends = [[syncpkgs['libreoffice-writer'],syncpkgs['anjuta']]]
|
#~ depends = [[syncpkgs['libreoffice-writer'],syncpkgs['anjuta']]]
|
||||||
to_provide = []
|
#~ to_provide = []
|
||||||
to_remove = []
|
#~ to_remove = []
|
||||||
warning = ''
|
#~ warning = ''
|
||||||
i = 0
|
#~ i = 0
|
||||||
while depends[i]:
|
#~ while depends[i]:
|
||||||
depends.append([])
|
#~ depends.append([])
|
||||||
for pkg in depends[i]:
|
#~ for pkg in depends[i]:
|
||||||
for depend in pkg.depends:
|
#~ for depend in pkg.depends:
|
||||||
provide = pyalpm.find_satisfier(localpkgs.values(), depend)
|
#~ provide = pyalpm.find_satisfier(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 ('-module' in depend) or ('linux' in depend):
|
#~ if ('-module' in depend) or ('linux' in depend):
|
||||||
to_provide.append(depend)
|
#~ to_provide.append(depend)
|
||||||
else:
|
#~ else:
|
||||||
provide = pyalpm.find_satisfier(syncpkgs.values(), depend)
|
#~ provide = pyalpm.find_satisfier(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):
|
||||||
print(provide.name,common.format_pkg_name(depend))
|
#~ print(provide.name,common.format_pkg_name(depend))
|
||||||
to_provide.append(depend)
|
#~ to_provide.append(depend)
|
||||||
else:
|
#~ else:
|
||||||
depends[i+1].append(provide)
|
#~ depends[i+1].append(provide)
|
||||||
for replace in pkg.replaces:
|
#~ for replace in pkg.replaces:
|
||||||
provide = pyalpm.find_satisfier(localpkgs.values(), replace)
|
#~ provide = pyalpm.find_satisfier(localpkgs.values(), replace)
|
||||||
if provide:
|
#~ if provide:
|
||||||
if not provide.name in to_remove:
|
#~ if not provide.name in to_remove:
|
||||||
to_remove.append(provide.name)
|
#~ to_remove.append(provide.name)
|
||||||
if warning:
|
#~ if warning:
|
||||||
warning = warning+'\n'
|
#~ warning = warning+'\n'
|
||||||
warning = warning+provide.name+' will be replaced by '+pkg.name
|
#~ warning = warning+provide.name+' will be replaced by '+pkg.name
|
||||||
for conflict in pkg.conflicts:
|
#~ for conflict in pkg.conflicts:
|
||||||
provide = pyalpm.find_satisfier(localpkgs.values(), conflict)
|
#~ provide = pyalpm.find_satisfier(localpkgs.values(), conflict)
|
||||||
if provide:
|
#~ if provide:
|
||||||
if not provide.name in to_remove:
|
#~ if not provide.name in to_remove:
|
||||||
to_remove.append(provide.name)
|
#~ to_remove.append(provide.name)
|
||||||
if warning:
|
#~ if warning:
|
||||||
warning = warning+'\n'
|
#~ warning = warning+'\n'
|
||||||
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) in to_remove:
|
#~ 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:
|
#~ 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(common.format_pkg_name(conflict))
|
||||||
to_add.remove(pkg.name)
|
#~ to_add.remove(pkg.name)
|
||||||
if warning:
|
#~ if warning:
|
||||||
warning = warning+'\n'
|
#~ warning = warning+'\n'
|
||||||
warning = warning+pkg.name+' conflicts with '+common.format_pkg_name(conflict)+'\nNone of them will be installed'
|
#~ warning = warning+pkg.name+' conflicts with '+common.format_pkg_name(conflict)+'\nNone of them will be installed'
|
||||||
i = i + 1
|
#~ i = i + 1
|
||||||
for pkg in localpkgs.values():
|
#~ for pkg in localpkgs.values():
|
||||||
for conflict in pkg.conflicts:
|
#~ for conflict in pkg.conflicts:
|
||||||
provide = pyalpm.find_satisfier(depends[0], conflict)
|
#~ provide = pyalpm.find_satisfier(depends[0], conflict)
|
||||||
if provide:
|
#~ if provide:
|
||||||
if not provide.name in to_remove:
|
#~ if not provide.name in to_remove:
|
||||||
to_remove.append(pkg.name)
|
#~ to_remove.append(pkg.name)
|
||||||
if warning:
|
#~ if warning:
|
||||||
warning = warning+'\n'
|
#~ warning = warning+'\n'
|
||||||
warning = warning+provide.name+' conflicts with '+pkg.name
|
#~ warning = warning+provide.name+' conflicts with '+pkg.name
|
||||||
print('depends:',depends)
|
#~ print('depends:',depends)
|
||||||
print('to provide:',to_provide)
|
#~ print('to provide:',to_provide)
|
||||||
print('to add:',to_add)
|
#~ print('to add:',to_add)
|
||||||
print('to remove:',to_remove)
|
#~ print('to remove:',to_remove)
|
||||||
print(warning)
|
#~ print(warning)
|
||||||
|
Loading…
Reference in New Issue
Block a user