Esempio n. 1
0
def do_sysupgrade():
    global transaction_type
    """Upgrade a system like pacman -Su"""
    if transaction.t_lock is False:
        transaction_type = "update"
        do_syncfirst, updates = transaction.get_updates()
        if updates:
            transaction.to_add = []
            transaction.to_remove = []
            check_conflicts(updates)
            if do_syncfirst:
                for pkg in updates:
                    transaction.to_add.append(pkg.name)
                if transaction.init_transaction(recurse=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()
                        set_transaction_sum()
                        if mode == "updater":
                            if len(transaction.to_add) + len(transaction.to_remove) != 0:
                                ConfDialog.show_all()
                            else:
                                finalize()
                        if mode == "manager":
                            ConfDialog.show_all()
            else:
                if transaction.init_transaction(noconflicts=True):
                    error = transaction.Sysupgrade()
                    if error:
                        handle_error(error)
                    else:
                        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()
                            set_transaction_sum()
                            if mode == "updater":
                                if len(transaction.to_add) + len(transaction.to_remove) != 0:
                                    ConfDialog.show_all()
                                else:
                                    finalize()
                            if mode == "manager":
                                ConfDialog.show_all()
Esempio n. 2
0
 def on_Manager_ValidButton_clicked(self, *arg):
     if not transaction_dict:
         transaction.ErrorDialog.format_secondary_text("No package is selected")
         response = transaction.ErrorDialog.run()
         if response:
             transaction.ErrorDialog.hide()
     else:
         if transaction.t_lock is True:
             print("Transaction locked")
         else:
             if transaction_type is "remove":
                 if transaction.init_transaction(cascade=True, unneeded=True):
                     for pkgname in transaction_dict.keys():
                         transaction.Remove(pkgname)
                     error = transaction.Prepare()
                     if error:
                         handle_error(error)
                     else:
                         transaction.get_to_remove()
                         transaction.get_to_add()
                         set_transaction_sum()
                         ConfDialog.show_all()
             if transaction_type is "install":
                 transaction.to_add = []
                 for pkgname in transaction_dict.keys():
                     transaction.to_add.append(pkgname)
                 transaction.to_remove = []
                 check_conflicts(transaction_dict.values())
                 if transaction.to_add:
                     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()
                             set_transaction_sum()
                             ConfDialog.show_all()
                 else:
                     transaction.WarningDialog.format_secondary_text("Nothing to do")
                     response = transaction.WarningDialog.run()
                     if response:
                         transaction.WarningDialog.hide()
                     transaction.t_lock = False