Exemple #1
0
    def plan_install_item(self, item):
        """ Plan the installation of a given item """
        trans = Transaction(item)

        # We only install one requested item at a time
        order = set([item.get_id()])
        # Now ensure system.base upgrade is present because we satisfy safety
        order |= upgrade_base(order)
        # Push the installation set here
        (pg, pkgs) = plan_install_pkg_names(order)

        # If system.base is defined (should be!) put base packages first
        if self.compDB.has_component("system.base"):
            pkgs = pisi_helper.reorder_base_packages(pkgs)

        for name in pkgs:
            if self.installDB.has_package(name):
                # Have the package so its an update now
                trans.push_upgrade(self.build_item(name))
            else:
                # Newly installed through dependency
                trans.push_installation(self.build_item(name))

        # Potential conflict?
        conflicts = pisi_helper.check_conflicts(pkgs, self.availDB)
        if conflicts:
            for name in conflicts:
                trans.push_removal(self.build_item(name))

        return trans
Exemple #2
0
    def plan_install_item(self, item):
        """ Plan the installation of a given item """
        trans = Transaction(item)

        # We only install one requested item at a time
        order = set([item.get_id()])
        # Now ensure system.base upgrade is present because we satisfy safety
        order |= upgrade_base(order)
        # Push the installation set here
        (pg, pkgs) = plan_install_pkg_names(order)

        # If system.base is defined (should be!) put base packages first
        if self.compDB.has_component("system.base"):
            pkgs = pisi_helper.reorder_base_packages(pkgs)

        for name in pkgs:
            if self.installDB.has_package(name):
                # Have the package so its an update now
                trans.push_upgrade(self.build_item(name))
            else:
                # Newly installed through dependency
                trans.push_installation(self.build_item(name))

        # Potential conflict?
        conflicts = pisi_helper.check_conflicts(pkgs, self.availDB)
        if conflicts:
            for name in conflicts:
                trans.push_removal(self.build_item(name))

        return trans
Exemple #3
0
 def plan_install_item(self, item):
     """ Plan the installation of a given item """
     (pg, pkgs) = plan_install_pkg_names([item.get_id()])
     # We only want the package set, not the graph
     ret = []
     for name in pkgs:
         ret.append(self.build_item(name))
     return ret
Exemple #4
0
    def apply_operations(self):
        self.doing_things = True
        updates = [
            i for i in self.operations if self.operations[i] == 'UPDATE'
        ]
        installs = [
            i for i in self.operations if self.operations[i] == 'INSTALL'
        ]
        removals = [
            i for i in self.operations if self.operations[i] == 'UNINSTALL'
        ]

        # We monitor 4 post events
        STEPS = 4

        self.installdb = pisi.db.installdb.InstallDB()
        self.packagedb = pisi.db.packagedb.PackageDB()

        self.emit('basket-changed', None)
        # print "%d packages updated" % len(updates)
        # print "%d packages installed" % len(installs)
        # print "%d packages removed" % len(removals)

        setAct = False

        for packageset in [updates, installs, removals]:
            if len(packageset) == 0:
                continue

            self.current_package = 1
            self.current_dl_package = 1

            if packageset == installs:
                (pg, pkgs) = plan_install_pkg_names(packageset)
                if len(pkgs) > len(packageset):
                    p = [x for x in pkgs if x not in packageset]
                    if self.show_dialog(p):
                        installs = packageset = pkgs
                    else:
                        # print "Not installing"
                        continue
            elif packageset == removals:
                (pk, pkgs) = plan_remove(packageset)
                if len(pkgs) > len(packageset):
                    p = [x for x in pkgs if x not in packageset]
                    if self.show_dialog(p, remove=True):
                        removals = packageset = pkgs
                    else:
                        # print "Not removing"
                        continue
            elif packageset == updates:
                (pk, pkgs) = plan_upgrade(packageset)
                if len(pkgs) > len(packageset):
                    p = [x for x in pkgs if x not in packageset]
                    if self.show_dialog(p, update=True):
                        updates = packageset = pkgs
                    else:
                        # print Not continuing
                        continue
            self.total_packages = len(packageset)
            setAct = True

            if packageset != removals:
                self.total_size = self.get_sizes(packageset)
                # one tenth of progress is post install
                self.step_offset = self.total_size / 10
                self.progress_total = self.total_size + \
                    ((self.step_offset * self.total_packages) * STEPS)
            else:
                self.total_size = self.total_packages * (STEPS / 2)
                self.step_offset = 1
                self.progress_total = self.total_size
            self.progress_current = 0

            self.current_operations = packageset

            self.cb = self.invalidate_all
            if packageset == updates:
                self.pmanager.updatePackage(",".join(packageset),
                                            async=self.pisi_callback)
            elif packageset == installs:
                self.pmanager.installPackage(",".join(packageset),
                                             async=self.pisi_callback)
            elif packageset == removals:
                self.pmanager.removePackage(",".join(packageset),
                                            async=self.pisi_callback)
        if not setAct:
            self.invalidate_all()
            self.update_ui()
