Пример #1
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("provides"):
                continue

            rctalk.message("--- %s %s ---" %
                           (pkg["name"], rcformat.evr_to_str(pkg)))

            for dep in dep_info["provides"]:
                rctalk.message(rcformat.dep_to_str(dep))

            rctalk.message("")
Пример #2
0
    def execute(self, server, options_dict, non_option_args):
        if len(non_option_args) != 1:
            self.usage()
            sys.exit(1)

        plist = rcpackageutils.find_package(server, non_option_args[0], 1)

        if not plist:
            rctalk.message("--- No package found ---")
            sys.exit(1)

        pkg = None
        for p in plist:
            if p["installed"] or p.get("package_filename", None):
                pkg = p
                break

        if not pkg:
            rctalk.message("--- File information not available ---")
            sys.exit(1)

        try:
            file_list = server.rcd.packsys.file_list(pkg)
        except ximian_xmlrpclib.Fault, f:
            if f.faultCode == rcfault.undefined_method:
                rctalk.error("File list is not supported by this daemon")
                sys.exit(1)
            else:
                raise
Пример #3
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("provides"):
                continue

            rctalk.message("--- %s %s ---" %
                           (pkg["name"], rcformat.evr_to_str(pkg)))

            for dep in dep_info["provides"]:
                rctalk.message(rcformat.dep_to_str(dep))

            rctalk.message("")
Пример #4
0
    def execute(self, server, options_dict, non_option_args):
        if len(non_option_args) != 1:
            self.usage()
            sys.exit(1)

        plist = rcpackageutils.find_package(server, non_option_args[0], 1)

        if not plist:
            rctalk.message("--- No package found ---")
            sys.exit(1)

        pkg = None
        for p in plist:
            if p["installed"] or p.get("package_filename", None):
                pkg = p
                break

        if not pkg:
            rctalk.message("--- File information not available ---")
            sys.exit(1)

        try:
            file_list = server.rcd.packsys.file_list(pkg)
        except ximian_xmlrpclib.Fault, f:
            if f.faultCode == rcfault.undefined_method:
                rctalk.error("File list is not supported by this daemon")
                sys.exit(1)
            else:
                raise
Пример #5
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)
Пример #6
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        no_abbrev = options_dict.has_key("no-abbrev")

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("children"):
                continue

            table = []

            row_spec = ["name", "channel"]
            row_headers = ["Provided By", "Channel"]
            pad = []

            if options_dict.has_key("show-versions"):
                row_spec.insert(1, "version")
                row_headers.insert(1, "Version")
                pad = pad + [""]

            if options_dict.has_key("all-providers"):
                row_spec.insert(2, "installed")
                row_headers.insert(2, "S")
                pad = pad + [""]

            for dep in dep_info["children"]:
                providers = map(lambda x:x[0], server.rcd.packsys.what_provides(dep))
                prov_dict = {}

                name = rcformat.dep_to_str(dep)
                status = "*"
                for prov in providers:
                    if prov["installed"]:
                        status = ""

                if status == "" \
                       and not options_dict.has_key("all-providers"):
                    providers = filter(lambda x:x["installed"], providers)


                count = 0
                for prov in providers:
                    row = rcformat.package_to_row(server, prov, no_abbrev, row_spec)
                    key = string.join(row)
                    if not prov_dict.has_key(key):
                        table.append([status, name] + row)
                        prov_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["*", name, "(none)", "(none)"] + pad)
                elif count > 1 and not rctalk.be_terse:
                    table.append(["", "", "", ""] + pad)

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No Children ---")
            else:
                rcformat.tabular(["!", "Requirement"] + row_headers, table)

            if len(plist) > 1:
                rctalk.message("")
