diff --git a/gui/manager.glade b/gui/manager.glade index 8f71edc0bd227a1beec53303d53f972e13850aea..6ce630c6705eb032e75595479fe37c333624f129 100644 --- a/gui/manager.glade +++ b/gui/manager.glade @@ -1,19 +1,46 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.0 --> - <object class="GtkWindow" id="ChooseDialog"> + <object class="GtkDialog" id="ChooseDialog"> <property name="can_focus">False</property> + <property name="border_width">5</property> <property name="modal">True</property> <property name="window_position">center-on-parent</property> <property name="type_hint">dialog</property> <property name="skip_taskbar_hint">True</property> <property name="urgency_hint">True</property> - <child> - <object class="GtkBox" id="box8"> - <property name="visible">True</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> <property name="orientation">vertical</property> - <property name="spacing">5</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ChooseButton"> + <property name="label">gtk-ok</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="on_ChooseButton_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> <child> <object class="GtkLabel" id="chooselabel"> <property name="visible">True</property> @@ -23,7 +50,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> <child> @@ -31,6 +58,8 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="shadow_type">in</property> + <property name="min_content_width">300</property> + <property name="min_content_height">250</property> <child> <object class="GtkTreeView" id="treeview5"> <property name="visible">True</property> @@ -39,10 +68,9 @@ <property name="headers_visible">False</property> <property name="headers_clickable">False</property> <property name="enable_search">False</property> + <property name="search_column">0</property> <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection5"> - <property name="mode">multiple</property> - </object> + <object class="GtkTreeSelection" id="treeview-selection5"/> </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn1"> @@ -69,38 +97,14 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButtonBox" id="buttonbox3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="ChooseButton"> - <property name="label">gtk-ok</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - <signal name="clicked" handler="on_ChooseButton_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> <property name="position">2</property> </packing> </child> </object> </child> + <action-widgets> + <action-widget response="0">ChooseButton</action-widget> + </action-widgets> </object> <object class="GtkWindow" id="ConfDialog"> <property name="can_focus">False</property> @@ -133,13 +137,13 @@ </child> <child> <object class="GtkScrolledWindow" id="scrolledwindow4"> - <property name="width_request">200</property> - <property name="height_request">120</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="shadow_type">in</property> + <property name="min_content_width">300</property> + <property name="min_content_height">250</property> <child> <object class="GtkTreeView" id="treeview4"> <property name="visible">True</property> diff --git a/pamac/common.py b/pamac/common.py index 1e2d1df69020fa5fed5ace9232c0e29de4e09538..55b271d56ecfaaf200f09548749a9d6c93359dbc 100755 --- a/pamac/common.py +++ b/pamac/common.py @@ -9,3 +9,11 @@ def format_size(size): else: size_string = '%.2f MiB' % (KiB_size / 1024) return size_string + +def format_pkg_name(name): + unwanted = ['>','<','='] + for i in unwanted: + index = name.find(i) + if index != -1: + name = name[0:index] + return name diff --git a/pamac/manager.py b/pamac/manager.py index 1f803b2774425050eb826d6caf942c08a675ac57..b4bf1eca94e52923b033293a688638afdb8a9772 100755 --- a/pamac/manager.py +++ b/pamac/manager.py @@ -226,47 +226,11 @@ def set_transaction_sum(): #bottom_label.set_markup('<b>Total Download size: </b>'+common.format_size(totaldlcb)) top_label.set_markup('<big><b>Transaction Summary</b></big>') -def do_sysupgrade(): - global transaction_type - """Upgrade a system like pacman -Su""" - if transaction.t_lock is False: - transaction_type = "update" - if transaction.do_syncfirst is True: - if transaction.init_transaction(recurse = True): - for pkg in transaction.list_first: - transaction.Add(pkg.name) - transaction.get_to_remove() - transaction.get_to_add() - transaction.check_conflicts() - transaction.Release() - set_transaction_sum() - ConfDialog.show_all() - else: - if transaction.init_transaction(): - error = transaction.Sysupgrade() - if error: - transaction.ErrorDialog.format_secondary_text(error) - response = transaction.ErrorDialog.run() - if response: - transaction.ErrorDialog.hide() - transaction.Release() - transaction.t_lock = False - transaction.get_to_remove() - 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() - ConfDialog.show_all() - else: - transaction.Release() - transaction.t_lock = False - def handle_error(error): global transaction_type global transaction_dict if not 'DBus.Error.NoReply' in str(error): - transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(error)) + transaction.ErrorDialog.format_secondary_text('Error:\n'+str(error)) response = transaction.ErrorDialog.run() if response: transaction.ErrorDialog.hide() @@ -278,12 +242,13 @@ def handle_error(error): transaction_dict.clear() transaction_type = None set_packages_list() + print('error',error) def handle_reply(reply): global transaction_type global transaction_dict if str(reply): - transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(reply)) + transaction.ErrorDialog.format_secondary_text('Error:\n'+str(reply)) response = transaction.ErrorDialog.run() if response: transaction.ErrorDialog.hide() @@ -296,8 +261,57 @@ def handle_reply(reply): transaction.to_add = [] transaction.to_remove = [] transaction_dict.clear() - transaction_type = None - set_packages_list() + if (transaction_type == "install") or (transaction_type == "remove"): + transaction_type = None + set_packages_list() + else: + transaction_type = None + if transaction.get_updates(): + do_sysupgrade() + +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 do_sysupgrade(): + global transaction_type + """Upgrade a system like pacman -Su""" + if transaction.t_lock is False: + transaction_type = "update" + if transaction.do_syncfirst is True: + if transaction.init_transaction(recurse = True): + for pkg in transaction.list_first: + transaction.Add(pkg.name) + transaction.get_to_remove() + transaction.get_to_add() + transaction.check_conflicts() + transaction.Release() + set_transaction_sum() + ConfDialog.show_all() + else: + if transaction.init_transaction(): + error = transaction.Sysupgrade() + if error: + handle_error(error) + else: + transaction.get_to_remove() + 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() + ConfDialog.show_all() + else: + transaction.Release() + transaction.t_lock = False def choose_provides(): to_check = [] @@ -311,7 +325,7 @@ def choose_provides(): break for target in to_check: for name in target.depends: - depends.append(name) + depends.append(common.format_pkg_name(name)) for installed_pkg in transaction.handle.get_localdb().pkgcache: if installed_pkg.name in depends: depends.remove(installed_pkg.name) @@ -320,20 +334,55 @@ def choose_provides(): if pkg.name in depends: depends.remove(pkg.name) if depends: + for installed_pkg in transaction.handle.get_localdb().pkgcache: + for name in pkg.provides: + if common.format_pkg_name(name) in depends: + depends.remove(common.format_pkg_name(name)) for repo in transaction.handle.get_syncdbs(): for pkg in repo.pkgcache: for depend in depends: for name in pkg.provides: - if name == depend: + if common.format_pkg_name(name) == depend: if not provides.__contains__(depend): provides[depend] = [] - provides.get(depend).append(pkg.name) - if provides: + if not pkg.name in provides.get(depend): + provides.get(depend).append(pkg.name) + if provides: for virtualdep, liste in provides.items(): - choose_list.clear() - for name in liste: - choose_list.append([False, name]) - ChooseDialog.show_all() + if ('-module' in virtualdep) or ('linux' in virtualdep): + print('choose module') + pkgs = transaction.handle.get_localdb().search('linux3') + installed_linux = [] + to_remove_from_add = [] + for i in pkgs: + if len(i.name) == 7: + installed_linux.append(i.name) + for to_install in transaction.to_add: + if 'linux3' in to_install: + if len(to_install) == 7: + if to_install in transaction_dict.keys(): + installed_linux.append(to_install) + else: + to_remove_from_add.append(to_install) + for name in liste: + if name == to_install: + if not to_install in transaction_dict.keys(): + to_remove_from_add.append(to_install) + for to_remove in to_remove_from_add: + transaction.to_add.remove(to_remove) + for name in liste: + for linux in installed_linux: + if not transaction.handle.get_localdb().get_pkg(name): + if linux in name: + transaction.to_add.append(name) + else: + choose_list.clear() + for name in liste: + if transaction.handle.get_localdb().get_pkg(name): + choose_list.append([True, name]) + else: + choose_list.append([False, name]) + ChooseDialog.run() class Handler: def on_MainWindow_delete_event(self, *arg): @@ -366,34 +415,38 @@ class Handler: transaction.Remove(pkgname) error = transaction.Prepare() if error: - transaction.ErrorDialog.format_secondary_text(error) - response = transaction.ErrorDialog.run() - if response: - transaction.ErrorDialog.hide() - transaction.Release() - transaction.t_lock = False - transaction.get_to_remove() - transaction.get_to_add() - set_transaction_sum() - ConfDialog.show_all() + handle_error(error) + else: + transaction.get_to_remove() + transaction.get_to_add() + set_transaction_sum() + ConfDialog.show_all() if transaction_type is "install": if transaction.init_transaction(noconflicts = True): for pkgname in transaction_dict.keys(): transaction.Add(pkgname) error = transaction.Prepare() if error: - transaction.ErrorDialog.format_secondary_text(error) - response = transaction.ErrorDialog.run() - if response: - transaction.ErrorDialog.hide() + handle_error(error) + else: + transaction.get_to_remove() + transaction.get_to_add() transaction.Release() - transaction.t_lock = False - transaction.get_to_remove() - transaction.get_to_add() - #choose_provides() - transaction.check_conflicts() - transaction.Release() - if len(transaction.to_add) + len(transaction.to_update) + len(transaction.to_remove) != 0: + choose_provides() + transaction.check_conflicts() + if transaction.init_transaction(noconflicts = True): + 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.get_to_remove() + transaction.get_to_add() + transaction.Release() + if len(transaction.to_add) + len(transaction.to_remove) != 0: set_transaction_sum() ConfDialog.show_all() else: @@ -412,7 +465,7 @@ class Handler: def on_RefreshButton_clicked(self, *arg): transaction.do_refresh() - refresh_packages_list() + set_packages_list() def on_TransCancelButton_clicked(self, *arg): global transaction_type @@ -427,6 +480,7 @@ class Handler: ConfDialog.hide() transaction.progress_label.set_text('Preparing...') transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png') + transaction.progress_bar.set_text('') while Gtk.events_pending(): Gtk.main_iteration() if transaction_type == "remove": @@ -434,7 +488,7 @@ class Handler: 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 "update"): + 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) @@ -444,12 +498,7 @@ class Handler: transaction.Remove(pkgname) error = transaction.Prepare() if error: - transaction.ErrorDialog.format_secondary_text(error) - response = transaction.ErrorDialog.run() - if response: - transaction.ErrorDialog.hide() - transaction.Release() - transaction.t_lock = False + handle_error(error) else: transaction.ProgressWindow.show_all() while Gtk.events_pending(): @@ -543,23 +592,18 @@ class Handler: line = 0 while line < len(choose_list): if choose_list[line][0] is True: - transaction.to_add.append(snap_list[line][1]) - elif choose_list[line][0] in transaction.to_add: - transaction.to_add.remove(snap_list[line][1]) + if not choose_list[line][1] in transaction.to_add: + if not transaction.handle.get_localdb().get_pkg(choose_list[line][1]): + transaction.to_add.append(choose_list[line][1]) + if choose_list[line][0] is False: + if choose_list[line][1] in transaction.to_add: + transaction.to_add.remove(choose_list[line][1]) line += 1 + print(transaction.to_add) def main(): interface.connect_signals(Handler()) - transaction.do_refresh() - do_sysupgrade() - #~ if transaction.get_updates(): - #~ transaction.QuestionDialog.format_secondary_text("Some updates are available.\nIt is higly recommended to update your system before installing/removing software.\nDo you want to update your system now ?") - #~ response = transaction.QuestionDialog.run() - #~ if response == Gtk.ResponseType.YES: - #~ transaction.QuestionDialog.hide() - #~ do_sysupgrade() - #~ else: - #~ transaction.QuestionDialog.hide() + do_refresh() MainWindow.show_all() while Gtk.events_pending(): Gtk.main_iteration() @@ -567,4 +611,3 @@ def main(): if __name__ == "__main__": main() Gtk.main() - diff --git a/pamac/transaction.py b/pamac/transaction.py index cea9ce92389a6030480f9624e2cf594edcce78c6..be1b43f1b4756f0f66708984808d718d8d4b9909 100755 --- a/pamac/transaction.py +++ b/pamac/transaction.py @@ -7,7 +7,7 @@ import pyalpm import dbus from dbus.mainloop.glib import DBusGMainLoop -from pamac import config +from pamac import config, common interface = Gtk.Builder() interface.add_from_file('/usr/share/pamac/gui/dialogs.glade') @@ -105,29 +105,29 @@ def check_conflicts(): 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 common.format_pkg_name(name) in installed_pkg_name: + if not common.format_pkg_name(name) in to_remove: + to_remove.append(common.format_pkg_name(name)) if warning: warning = warning+'\n' warning = warning+name+' will be replaced by '+target.name for name in target.conflicts: - if name in to_add: - to_add.remove(name) + if common.format_pkg_name(name) in to_add: + to_add.remove(common.format_pkg_name(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 common.format_pkg_name(name) in installed_pkg_name: + if not common.format_pkg_name(name) in to_remove: + to_remove.append(common.format_pkg_name(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: + if common.format_pkg_name(name) == target.name: + if not common.format_pkg_name(name) in to_remove: to_remove.append(installed_pkg.name) if warning: warning = warning+'\n' @@ -135,12 +135,12 @@ def check_conflicts(): 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 common.format_pkg_name(name) in installed_pkg_name: + if not common.format_pkg_name(name) in to_remove: + to_remove.append(common.format_pkg_name(name)) if warning: warning = warning+'\n' - warning = warning+name+' will be replaced by '+pkg.name + warning = warning+common.format_pkg_name(name)+' will be replaced by '+pkg.name if not pkg.name in to_add: to_add.append(pkg.name) if warning: diff --git a/test.py b/test.py index fbad5414cdb040cc8d1bcf76ef5d88728229a1df..77a408208fe076087ac6125dd404f54f3672347b 100755 --- a/test.py +++ b/test.py @@ -13,6 +13,7 @@ for repo in config.handle.get_syncdbs(): for pkg in syncpkgs.values(): for name in pkg.depends: if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name): + if 'module' in name: if not virtualdeps.__contains__(name): virtualdeps[name] = [] virtualdeps.get(name).append(pkg.name)