Exemplo n.º 1
0
                pkg = action_factory.get(
                    action_factory.CONFIG_ACTION,
                    (package_id, inst_repo.repository_id()))

                xterm_header = "equo (%s) :: %d of %d ::" % (
                    _("configure"), count, len(package_ids))
                pkg.set_xterm_header(xterm_header)

                entropy_client.output(
                    darkgreen(atom),
                    count=(count, len(package_ids)),
                    header=darkred(" ::: ") + ">>> ")

                exit_st = pkg.start()
                if exit_st not in (0, 3):
                    return 1, True

            finally:
                if pkg is not None:
                    pkg.finalize()

        return 0, True


SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloConfig,
        SoloConfig.NAME,
        _("configure installed packages"))
    )
Exemplo n.º 2
0
                darkgreen(_("Succesfully switched to branch")),
                purple(self._branch),)
            entropy_client.output(
                mytxt,
                header=red(" @@ "))
            mytxt = "%s %s" % (
                brown(" ?? "),
                darkgreen(_("Now run 'equo upgrade' to "
                            "upgrade your distribution to")),
                )
            entropy_client.output(mytxt)
            return 0

        entropy_client.set_branch(old_branch)

        mytxt = "%s: %s" % (
            darkred(_("Unable to switch to branch")),
            purple(self._branch),)
        entropy_client.output(
            mytxt, level="error",
            importance=1, header=bold(" !!! "))

        return 3

SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloHop,
        SoloHop.NAME,
        _("upgrade the System to a new branch"))
    )
Exemplo n.º 3
0
        spm_wanted_map = {}
        for pkg in self._wanted_packages:
            stripped = entropy.dep.dep_getkey(pkg)
            obj = spm_wanted_map.setdefault(stripped, set())
            obj.add(pkg)
        return spm_wanted_map

    def is_user_selected(self, pkg):
        """
        Determines whether a package is selected by user in SPM "world" file.
        """
        spm_package_key = entropy.dep.dep_getkey(pkg)
        spm_wanted_candidates = self._map.get(spm_package_key, set())

        # Avoid calling spm.match_installed_package() which can be
        # a little slow. Now the list is reduced.
        spm_wanted_matches = (self._spm_match_installed(x)
                              for x in spm_wanted_candidates if x is not None)
        return pkg in spm_wanted_matches

    def _spm_match_installed(self, pkg):
        try:
            return self._spm.match_installed_package(pkg)
        except KeyError:
            return None


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloRescue, SoloRescue.NAME,
                          _("tools to rescue the running system")))
Exemplo n.º 4
0
                    darkred(_("10 seconds")),
                    blue("..."),
                )
                entropy_client.output(mytxt, header=darkred(" @@ "))
                time.sleep(10)

            exit_st, _show_cfgupd = self._install_action(
                entropy_client,
                True,
                True,
                pretend,
                ask,
                False,
                quiet,
                False,
                False,
                False,
                False,
                False,
                False,
                False,
                1, [],
                package_matches=package_matches)

        return exit_st


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloLibtest, SoloLibtest.NAME,
                          _("look for missing libraries")))
Exemplo n.º 5
0
            time.sleep(10)

        # avoid saving deps as installed by user
        matched_for_installation = self._match_packages_for_installation(
            entropy_client, False, sorted(found_deps))
        if not matched_for_installation:
            return 1
        exit_st, _show_cfgupd = self._install_action(
            entropy_client,
            True,
            True,
            self._pretend,
            self._ask,
            False,
            self._quiet,
            False,
            False,
            False,
            False,
            False,
            False,
            False,
            1, [],
            package_matches=matched_for_installation)
        return exit_st


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloDeptest, SoloDeptest.NAME,
                          _("look for unsatisfied dependencies")))
Exemplo n.º 6
0
                    return 1, False

            removal_queue += [x for x in package_ids if x not in removal_queue]
            self._show_removal_info(entropy_client, removal_queue)

            self._prompt_final_removal(
                entropy_client, inst_repo, removal_queue)

        if pretend:
            return 0, False

        if ask:
            question = "     %s" % (
                _("Would you like to proceed ?"),)
            rc = entropy_client.ask_question(question)
            if rc == _("No"):
                return 1, False

        exit_st = self._execute_action(
            entropy_client, inst_repo, removal_queue,
            remove_config_files)
        return exit_st, True


SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloRemove,
        SoloRemove.NAME,
        _("remove packages from system"))
    )