Пример #7
0
    def execute(self, server, options_dict, non_option_args):

        if not non_option_args:
            self.usage()
            sys.exit(1)

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

        plist = []

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

            plist = plist + rcpackageutils.find_package(server, a, allow_unsub)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for p in plist:
            pinfo = server.rcd.packsys.package_info(p)

            rctalk.message("")
            rctalk.message("Name: " + p["name"])
            rctalk.message("Version: " + p["version"])
            rctalk.message("Release: " + p["release"])
            if p["installed"]:
                rctalk.message("Installed: Yes")
                update = rcpackageutils.find_latest_package(server, a, allow_unsub, 1)
                if not len(update):
                    rctalk.message("Status: up-to-date")
                else:
                    rctalk.message("Status: update available (%s)" % update[0]["version"])
            else:
                rctalk.message("Installed: No")
            if pinfo.get("file_size", 0):
                rctalk.message("Package size: " + str(pinfo["file_size"]))
            if pinfo.get("installed_size", 0):
                rctalk.message("Installed size: " + str(pinfo["installed_size"]))
            rctalk.message("Summary: " + pinfo["summary"])
            rctalk.message("Description: ")
            rctalk.message(pinfo["description"])

            log_entries = server.rcd.log.query_log([["name", "=", p["name"]]])
            if log_entries:

                # Reverse chronological order
                log_entries.sort(lambda x,y:cmp(y["timestamp"], x["timestamp"]))

                act_len_list = map(lambda x:len(x["action"]), log_entries)
                if len(act_len_list) > 1:
                    act_len = apply(max, act_len_list)
                else:
                    act_len = act_len_list[0]
                
                rctalk.message("\nHistory:")
                                
                for item in log_entries:

                    init_str = ""
                    fin_str = ""

                    if item.has_key("pkg_initial"):
                        init_str = rcformat.evr_to_abbrev_str(item["pkg_initial"])
                    if item.has_key("pkg_final"):
                        fin_str = rcformat.evr_to_abbrev_str(item["pkg_final"])

                    if init_str and fin_str:
                        pkg_str = init_str + " => " + fin_str
                    elif init_str:
                        pkg_str = init_str
                    elif fin_str:
                        pkg_str = fin_str

                    time_str = time.strftime("%Y-%m-%d %H:%M,",
                                             time.localtime(item["timestamp"]))

                    action_str = string.ljust(item["action"] + ",", act_len+1)

                    if pkg_str:
                        rctalk.message(time_str + " " + action_str + " " + pkg_str)
Пример #8
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("obsoletes"):
                continue

            table = []

            for dep in dep_info["obsoletes"]:
                provided_by = map(lambda x:x[0], server.rcd.packsys.what_provides(dep))
                ob_dict = {}

                name = rcformat.dep_to_str(dep)
                status = ""
                for provider in provided_by:
                    if provider["installed"]:
                        status = "*"

                count = 0
                for provider in provided_by:
                    # skip self-obsoletes
                    if evr_eq(provider, pkg):
                        continue

                    if provider["installed"]:
                        status = "*"
                    else:
                        status = ""
                    
                    row = rcformat.package_to_row(server, provider, 0, ["name", "installed", "channel"])
                    key = string.join(row)
                    if not ob_dict.has_key(key):
                        table.append([status, name] + row)
                        ob_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["", name, "", "", ""])
                elif count > 1:
                    table.append(["", "", "", "", ""])

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No obsoletes ---")
            else:
                rcformat.tabular(["!", "Obsoletes", "Provided by", "S", "Channel"], table)

            if len(plist) > 1:
                rctalk.message("")
Пример #9
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)
Пример #10
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        no_abbrev = options_dict.has_key("no-abbrev")

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("children"):
                continue

            table = []

            row_spec = ["name", "channel"]
            row_headers = ["Provided By", "Channel"]
            pad = []

            if options_dict.has_key("show-versions"):
                row_spec.insert(1, "version")
                row_headers.insert(1, "Version")
                pad = pad + [""]

            if options_dict.has_key("all-providers"):
                row_spec.insert(2, "installed")
                row_headers.insert(2, "S")
                pad = pad + [""]

            for dep in dep_info["children"]:
                providers = map(lambda x: x[0],
                                server.rcd.packsys.what_provides(dep))
                prov_dict = {}

                name = rcformat.dep_to_str(dep)
                status = "*"
                for prov in providers:
                    if prov["installed"]:
                        status = ""

                if status == "" \
                       and not options_dict.has_key("all-providers"):
                    providers = filter(lambda x: x["installed"], providers)

                count = 0
                for prov in providers:
                    row = rcformat.package_to_row(server, prov, no_abbrev,
                                                  row_spec)
                    key = string.join(row)
                    if not prov_dict.has_key(key):
                        table.append([status, name] + row)
                        prov_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["*", name, "(none)", "(none)"] + pad)
                elif count > 1 and not rctalk.be_terse:
                    table.append(["", "", "", ""] + pad)

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No Children ---")
            else:
                rcformat.tabular(["!", "Requirement"] + row_headers, table)

            if len(plist) > 1:
                rctalk.message("")
