From 90b04d031958a854b821712a0603ae5c1ce1504b Mon Sep 17 00:00:00 2001 From: guinux Date: Sun, 27 Jan 2013 18:15:34 +0100 Subject: [PATCH] continue --- gui/dialogs.glade | 1 + gui/manager.glade | 109 +++++++++++++++++++++++++++++++++++++++++++ pamac/manager.py | 62 ++++++++++++++++++++++-- pamac/transaction.py | 34 +++----------- test.py | 19 ++++++++ 5 files changed, 194 insertions(+), 31 deletions(-) create mode 100755 test.py diff --git a/gui/dialogs.glade b/gui/dialogs.glade index f7bb8d3..b3de14a 100644 --- a/gui/dialogs.glade +++ b/gui/dialogs.glade @@ -43,6 +43,7 @@ Progress False True + center-on-parent 250 60 /usr/share/pamac/icons/22x22/status/setup.png diff --git a/gui/manager.glade b/gui/manager.glade index 5f7bda4..8f71edc 100644 --- a/gui/manager.glade +++ b/gui/manager.glade @@ -1,6 +1,107 @@ + + False + True + center-on-parent + dialog + True + True + + + True + False + vertical + 5 + + + True + False + label + + + False + True + 0 + + + + + True + True + in + + + True + True + choose_list + False + False + False + + + multiple + + + + + column + + + + + + 0 + + + + + + 1 + + + + + + + + + True + True + 1 + + + + + True + False + end + + + gtk-ok + True + True + True + True + + + + False + True + 0 + + + + + False + True + 2 + + + + + False @@ -504,6 +605,14 @@ + + + + + + + + diff --git a/pamac/manager.py b/pamac/manager.py index 1613370..1f803b2 100755 --- a/pamac/manager.py +++ b/pamac/manager.py @@ -27,12 +27,16 @@ ConfDialog = interface.get_object('ConfDialog') transaction_sum = interface.get_object('transaction_sum') top_label = interface.get_object('top_label') bottom_label = interface.get_object('bottom_label') +ChooseDialog = interface.get_object('ChooseDialog') +choose_list = interface.get_object('choose_list') installed_column.set_sort_column_id(1) name_column.set_sort_column_id(0) +transaction.get_handle() + tmp_list = [] -for repo in config.pacman_conf.initialize_alpm().get_syncdbs(): +for repo in transaction.handle.get_syncdbs(): for name, pkgs in repo.grpcache: if not name in tmp_list: tmp_list.append(name) @@ -55,13 +59,13 @@ def set_list_dict_search(*patterns): pkg_name_list = [] pkg_object_dict = {} pkg_installed_dict = {} - for db in config.pacman_conf.initialize_alpm().get_syncdbs(): + for db in transaction.handle.get_syncdbs(): for pkg_object in db.search(*patterns): if not pkg_object.name in pkg_name_list: pkg_name_list.append(pkg_object.name) pkg_object_dict[pkg_object.name] = pkg_object pkg_installed_dict[pkg_object.name] = False - for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().search(*patterns): + for pkg_object in transaction.handle.get_localdb().search(*patterns): if not pkg_object.name in pkg_name_list: pkg_name_list.append(pkg_object.name) pkg_installed_dict[pkg_object.name] = True @@ -75,7 +79,7 @@ def set_list_dict_group(group): pkg_name_list = [] pkg_object_dict = {} pkg_installed_dict = {} - for db in config.pacman_conf.initialize_alpm().get_syncdbs(): + for db in transaction.handle.get_syncdbs(): grp = db.read_grp(group) if grp is not None: name, pkg_list = grp @@ -295,6 +299,42 @@ def handle_reply(reply): transaction_type = None set_packages_list() +def choose_provides(): + to_check = [] + depends = [] + provides = {} + for pkgname in transaction.to_add: + for repo in transaction.handle.get_syncdbs(): + pkg = repo.get_pkg(pkgname) + if pkg: + to_check.append(pkg) + break + for target in to_check: + for name in target.depends: + depends.append(name) + for installed_pkg in transaction.handle.get_localdb().pkgcache: + if installed_pkg.name in depends: + depends.remove(installed_pkg.name) + for repo in transaction.handle.get_syncdbs(): + for pkg in repo.pkgcache: + if pkg.name in depends: + depends.remove(pkg.name) + if depends: + 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 not provides.__contains__(depend): + provides[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() + class Handler: def on_MainWindow_delete_event(self, *arg): transaction.StopDaemon() @@ -350,6 +390,7 @@ class Handler: 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: @@ -494,6 +535,19 @@ class Handler: packages_list[line][1] = not packages_list[line][1] packages_list[line][2] = True + def on_cellrenderertoggle2_toggled(self, widget, line): + choose_list[line][0] = not choose_list[line][0] + + def on_ChooseButton_clicked(self, *arg): + ChooseDialog.hide() + 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]) + line += 1 + def main(): interface.connect_signals(Handler()) transaction.do_refresh() diff --git a/pamac/transaction.py b/pamac/transaction.py index cadc6b6..cea9ce9 100755 --- a/pamac/transaction.py +++ b/pamac/transaction.py @@ -94,8 +94,6 @@ def check_conflicts(): to_check = [] installed_pkg_name = [] syncdbs_pkg_name = [] - depends = [] - provides = {} warning = '' for pkgname in to_add: for repo in handle.get_syncdbs(): @@ -106,8 +104,6 @@ def check_conflicts(): for installed_pkg in handle.get_localdb().pkgcache: installed_pkg_name.append(installed_pkg.name) for target in to_check: - for name in target.depends: - depends.append(name) for name in target.replaces: if name in installed_pkg_name: if not name in to_remove: @@ -129,16 +125,13 @@ def check_conflicts(): warning = warning+'\n' warning = warning+name+' conflicts with '+target.name for installed_pkg in handle.get_localdb().pkgcache: - if installed_pkg.conflicts: - 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 - if installed_pkg.name in depends: - depends.remove(installed_pkg.name) + 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: @@ -150,19 +143,6 @@ def check_conflicts(): warning = warning+name+' will be replaced by '+pkg.name if not pkg.name in to_add: to_add.append(pkg.name) - if pkg.name in depends: - depends.remove(pkg.name) - if depends: - for repo in handle.get_syncdbs(): - for pkg in repo.pkgcache: - for depend in depends: - for name in pkg.provides: - if name == depend: - if not provides.__contains__(depend): - provides[depend] = [] - provides.get(depend).append(pkg.name) - if provides: - print(provides) if warning: WarningDialog.format_secondary_text(warning) response = WarningDialog.run() diff --git a/test.py b/test.py new file mode 100755 index 0000000..fbad541 --- /dev/null +++ b/test.py @@ -0,0 +1,19 @@ +#! /usr/bin/python +# -*-coding:utf-8 -*- + +from pamac import config + +syncpkgs = {} +virtualdeps = {} + +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 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 not virtualdeps.__contains__(name): + virtualdeps[name] = [] + virtualdeps.get(name).append(pkg.name) +print(virtualdeps)