Exemplo n.º 7
0
            epilog="http://www.sabayon.org",
            formatter_class=ColorfulFormatter)

        # filtered out in solo.main. Will never get here
        parser.add_argument("--color",
                            action="store_true",
                            default=None,
                            help=_("force colored output"))

        descriptors = SoloCommandDescriptor.obtain()
        descriptors.sort(key=lambda x: x.get_name())
        group = parser.add_argument_group("command", "available commands")
        for descriptor in descriptors:
            if descriptor.get_class().HIDDEN:
                continue
            aliases = descriptor.get_class().ALIASES
            aliases_str = ", ".join([teal(x) for x in aliases])
            if aliases_str:
                aliases_str = " [%s]" % (aliases_str, )
            name = "%s%s" % (purple(descriptor.get_name()), aliases_str)
            desc = descriptor.get_description()
            group.add_argument(name, help=darkgreen(desc), action="store_true")
        parser.print_help()
        if not self._args:
            return 1
        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloHelp, SoloHelp.NAME, _("this help")))
Exemplo n.º 8
0
        for library, elfclass, path in collectables:

            package_ids = inst_repo.isFileAvailable(path, get_id=True)

            entropy_client.output("%s [%s:%s]" % (
                darkred(path),
                purple(library),
                teal(const_convert_to_unicode(elfclass)),
            ))

            for package_id in package_ids:
                atom = inst_repo.retrieveAtom(package_id)
                if atom is None:
                    continue

                entropy_client.output("%s: %s, %s" % (
                    blue(_("but owned by")),
                    darkgreen(atom),
                    blue(_("then just unregister the library")),
                ),
                                      header=brown(" -> "),
                                      importance=0)

        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloPreservedLibs, SoloPreservedLibs.NAME,
        _("Tools to manage the preserved libraries on the system")))
Exemplo n.º 9
0
    INTRODUCTION = """\
Show Equo version.
"""
    SEE_ALSO = "equo-help(1)"

    def man(self):
        """
        Overridden from SoloCommand.
        """
        return self._man()

    def parse(self):
        """
        Parse command
        """
        return self._show_version, []

    def _show_version(self, *args):
        # do not use entropy_client here
        # it is slow and might interfere with
        # other Client inits.
        release = read_client_release()
        text = TextInterface()
        text.output(release, level="generic")
        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloVersion, SoloVersion.NAME,
                          _("show equo version")))
Exemplo n.º 10
0
            count += 1
            pkg = None

            try:
                pkg = action_factory.get(action_factory.SOURCE_ACTION,
                                         match,
                                         opts=metaopts)

                xterm_header = "equo (%s) :: %d of %d ::" % (
                    _("sources download"), count, total)
                pkg.set_xterm_header(xterm_header)

                entropy_client.output(darkgreen(atom),
                                      count=(count, total),
                                      header=darkred(" ::: ") + ">>> ")

                exit_st = pkg.start()
                if exit_st != 0:
                    return 1

            finally:
                if pkg is not None:
                    pkg.finalize()

        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloSource, SoloSource.NAME,
                          _("download packages source code")))