Пример #11
0
    def execute(self, server, options_dict, non_option_args):

        if not non_option_args:
            self.usage()
            sys.exit(1)

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

        plist = []

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

            plist = plist + rcpackageutils.find_package(server, a, allow_unsub)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for p in plist:
            pinfo = server.rcd.packsys.package_info(p)

            rctalk.message("")
            rctalk.message("Name: " + p["name"])
            rctalk.message("Version: " + p["version"])
            rctalk.message("Release: " + p["release"])
            if p["installed"]:
                rctalk.message("Installed: Yes")
                update = rcpackageutils.find_latest_package(
                    server, a, allow_unsub, 1)
                if not len(update):
                    rctalk.message("Status: up-to-date")
                else:
                    rctalk.message("Status: update available (%s)" %
                                   update[0]["version"])
            else:
                rctalk.message("Installed: No")
            if pinfo.get("file_size", 0):
                rctalk.message("Package size: " + str(pinfo["file_size"]))
            if pinfo.get("installed_size", 0):
                rctalk.message("Installed size: " +
                               str(pinfo["installed_size"]))
            rctalk.message("Summary: " + pinfo["summary"])
            rctalk.message("Description: ")
            rctalk.message(pinfo["description"])

            log_entries = server.rcd.log.query_log([["name", "=", p["name"]]])
            if log_entries:

                # Reverse chronological order
                log_entries.sort(
                    lambda x, y: cmp(y["timestamp"], x["timestamp"]))

                act_len_list = map(lambda x: len(x["action"]), log_entries)
                if len(act_len_list) > 1:
                    act_len = apply(max, act_len_list)
                else:
                    act_len = act_len_list[0]

                rctalk.message("\nHistory:")

                for item in log_entries:

                    init_str = ""
                    fin_str = ""

                    if item.has_key("pkg_initial"):
                        init_str = rcformat.evr_to_abbrev_str(
                            item["pkg_initial"])
                    if item.has_key("pkg_final"):
                        fin_str = rcformat.evr_to_abbrev_str(item["pkg_final"])

                    if init_str and fin_str:
                        pkg_str = init_str + " => " + fin_str
                    elif init_str:
                        pkg_str = init_str
                    elif fin_str:
                        pkg_str = fin_str

                    time_str = time.strftime("%Y-%m-%d %H:%M,",
                                             time.localtime(item["timestamp"]))

                    action_str = string.ljust(item["action"] + ",",
                                              act_len + 1)

                    if pkg_str:
                        rctalk.message(time_str + " " + action_str + " " +
                                       pkg_str)
Пример #12
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("obsoletes"):
                continue

            table = []

            for dep in dep_info["obsoletes"]:
                provided_by = map(lambda x: x[0],
                                  server.rcd.packsys.what_provides(dep))
                ob_dict = {}

                name = rcformat.dep_to_str(dep)
                status = ""
                for provider in provided_by:
                    if provider["installed"]:
                        status = "*"

                count = 0
                for provider in provided_by:
                    # skip self-obsoletes
                    if evr_eq(provider, pkg):
                        continue

                    if provider["installed"]:
                        status = "*"
                    else:
                        status = ""

                    row = rcformat.package_to_row(
                        server, provider, 0, ["name", "installed", "channel"])
                    key = string.join(row)
                    if not ob_dict.has_key(key):
                        table.append([status, name] + row)
                        ob_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["", name, "", "", ""])
                elif count > 1:
                    table.append(["", "", "", "", ""])

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No obsoletes ---")
            else:
                rcformat.tabular(
                    ["!", "Obsoletes", "Provided by", "S", "Channel"], table)

            if len(plist) > 1:
                rctalk.message("")