Exemple #5
0
    def apply_operations(self):
        self.doing_things = True
        updates = [
            i for i in self.operations if self.operations[i] == 'UPDATE'
        ]
        installs = [
            i for i in self.operations if self.operations[i] == 'INSTALL'
        ]
        removals = [
            i for i in self.operations if self.operations[i] == 'UNINSTALL'
        ]

        # We monitor 4 post events
        STEPS = 4

        self.installdb = pisi.db.installdb.InstallDB()
        self.packagedb = pisi.db.packagedb.PackageDB()

        self.emit('apply', None)
        # print "%d packages updated" % len(updates)
        # print "%d packages installed" % len(installs)
        # print "%d packages removed" % len(removals)

        setAct = False

        for packageset in [updates, installs, removals]:
            if len(packageset) == 0:
                continue

            self.current_package = 1
            self.current_dl_package = 1

            if packageset == installs:
                (pg, pkgs) = plan_install_pkg_names(packageset)
                if len(pkgs) > len(packageset):
                    p = [x for x in pkgs if x not in packageset]
                    if self.show_dialog(p):
                        installs = packageset = pkgs
                    else:
                        # print "Not installing"
                        continue
            elif packageset == removals:
                (pk, pkgs) = plan_remove(packageset)
                if len(pkgs) > len(packageset):
                    p = [x for x in pkgs if x not in packageset]
                    if self.show_dialog(p, remove=True):
                        removals = packageset = pkgs
                    else:
                        # print "Not removing"
                        continue
            elif packageset == updates:
                (pk, pkgs) = plan_upgrade(packageset)
                if len(pkgs) > len(packageset):
                    p = [x for x in pkgs if x not in packageset]
                    if self.show_dialog(p, update=True):
                        updates = packageset = pkgs
                    else:
                        # print Not continuing
                        continue
            self.total_packages = len(packageset)
            setAct = True

            if packageset != removals:
                self.total_size = self.get_sizes(packageset)
                # one tenth of progress is post install
                self.step_offset = self.total_size / 10
                self.progress_total = self.total_size + \
                    ((self.step_offset * self.total_packages) * STEPS)
            else:
                self.total_size = self.total_packages * (STEPS / 2)
                self.step_offset = 1
                self.progress_total = self.total_size
            self.progress_current = 0

            self.current_operations = packageset

            self.cb = self.invalidate_all
            if packageset == updates:
                self.pmanager.updatePackage(
                    ",".join(packageset), async=self.pisi_callback)
            elif packageset == installs:
                self.pmanager.installPackage(
                    ",".join(packageset), async=self.pisi_callback)
            elif packageset == removals:
                self.pmanager.removePackage(
                    ",".join(packageset), async=self.pisi_callback)
        if not setAct:
            self.invalidate_all()
            self.update_ui()