Exemplo n.º 11
0
        Respawn the upgrade activity if required.
        """
        # It might be an Entropy bug and Entropy was proritized in the
        # install queue, ignoring the rest of available packages.
        # So, respawning myself again using execvp() should be a much
        # better idea.
        with inst_repo.shared():
            outcome = entropy_client.calculate_updates()

        if outcome['update']:
            entropy_client.output("%s." % (purple(
                _("There are more updates to install, "
                  "reloading Entropy")), ),
                                  header=teal(" @@ "))

            # then spawn a new process
            entropy_client.shutdown()
            # hack to tell the resurrected equo to block on
            # locking acquisition
            os.environ['__EQUO_LOCKS_BLOCKING__'] = "1"
            # we will acquire them again in blocking mode, cross
            # fingers
            lock = EntropyResourcesLock(output=entropy_client)
            lock.release()
            os.execvp("equo", sys.argv)


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloUpgrade, SoloUpgrade.NAME,
                          _("upgrade the system")))
Exemplo n.º 12
0
                    entropy_client.output(purple(atom),
                                          count=(count, total),
                                          header=darkgreen(" +++ ") + ">>> ")

                    exit_st = pkg.start()
                    if exit_st != 0:
                        if ugc_thread is not None:
                            ugc_thread.join()
                        return 1, True

                finally:
                    if pkg is not None:
                        pkg.finalize()

        finally:
            if notif_acquired:
                notification_lock.release()

        if ugc_thread is not None:
            ugc_thread.join()

        entropy_client.output("%s." % (blue(_("Installation complete")), ),
                              header=darkred(" @@ "))
        return 0, True


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloInstall, SoloInstall.NAME,
                          _("install or update packages or package files")))
Exemplo n.º 13
0
            target_pkg_ids = dest_db.getPackagesToRemove(
                pkg_meta['name'], pkg_meta['category'], pkg_meta['slot'],
                pkg_meta['injected'])
            if remove_conflicts:
                for conflict in pkg_meta['conflicts']:
                    if conflict in conflict_cache:
                        continue
                    conflict_cache.add(conflict)
                    matches, rc = dest_db.atomMatch(conflict, multiMatch=True)
                    target_pkg_ids |= matches

            for target_pkg_id in target_pkg_ids:
                dest_db.removePackage(target_pkg_id)
            dest_pkg_id = dest_db.addPackage(pkg_meta, formatted_content=True)
            dest_db.commit()

        entropy_client.output("[%s] %s" % (
            teal(source),
            blue(_("done merging packages")),
        ))

        dest_db.commit()
        dest_db.close()
        # close all repos again
        entropy_client.close_repositories()
        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloRepo, SoloRepo.NAME, _("manage repositories")))
Exemplo n.º 14
0
                level="error", importance=1
            )
            return 1

        if not voted:
            entropy_client.output(
                "[%s] %s: %s" % (
                    darkred(pkgkey),
                    blue(_("UGC error")),
                    _("already voted"),
                ),
                level="error", importance=1
            )
            return 1
        else:
            entropy_client.output("[%s] %s" % (
                    purple(pkgkey),
                    blue(_("vote added, thank you!")),
                )
            )
            self._vote_get(entropy_client)

        return 0

SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloUgc,
        SoloUgc.NAME,
        _("manage User Generated Content"))
    )
Exemplo n.º 15
0
            elif action == 3:
                comeback, _continue = self._edit_file(idx, entropy_client,
                                                      root, source, dest,
                                                      paths_map, scandata)
                if _continue:
                    continue
                break

            elif action == 4:
                comeback, _continue = self._interactive_merge(
                    idx, entropy_client, root, source, dest, paths_map,
                    scandata)
                if _continue:
                    continue
                break

            elif action == 5:
                # show diff again
                diff = self._showdiff(entropy_client, dest_path, source_path)
                continue

        if comeback:
            return True
        return False


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloConf, SoloConf.NAME,
                          _("manage package file updates")))
Exemplo n.º 16
0
                                         self._get_dep_ids(inst_repo))
        not_needed = all_ids - wanted_ids

        def _sort_key(x):
            sort_index = 1 if self._sortbysize else 0
            return x[sort_index]

        not_needed_pkgs_data = sorted(
            [(inst_repo.retrieveAtom(x), inst_repo.retrieveOnDiskSize(x))
             for x in not_needed],
            key=_sort_key)

        if self._quiet:
            entropy_client.output('\n'.join(
                [x[0] for x in not_needed_pkgs_data]),
                                  level="generic")
        else:
            for atom, disk_size in not_needed_pkgs_data:
                disk_size = entropy.tools.bytes_into_human(disk_size)
                entropy_client.output("# %s%s%s %s" % (
                    blue("["),
                    brown(disk_size),
                    blue("]"),
                    darkgreen(atom),
                ))


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloUnused, SoloUnused.NAME,
                          _("show unused packages (pay attention)")))
Exemplo n.º 17
0
        return 0

    def _match(self, entropy_client, inst_repo, string):
        """
        Solo Search string command.
        """
        results = self._match_string(entropy_client, inst_repo, string)

        for pkg_id, pkg_repo in results:
            repo = entropy_client.open_repository(pkg_repo)

            print_package_info(
                pkg_id, entropy_client, repo,
                show_download_if_quiet = self._showdownload,
                show_repo_if_quiet = self._showrepo,
                show_desc_if_quiet = self._showdesc,
                show_slot_if_quiet = self._showslot,
                extended = self._verbose,
                installed_search = repo is inst_repo,
                quiet = self._quiet)

        return results


SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloMatch,
        SoloMatch.NAME,
        _("match packages in repositories"))
    )
Exemplo n.º 18
0
                matches_found,
                brown(ngettext("entry", "entries", matches_found)),
            )))
            print_table(entropy_client, toc)

        if not matches_found:
            return 1
        return 0

    def _search(self, entropy_client, inst_repo, string):
        """
        Solo Search string command.
        """
        results = self._search_string(entropy_client, inst_repo, string)

        for pkg_id, pkg_repo in results:
            repo = entropy_client.open_repository(pkg_repo)
            print_package_info(pkg_id,
                               entropy_client,
                               repo,
                               extended=self._verbose,
                               installed_search=repo is inst_repo,
                               quiet=self._quiet)

        return results


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloSearch, SoloSearch.NAME,
                          _("search packages in repositories")))
Exemplo n.º 19
0
class SoloUnmask(SoloMaskUnmask):
    """
    Main Solo Mask command.
    """

    NAME = "unmask"
    ALIASES = []

    INTRODUCTION = """\
