示例#1
0
    def execute(self, server, options_dict, non_option_args):
        packages_to_remove = []

        for a in non_option_args:
            plist = rcpackageutils.find_package_on_system(server, a)

            if not plist:
                rctalk.error("Unable to find package '" + a + "'")
                sys.exit(1)

            for p in plist:
                dups = filter(lambda x, pn=p: x["name"] == pn["name"],
                              packages_to_remove)

                if dups:
                    rctalk.warning("Duplicate entry found: " + dups[0]["name"])
                else:
                    packages_to_remove.append(p)

        if not packages_to_remove:
            rctalk.message("--- No packages to remove ---")
            sys.exit(0)

        install_deps, remove_deps, dep_info = \
                      resolve_dependencies(server,
                                           [],
                                           packages_to_remove,
                                           [])

        self.transact(server, options_dict, [], [], packages_to_remove,
                      remove_deps)
示例#2
0
    def execute(self, server, options_dict, non_option_args):
        packages_to_remove = []
        
        for a in non_option_args:
            plist = rcpackageutils.find_package_on_system(server, a)

            if not plist:
                rctalk.error("Unable to find package '" + a + "'")
                sys.exit(1)

            for p in plist:
                dups = filter(lambda x, pn=p:x["name"] == pn["name"],
                              packages_to_remove)

                if dups:
                    rctalk.warning("Duplicate entry found: " + dups[0]["name"])
                else:
                    packages_to_remove.append(p)

        if not packages_to_remove:
            rctalk.message("--- No packages to remove ---")
            sys.exit(0)

        install_deps, remove_deps, dep_info = \
                      resolve_dependencies(server,
                                           [],
                                           packages_to_remove,
                                           [])

        self.transact(server, options_dict,
                      [], [],
                      packages_to_remove, remove_deps)
示例#3
0
    def execute(self, server, options_dict, non_option_args):
        packages_to_install = []
        packages_to_remove = []

        if options_dict.has_key("allow-unsubscribed"):
            allow_unsub = 1
        else:
            allow_unsub = 0

        if options_dict.has_key("entire-channel"):

            channel_list = []
            for a in non_option_args:
                matches = rcchannelutils.get_channels_by_name(server, a)
                if not rcchannelutils.validate_channel_list(a, matches):
                    sys.exit(1)
                channel_list.append(matches[0])

            contributors = 0
            for c in channel_list:
                query = [["channel", "=", c["id"]],
                         ["package-installed", "=", "false"]]
                packages = server.rcd.packsys.search(query)
                packages_to_install.extend(packages)
                if len(packages) > 0:
                    contributors = contributors + 1
                msg = "Found %d %s in channel '%s'" % \
                      (len(packages),
                       (len(packages) != 1 and "packages") or "package",
                       c["name"])
                rctalk.message(msg)

            if contributors > 1:
                msg = "Found a total of %d %s" % \
                      (len(packages_to_install),
                       (len(packages_to_install) != 1 and "packages")
                       or "package")
                rctalk.message(msg)

            rctalk.message("")

        else:

            for a in non_option_args:
                inform = 0
                channel = None
                package = None

                if a[0] == "!" or a[0] == "~":
                    pn = a[1:]
                    plist = rcpackageutils.find_package_on_system(server, pn)

                    if not plist:
                        rctalk.error("Unable to find package '" + pn + "'")
                        sys.exit(1)

                    for p in plist:
                        packages_to_remove.append(p)
                else:
                    plist = rcpackageutils.find_package(server,
                                                        a,
                                                        allow_unsub,
                                                        allow_system=0)

                    if not plist:
                        sys.exit(1)

                    for p in plist:
                        dups = filter(lambda x, pn=p: x["name"] == pn["name"],
                                      packages_to_install)

                        if dups and not options_dict.has_key("download-only"):
                            rctalk.error("Duplicate entry found: " +
                                         dups[0]["name"])
                            sys.exit(1)

                        packages_to_install.append(p)

        if not packages_to_install and not packages_to_remove:
            rctalk.message("--- No packages to install ---")
            sys.exit(0)

        if not options_dict.has_key("download-only"):
            install_deps, remove_deps, dep_info = \
                          resolve_dependencies(server,
                                               packages_to_install,
                                               packages_to_remove,
                                               [])
        else:
            install_deps = []
            remove_deps = []

        self.transact(server, options_dict, packages_to_install, install_deps,
                      packages_to_remove, remove_deps)
示例#4
0
    def execute(self, server, options_dict, non_option_args):
        packages_to_install = []
        packages_to_remove = []
        
        if options_dict.has_key("allow-unsubscribed"):
            allow_unsub = 1
        else:
            allow_unsub = 0

        if options_dict.has_key("entire-channel"):

            channel_list = []
            for a in non_option_args:
                matches = rcchannelutils.get_channels_by_name(server, a)
                if not rcchannelutils.validate_channel_list(a, matches):
                    sys.exit(1)
                channel_list.append(matches[0])

            contributors = 0
            for c in channel_list:
                query = [["channel", "=", c["id"]],
                         ["package-installed", "=", "false"]]
                packages = server.rcd.packsys.search(query)
                packages_to_install.extend(packages)
                if len(packages) > 0:
                    contributors = contributors + 1
                msg = "Found %d %s in channel '%s'" % \
                      (len(packages),
                       (len(packages) != 1 and "packages") or "package",
                       c["name"])
                rctalk.message(msg)

            if contributors > 1:
                msg = "Found a total of %d %s" % \
                      (len(packages_to_install),
                       (len(packages_to_install) != 1 and "packages")
                       or "package")
                rctalk.message(msg)

            rctalk.message("")

        else:
            
            for a in non_option_args:
                inform = 0
                channel = None
                package = None

                if a[0] == "!" or a[0] == "~":
                    pn = a[1:]
                    plist = rcpackageutils.find_package_on_system(server, pn)

                    if not plist:
                        rctalk.error("Unable to find package '" + pn + "'")
                        sys.exit(1)

                    for p in plist:
                        packages_to_remove.append(p)
                else:
                    plist = rcpackageutils.find_package(server, a,
                                                        allow_unsub,
                                                        allow_system=0)

                    if not plist:
                        sys.exit(1)

                    for p in plist:
                        dups = filter(lambda x, pn=p:x["name"] == pn["name"],
                                      packages_to_install)

                        if dups and not options_dict.has_key("download-only"):
                            rctalk.error("Duplicate entry found: " +
                                         dups[0]["name"])
                            sys.exit(1)

                        packages_to_install.append(p)

        if not packages_to_install and not packages_to_remove:
            rctalk.message("--- No packages to install ---")
            sys.exit(0)

        if not options_dict.has_key("download-only"):
            install_deps, remove_deps, dep_info = \
                          resolve_dependencies(server,
                                               packages_to_install,
                                               packages_to_remove,
                                               [])
        else:
            install_deps = []
            remove_deps = []

        self.transact(server, options_dict,
                      packages_to_install, install_deps,
                      packages_to_remove, remove_deps)