Unmask packages so that installation and update will be allowed.
"""
    SEE_ALSO = "equo-mask(1)"

    def __init__(self, args):
        SoloMaskUnmask.__init__(self, args, SoloUnmask.NAME)


SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloMask,
        SoloMask.NAME,
        _("mask one or more packages"))
    )

SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloUnmask,
        SoloUnmask.NAME,
        _("unmask one or more packages"))
    )
Exemplo n.º 20
0
        mytxt = "[%s] [%s] %s: %s" % (
            blue(str(key)),
            brown(mydict['pubDate']),
            _("Title"),
            darkred(mydict['title']),
        )
        entropy_client.output(mytxt)

        mytxt = "%s:\n\n%s\n" % (
            darkgreen(_("Content")),
            mydict['description'],
        )
        entropy_client.output(mytxt)
        mytxt = "%s: %s" % (
            darkgreen(_("Link")),
            blue(mydict['link']),
        )
        entropy_client.output(mytxt)

        def fake_callback(s):
            return True

        input_params = [('idx', _("Press Enter to continue"), fake_callback,
                         False)]
        entropy_client.input_box('', input_params, cancel_button=True)


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloNotice, SoloNotice.NAME,
                          _("repository notice board reader")))
Exemplo n.º 21
0
            outcome += ["--verbose", "-v", "--quiet", "-q"]

        return self._bashcomp(sys.stdout, last_arg, outcome)

    @sharedlock  # clear_cache uses inst_repo
    def _clean(self, entropy_client, _inst_repo):
        """
        Solo Cache Clean command.
        """
        entropy_client.output(
            blue(_("Cleaning Entropy cache, please wait ...")),
            level = "info",
            header = brown(" @@ "),
            back = True
        )
        entropy_client.clear_cache()
        entropy_client.output(
            darkgreen(_("Entropy cache cleaned.")),
            level = "info",
            header = brown(" @@ ")
        )
        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloCache,
        SoloCache.NAME,
        _("manage Entropy Library Cache"))
    )
Exemplo n.º 22
0
    def _show_notice_board_summary(self, entropy_client, repository):
        """
        Show NoticeBoard information to user after repository update.
        """
        mytxt = "%s %s: %s" % (
            darkgreen(" @@ "),
            brown(_("Notice board")),
            bold(repository),
        )
        entropy_client.output(mytxt)

        mydict = self._check_notice_board_availability(entropy_client,
                                                       repository)
        if not mydict:
            return

        for key in sorted(mydict.keys()):
            mydata = mydict.get(key)
            mytxt = "    [%s] [%s] %s: %s" % (
                blue(str(key)),
                brown(mydata['pubDate']),
                _("Title"),
                darkred(mydata['title']),
            )
            entropy_client.output(mytxt)


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloUpdate, SoloUpdate.NAME,
                          _("update repositories")))
Exemplo n.º 23
0
        repository_path = repo_data.get('dbpath', _("Not available"))
        entropy_client.output("%s: %s" % (
            brown(_("Path")),
            darkgreen(repository_path),
        ),
                              header="    ")

        entropy_client.output("%s: %s" % (
            brown(_("Repository URL")),
            darkgreen(repo_data['plain_database']),
        ),
                              header="    ")

        if repo_data['packages']:
            entropy_client.output("%s:" % (blue(_("Package URLs")), ),
                                  header="    ")
        urlcount = 0
        for packages_url in repo_data['plain_packages']:
            urlcount += 1
            entropy_client.output("%s. %s" % (
                purple(const_convert_to_unicode(urlcount)),
                brown(packages_url),
            ),
                                  header="     ")


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloStatus, SoloStatus.NAME,
                          _("show Repositories status")))
Exemplo n.º 24
0
                return 1

            run_queue, removal_queue = self._generate_install_queue(
                entropy_client, packages, deps, False, deep, relaxed, onlydeps,
                bdeps, recursive)

        if (run_queue is None) or (removal_queue is None):
            return 1
        elif not (run_queue or removal_queue):
            entropy_client.output("%s." % (blue(_("Nothing to do")), ),
                                  level="warning",
                                  header=darkgreen(" @@ "))
            return 0

        if pretend:
            entropy_client.output("%s." % (blue(_("All done")), ))
            return 0

        down_data = {}
        exit_st = self._download_packages(entropy_client, run_queue, down_data,
                                          multifetch)

        if exit_st == 0:
            self._signal_ugc(entropy_client, down_data)
        return exit_st


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloDownload, SoloDownload.NAME,
                          _("download packages, essentially")))
Exemplo n.º 25
0
                back=True)

            file_name = os.path.basename(_file)
            package_path = os.path.join(
                savedir, file_name + ".db")
            ext_rc = entropy.tools.dump_entropy_metadata(
                _file, package_path)
            if not ext_rc:
                entropy_client.output(
                    "%s: %s" % (
                        teal(_("error during metadata extraction")),
                        purple(_file)),
                    header=darkred(" @@ "),
                    level="error", importance=1)
                return 1

            entropy_client.output(
                "%s: %s" % (
                    teal(_("metadata file generated")),
                    purple(package_path)),
                header=darkred(" @@ "))

        return 0

SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloPkg,
        SoloPkg.NAME,
        _("execute advanced tasks on packages"))
    )
Exemplo n.º 26
0
        Parse command.
        """
        parser = self._get_parser()
        try:
            nsargs = parser.parse_args(self._args)
        except IOError as err:
            sys.stderr.write("%s\n" % (err, ))
            return parser.print_help, []

        return self._call_exclusive, [self._cleanup]

    def _cleanup(self, entropy_client):
        """
        Solo Cleanup command.
        """
        dirs = [etpConst['logdir'], etpConst['entropyunpackdir']]
        for rel in etpConst['packagesrelativepaths']:
            # backward compatibility, packages are moved to packages/ dir,
            # including nonfree, restricted etc.
            dirs.append(os.path.join(etpConst['entropyworkdir'], rel))
            # new location
            dirs.append(os.path.join(etpConst['entropypackagesworkdir'], rel))
        cleanup(entropy_client, dirs)
        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(
        SoloCleanup, SoloCleanup.NAME,
        _("remove downloaded packages and clean temp. directories")))
Exemplo n.º 27
0
            pass

    @staticmethod
    def reset():
        """
        Reset Yell Status.
        """
        cacher = EntropyCacher()
        try:
            cacher.save(SoloYell._CACHE_KEY, 0)
        except IOError:
            pass

    def _show_yell(self, *args):
        yell_id = SoloYell.read()
        max_id = max(list(SoloYell._MESSAGES.keys()))
        yell_message = SoloYell._MESSAGES.get(yell_id, max_id)
        # do not use entropy_client here
        # it is slow and might interfere with
        # other Client inits.
        text = TextInterface()
        text.output(yell_message, importance=1, level="warning")
        new_yell_id = yell_id + 1
        if new_yell_id <= max_id:
            SoloYell.write(new_yell_id)
        return 1


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloYell, SoloYell.NAME, _("yell at user")))
Exemplo n.º 28
0
        for package in packages:
            if package not in package_ids:
                # Package was not found.
                continue

            for pkg_id in package_ids[package]:

                pkg_atom = inst_repo.retrieveAtom(pkg_id)
                current_source = inst_repo.getInstalledPackageSource(pkg_id)
                current_source_txt = reverse_install_sources.get(
                    current_source, other_source)

                if current_source == source:
                    txt = "%s: %s" % (brown(pkg_atom), _("no change"))
                    entropy_client.output(txt, header=blue(" @@ "))
                else:
                    txt = "%s: %s => %s" % (brown(pkg_atom),
                                            current_source_txt, source_txt)
                    entropy_client.output(txt, header=red(" !! "))

                    if not pretend:
                        inst_repo.setInstalledPackageSource(pkg_id, source)

        return 0


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloMark, SoloMark.NAME,
                          _("set properties on installed packages")))
Exemplo n.º 29
0
    ALLOW_UNPRIVILEGED = True
    HIDDEN = True

    INTRODUCTION = """\
Bow to the Highness.
"""
    SEE_ALSO = ""

    def _get_message(self):
        """
        Reimplemented from SoloFunny.
        """
        t = """
 _________________________
< Hail to the king, baby! >
 -------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\\
                ||----w |
                ||     ||
"""
        return t


SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloMoo, SoloMoo.NAME, _("moo at user")))

SoloCommandDescriptor.register(
    SoloCommandDescriptor(SoloLxnay, SoloLxnay.NAME, _("bow to lxnay")))