Exemple #1
0
                level="warning")
            entropy_server.output(
                purple(_("Users with older repositories will have to update")),
                importance=1,
                level="warning")
            entropy_server.output("", level="warning")

        repository_id = entropy_server.repository()
        entropy_server.Mirrors.tidy_mirrors(
            repository_id, ask = self._ask,
            pretend = self._pretend, expiration_days = self._days)
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitCleanup,
        EitCleanup.NAME,
        _('clean expired packages from a repository'))
    )

class EitVacuum(EitCleanup):
    """
    Main Eit vacuum command (kept for backward compat).
    """

    NAME = "vacuum"
    ALIASES = []

    def __init__(self, args):
        EitCleanup.__init__(self, args)
        # default is 0 here
        self._days = 0
Exemple #2
0
                darkred(mydata['title']),
            )
            entropy_server.output(mytxt)

        entropy_server.output("")
        mytxt = "[%s] %s" % (
            blue("-1"),
            darkred(_("Exit/Commit")),
        )
        entropy_server.output(mytxt)

        def fake_callback(s):
            return s

        input_params = [('id', blue(_('Choose one by typing its identifier')),
                         fake_callback, False)]
        data = entropy_server.input_box(title,
                                        input_params,
                                        cancel_button=True)
        if not isinstance(data, dict):
            return -1
        try:
            return int(data['id'])
        except ValueError:
            return -2


EitCommandDescriptor.register(
    EitCommandDescriptor(EitNotice, EitNotice.NAME,
                         _('manage repository notice-board')))
Exemple #3
0
                                   "and slot updates"),
                            default=self._conservative)
        parser.add_argument("--to",
                            metavar="<repository>",
                            help=_("add to given repository"),
                            default=None)
        parser.add_argument("--quick",
                            action="store_true",
                            default=not self._ask,
                            help=_("no stupid questions"))
        return parser

    def parse(self):
        """ Overridden from EitCommit """
        parser = self._get_parser()
        try:
            nsargs = parser.parse_args(self._args)
        except IOError as err:
            return parser.print_help, []

        # setup atoms variable before spawning commit
        self._ask = not nsargs.quick
        self._entropy_class()._inhibit_treeupdates = nsargs.conservative
        self._packages = nsargs.packages[:]
        return self._call_exclusive, [self._commit, nsargs.to]


EitCommandDescriptor.register(
    EitCommandDescriptor(EitAdd, EitAdd.NAME,
                         _('commit to repository the provided packages')))
Exemple #4
0
        """
        exit_st = 0
        for package in self._packages:
            pkg_id, pkg_repo = entropy_server.atom_match(package)
            if pkg_id == -1:
                exit_st = 1
                if not self._quiet:
                    entropy_server.output(
                        "%s: %s" % (purple(_("Not matched")), teal(package)), level="warning", importance=1
                    )
                continue

            entropy_repository = entropy_server.open_repository(pkg_repo)
            files = entropy_repository.retrieveContent(pkg_id, order_by="file")
            atom = entropy_repository.retrieveAtom(pkg_id)
            if self._quiet:
                for path in files:
                    entropy_server.output(path, level="generic")
            else:
                for path in files:
                    entropy_server.output(path)
                entropy_server.output(
                    "[%s] %s: %s %s"
                    % (purple(pkg_repo), darkgreen(atom), bold(str(len(files))), teal(_("files found")))
                )

        return exit_st


EitCommandDescriptor.register(EitCommandDescriptor(EitFiles, EitFiles.NAME, _("show files owned by packages")))
Exemple #5
0
        switched, already_switched, ignored, \
            not_found, no_checksum = status
        if not_found or no_checksum:
            return 1
        return 0

    def _status(self, entropy_server):
        """
        Show branch information (list of branches, current branch)
        """
        repository_id = entropy_server.repository()
        branch_dir = entropy_server._get_local_repository_dir(repository_id,
                                                              branch="")
        branches = []
        if os.path.isdir(branch_dir):
            branches += [x for x in os.listdir(branch_dir) if \
                os.path.isdir(os.path.join(branch_dir, x))]
        current_branch = self._settings()['repositories']['branch']
        branches.sort()
        for branch in branches:
            cur_txt = ""
            if branch == current_branch:
                cur_txt = purple("*") + " "
            entropy_server.output("%s%s" % (cur_txt, branch))
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitBranch, EitBranch.NAME,
                         _('manage repository branches')))
Exemple #6
0
            branchinfo = ""
            sizeinfo = ""
            if self._verbose:
                branch = entropy_repository.retrieveBranch(pkg_id)
                branchinfo = darkgreen("[")+teal(branch)+darkgreen("]")
                mysize = entropy_repository.retrieveOnDiskSize(pkg_id)
                mysize = entropy.tools.bytes_into_human(mysize)
                sizeinfo = brown("[")+purple(mysize)+brown("]")

            if not self._quiet:
                entropy_server.output(
                    "%s %s %s" % (
                        atom, sizeinfo, branchinfo),
                    header="")
            else:
                entropy_server.output(atom, level="generic")

        if not pkg_ids and not self._quiet:
            entropy_server.output(
                darkgreen(_("No packages")),
                header=brown(" @@ "))


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitList,
        EitList.NAME,
        _("show repository content (packages)"))
    )
Exemple #7
0
            while True:
                try:
                    w_repo.removeDependencies(package_id)
                    w_repo.insertDependencies(package_id, orig_deps)
                    w_repo.removeConflicts(package_id)
                    w_repo.insertConflicts(package_id, orig_conflicts)
                    w_repo.commit()
                except (
                        KeyboardInterrupt,
                        SystemExit,
                ):
                    continue
                break

            # now bump, this makes EAPI=3 differential db sync happy
            old_pkg_data = w_repo.getPackageData(package_id)
            w_repo.handlePackage(old_pkg_data)

            entropy_server.output(
                "%s: %s" % (blue(atom),
                            darkgreen(_("dependencies updated successfully"))),
                header=brown(" @@ "))

        entropy_server.commit_repositories()
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitDeps, EitDeps.NAME,
                         _('edit dependencies for packages in repository')))
Exemple #8
0
            entropy_server.Mirrors.lock_mirrors(
                repository_id,
                False,
                unlock_locally=(self._as_repository_id is None))

        if sts != 0:
            entropy_server.output(red(_("Aborting !")),
                                  importance=1,
                                  level="error",
                                  header=darkred(" !!! "))
            return sts

        if self._ask:
            q_rc = entropy_server.ask_question(
                _("Should I cleanup old packages on mirrors ?"))
            if q_rc == _("No"):
                return 0
            # fall through

        done = entropy_server.Mirrors.tidy_mirrors(repository_id,
                                                   ask=self._ask,
                                                   pretend=self._pretend)
        if not done:
            return 1
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitPush, EitPush.NAME,
                         _('push repository packages and metadata')))
Exemple #9
0
            repo = entropy_server.open_repository(repository_id)
            key_sorter = lambda x: repo.retrieveAtom(x)
            for desc in self._nsargs.descriptions:
                pkg_ids = repo.searchDescription(desc, just_id = True)
                for pkg_id in sorted(pkg_ids, key = key_sorter):
                    if self._quiet:
                        entropy_server.output(
                            repo.retrieveAtom(pkg_id), level="generic")
                    else:
                        print_package_info(pkg_id, entropy_server, repo,
                                     extended = self._verbose,
                                     strict_output = False,
                                     quiet = False)

                if not self._quiet:
                    entropy_server.output(
                        "[%s] %s %s" % (
                            darkgreen(desc),
                            bold(str(len(pkg_ids))),
                            teal(_("packages found"))))

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitQuery,
        EitQuery.NAME,
        _('miscellaneous package metadata queries'))
    )
Exemple #10
0
            entropy_server.output(purple(_("Considering all the packages")),
                                  importance=1,
                                  level="warning")
            repo = entropy_server.open_repository(self._source)
            package_ids = repo.listAllPackageIds()

        if not package_ids:
            return 1

        rc = False
        if self._copy:
            rc = entropy_server.copy_packages(package_ids,
                                              self._source,
                                              self._dest,
                                              pull_dependencies=self._deps,
                                              ask=self._ask)
        else:
            rc = entropy_server.move_packages(package_ids,
                                              self._source,
                                              self._dest,
                                              pull_dependencies=self._deps,
                                              ask=self._ask)
        if rc:
            return 0
        return 1


EitCommandDescriptor.register(
    EitCommandDescriptor(EitCp, EitCp.NAME,
                         _('copy packages from a repository to another')))
Exemple #11
0
        """
        Overridden from EitCommand.
        """
        return self._man()

    def parse(self):
        """ Overridden from EitInit """
        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, []

        self._ask = not nsargs.quick
        return self._call_exclusive, [self._init, nsargs.repo[0]]

    def _init(self, entropy_server):
        rc = entropy_server.initialize_repository(entropy_server.repository(), ask=self._ask)
        if rc == 0:
            entropy_server.output(
                teal(_("Entropy repository has been initialized")), header=darkgreen(" * "), importance=1
            )
            return 0
        return 1


EitCommandDescriptor.register(
    EitCommandDescriptor(EitInit, EitInit.NAME, _("initialize repository (erasing all its content)"))
)
Exemple #12
0
        return self._call_shared, [self._match, None]

    def _match(self, entropy_server):
        """
        Actual Eit match code.
        """
        count = 0
        for package in self._packages:
            pkg_id, pkg_repo = entropy_server.atom_match(package)
            if pkg_id == -1:
                continue

            count += 1
            print_package_info(pkg_id,
                               entropy_server,
                               entropy_server.open_repository(pkg_repo),
                               installed_search=True,
                               extended=True,
                               quiet=self._quiet)

        if not count and not self._quiet:
            entropy_server.output(purple(_("Nothing found")),
                                  importance=1,
                                  level="warning")
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitMatch, EitMatch.NAME,
                         _('match packages in repositories')))
Exemple #13
0
        outcome = sorted(filter(_startswith, outcome))
        sys.stdout.write(" ".join(outcome) + "\n")
        sys.stdout.flush()

    def _show_help(self, *args):
        parser = argparse.ArgumentParser(
            description=_("Entropy Infrastructure Toolkit"),
            epilog="http://www.sabayon.org",
            formatter_class=ColorfulFormatter)

        descriptors = EitCommandDescriptor.obtain()
        descriptors.sort(key=lambda x: x.get_name())
        group = parser.add_argument_group("command", "available commands")
        for descriptor in descriptors:
            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


EitCommandDescriptor.register(
    EitCommandDescriptor(EitHelp, EitHelp.NAME, _("this help")))
Exemple #14
0
            prog="%s %s" % (sys.argv[0], EitRepack.NAME))

        parser.add_argument("packages",
                            nargs='+',
                            metavar="<package>",
                            help=_("package names"))
        parser.add_argument("--in",
                            metavar="<repository>",
                            help=_("repack to given repository"),
                            default=None,
                            dest="into")
        return parser

    def parse(self):
        """ Overridden from EitCommit """
        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, []

        # setup atoms variable before spawning commit
        self._repackage = nsargs.packages[:]
        return self._call_exclusive, [self._commit, nsargs.into]


EitCommandDescriptor.register(
    EitCommandDescriptor(EitRepack, EitRepack.NAME,
                         _('rebuild packages in repository')))
Exemple #15
0
        """
        Overridden from EitCommand.
        """
        return self._man()

    def parse(self):
        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, []

        self._source = nsargs.source
        self._dest = nsargs.dest
        self._deps = nsargs.deps
        self._ask = not nsargs.quick
        self._packages += nsargs.packages
        self._copy = False
        self._entropy_class()._inhibit_treeupdates = nsargs.conservative

        return self._call_exclusive, [self._move_copy, self._source]


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitMv,
        EitMv.NAME,
        _('move packages from a repository to another'))
    )
Exemple #16
0
            pkg_id, pkg_repo = entropy_server.atom_match(package)
            if pkg_id == -1:
                exit_st = 1
                if not self._quiet:
                    entropy_server.output(
                        "%s: %s" % (purple(_("Not matched")), teal(package)),
                        level="warning",
                        importance=1)
                continue

            entropy_repository = entropy_server.open_repository(pkg_repo)
            files = entropy_repository.retrieveContent(pkg_id, order_by="file")
            atom = entropy_repository.retrieveAtom(pkg_id)
            if self._quiet:
                for path in files:
                    entropy_server.output(path, level="generic")
            else:
                for path in files:
                    entropy_server.output(path)
                entropy_server.output(
                    "[%s] %s: %s %s" %
                    (purple(pkg_repo), darkgreen(atom), bold(str(
                        len(files))), teal(_("files found"))))

        return exit_st


EitCommandDescriptor.register(
    EitCommandDescriptor(EitFiles, EitFiles.NAME,
                         _('show files owned by packages')))
Exemple #17
0
    def _show_help(self, *args):
        parser = argparse.ArgumentParser(
            description=_("Entropy Infrastructure Toolkit"),
            epilog="http://www.sabayon.org",
            formatter_class=ColorfulFormatter)

        descriptors = EitCommandDescriptor.obtain()
        descriptors.sort(key = lambda x: x.get_name())
        group = parser.add_argument_group("command", "available commands")
        for descriptor in descriptors:
            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

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitHelp,
        EitHelp.NAME,
        _("this help"))
    )
Exemple #18
0
                        purple(repository_id),
                        blue(_("repository not available")),),
                    level="warning", importance=1)
                exit_st = 1
                continue

            parser = RepositoryConfigParser()
            removed = parser.remove(repository_id)
            if not removed:
                exit_st = 1
                entropy_server.output(
                    "[%s] %s" % (
                        purple(repository_id),
                        blue(_("cannot remove repository")),),
                    level="warning", importance=1)
            else:
                entropy_server.output(
                    "[%s] %s" % (
                        purple(repository_id),
                        blue(_("repository removed succesfully")),))

        return exit_st


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitRepo,
        EitRepo.NAME,
        _("manage repositories"))
    )
Exemple #19
0
        """
        Overridden from EitCommand.
        """
        return self._man()

    def parse(self):
        """ Overridden from EitCommit """
        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, []

        self._ask = not nsargs.quick
        self._merge_branch = nsargs.branch
        return self._call_exclusive, [self._branch, nsargs.into]

    def _branch(self, entropy_server):
        """
        Eit branch code.
        """
        return entropy_server.flushback_packages(entropy_server.repository(),
                                                 [self._merge_branch],
                                                 ask=self._ask)


EitCommandDescriptor.register(
    EitCommandDescriptor(EitMerge, EitMerge.NAME,
                         _('merge packages on other branches into current')))
Exemple #20
0
            # save new dependencies
            while True:
                try:
                    w_repo.removeDependencies(package_id)
                    w_repo.insertDependencies(package_id, orig_deps)
                    w_repo.commit()
                except (KeyboardInterrupt, SystemExit,):
                    continue
                break

            # now bump, this makes EAPI=3 differential db sync happy
            old_pkg_data = w_repo.getPackageData(package_id)
            w_repo.handlePackage(old_pkg_data)

            entropy_server.output(
                "%s: %s" % (
                    blue(atom),
                    darkgreen(_("dependencies updated successfully"))),
                header=brown(" @@ "))

        entropy_server.commit_repositories()
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitDeps,
        EitDeps.NAME,
        _('edit dependencies for packages in repository'))
    )
Exemple #21
0
    def parse(self):
        """ Overridden from EitCommand """
        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, []

        self._sync = nsargs.sync
        return self._call_exclusive, [self._bump, nsargs.repo]

    def _bump(self, entropy_server):
        """
        Actual Entropy Repository bump function
        """
        entropy_server.output(darkgreen(" * ")+blue("%s..." % (
                    _("Bumping repository"),) ))
        entropy_server._bump_database(entropy_server.repository())
        if self._sync:
            errors = entropy_server.Mirrors.sync_repository(
                entropy_server.repository())
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitBump,
        EitBump.NAME,
        _('bump repository revision, force push'))
    )
Exemple #22
0
                result = results[result]

                for pkg_id in sorted(result, key = key_sorter):
                    if self._quiet:
                        entropy_server.output(
                            repo.retrieveAtom(pkg_id),
                            level="generic")
                    else:
                        print_package_info(pkg_id, entropy_server,
                                     repo, installed_search = True,
                                     extended = self._verbose,
                                     quiet = self._quiet)

                if not self._quiet:
                    entropy_server.output(
                        "[%s] %s: %s %s" % (
                            purple(repository_id),
                            darkgreen(xfile),
                            bold(str(len(result))),
                            teal(_("packages found"))))

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitOwn,
        EitOwn.NAME,
        _('search packages owning paths'))
    )
Exemple #23
0
            repository_id = entropy_server.repository()
        if repository_id not in entropy_server.repositories():
            entropy_server.output(
                "%s: %s" % (
                    purple(_("Invalid repository")),
                    teal(repository_id)),
                importance=1, level="error")
            return 1

        fine, failed, dl_fine, dl_err = \
            entropy_server._verify_local_packages(
                repository_id, [], ask = not self._nsargs.quick)
        if failed:
            return 1
        return 0

    def _rem_pkgtest(self, entropy_server):
        repository_id = self._nsargs.repo
        if repository_id is None:
            repository_id = entropy_server.repository()
        entropy_server._verify_remote_packages(repository_id, [],
            ask = self._ask)
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitTest,
        EitTest.NAME,
        _('run QA tests'))
    )
Exemple #24
0
        sts = self.__sync_repo(entropy_server, repository_id)
        if sts == 0:
            # do not touch locking
            entropy_server.Mirrors.lock_mirrors(repository_id, False,
                unlock_locally = (self._as_repository_id is None))

        if sts != 0:
            entropy_server.output(red(_("Aborting !")),
                importance=1, level="error", header=darkred(" !!! "))
            return sts

        if self._ask:
            q_rc = entropy_server.ask_question(
                _("Should I cleanup old packages on mirrors ?"))
            if q_rc == _("No"):
                return 0
            # fall through

        done = entropy_server.Mirrors.tidy_mirrors(
            repository_id, ask = self._ask, pretend = self._pretend)
        if not done:
            return 1
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitPush,
        EitPush.NAME,
        _('push repository packages and metadata'))
    )
Exemple #25
0
            for result in results:

                # print info
                xfile = result
                result = results[result]

                for pkg_id in sorted(result, key=key_sorter):
                    if self._quiet:
                        entropy_server.output(repo.retrieveAtom(pkg_id),
                                              level="generic")
                    else:
                        print_package_info(pkg_id,
                                           entropy_server,
                                           repo,
                                           installed_search=True,
                                           extended=self._verbose,
                                           quiet=self._quiet)

                if not self._quiet:
                    entropy_server.output(
                        "[%s] %s: %s %s" %
                        (purple(repository_id), darkgreen(xfile),
                         bold(str(len(result))), teal(_("packages found"))))

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitOwn, EitOwn.NAME,
                         _('search packages owning paths')))
Exemple #26
0
                    level="error")
                return 1

        if not etp_pkg_files:
            entropy_server.output(teal(_("no valid package paths")),
                                  importance=1,
                                  level="error")
            return 1

        # in this case, no split package files are provided
        repository_id = entropy_server.repository()
        etp_pkg_files = [(
            [x],
            True,
        ) for x in etp_pkg_files]
        package_ids = entropy_server.add_packages_to_repository(
            repository_id, etp_pkg_files)
        if package_ids:
            # checking dependencies and print issues
            entropy_server.extended_dependencies_test([repository_id])

        entropy_server.commit_repositories()
        if package_ids:
            return 0
        return 1


EitCommandDescriptor.register(
    EitCommandDescriptor(EitInject, EitInject.NAME,
                         _('inject package files into repository')))
Exemple #27
0
        """
        return self._man()

    def parse(self):
        """ Overridden from EitCommand """
        parser = self._get_parser()
        try:
            nsargs = parser.parse_args(self._args)
        except IOError as err:
            return parser.print_help, []

        return self._call_exclusive, [self._checkout, nsargs.repo]

    def _checkout(self, entropy_server):
        """
        Actual Entropy Repository checkout function
        """
        repository_id = entropy_server.repository()
        entropy_server.switch_default_repository(repository_id,
            save = True)
        # show interface info
        entropy_server._show_interface_status()
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitCheckout,
        EitCheckout.NAME,
        _('switch from a repository to another'))
    )
Exemple #28
0
        """
        return self._man()

    def parse(self):
        """ Overridden from EitInit """
        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, []

        self._ask = not nsargs.quick
        return self._call_exclusive, [self._init, nsargs.repo[0]]

    def _init(self, entropy_server):
        rc = entropy_server.initialize_repository(entropy_server.repository(),
                                                  ask=self._ask)
        if rc == 0:
            entropy_server.output(teal(
                _("Entropy repository has been initialized")),
                                  header=darkgreen(" * "),
                                  importance=1)
            return 0
        return 1


EitCommandDescriptor.register(
    EitCommandDescriptor(EitInit, EitInit.NAME,
                         _('initialize repository (erasing all its content)')))
Exemple #29
0
            entropy_server.output(mytxt)

        entropy_server.output("")
        mytxt = "[%s] %s" % (
            blue("-1"),
            darkred(_("Exit/Commit")),
        )
        entropy_server.output(mytxt)

        def fake_callback(s):
            return s
        input_params = [
            ('id', blue(_('Choose one by typing its identifier')),
            fake_callback, False)]
        data = entropy_server.input_box(title, input_params,
            cancel_button = True)
        if not isinstance(data, dict):
            return -1
        try:
            return int(data['id'])
        except ValueError:
            return -2


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitNotice,
        EitNotice.NAME,
        _('manage repository notice-board'))
    )
Exemple #30
0
            default_str = ""
            if repository_id == default_repo:
                default_str = " (%s)" % (purple("*"), )
            meta = entropy_server.repository_metadata(repository_id)
            description = meta['description']
            repo_mirrors = meta['repo_mirrors']
            pkg_mirrors = meta['pkg_mirrors']

            entropy_server.output("%s [%s]%s" % (
                teal(repository_id),
                darkgreen(description),
                default_str,
            ))
            for repo_mirror in repo_mirrors:
                entropy_server.output("  %s: %s" % (
                    blue(_("repository")),
                    brown(repo_mirror),
                ))
            for pkg_mirror in pkg_mirrors:
                entropy_server.output("  %s: %s" % (
                    blue(_("packages")),
                    brown(pkg_mirror),
                ))

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitRemote, EitRemote.NAME, _('manage repositories')))
Exemple #31
0
        repositories = entropy_server.repositories()
        if self._repository_id not in repositories:
            entropy_server.output(
                "%s: %s" % (_("Invalid Repository"), self._repository_id),
                level="error",
                importance=1)
            return 1

        done = entropy_server.Mirrors.lock_mirrors_for_download(
            self._repository_id, self._action_lock, quiet=self._quiet)
        if not done:
            return 1
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitLock, EitLock.NAME, _('lock repository')))


class EitUnlock(EitLock):
    """
    Main Eit unlock command.
    """

    NAME = "unlock"
    ALIASES = []
    ALLOW_UNPRIVILEGED = True

    def __init__(self, args):
        EitLock.__init__(self, args)
        self._repository_id = None
        self._action_lock = False
Exemple #32
0
                    importance=1, level="error")
                return 1

        if not etp_pkg_files:
            entropy_server.output(
                teal(_("no valid package paths")),
                importance=1, level="error")
            return 1

        # in this case, no split package files are provided
        repository_id = entropy_server.repository()
        etp_pkg_files = [([x], True,) for x in etp_pkg_files]
        package_ids = entropy_server.add_packages_to_repository(
            repository_id, etp_pkg_files)
        if package_ids:
            # checking dependencies and print issues
            entropy_server.extended_dependencies_test([repository_id])

        entropy_server.commit_repositories()
        if package_ids:
            return 0
        return 1


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitInject,
        EitInject.NAME,
        _('inject package files into repository'))
    )
Exemple #33
0
            atom = entropy_repository.retrieveAtom(pkg_id)
            if atom is None:
                continue
            if not self._verbose:
                atom = entropy.dep.dep_getkey(atom)

            branchinfo = ""
            sizeinfo = ""
            if self._verbose:
                branch = entropy_repository.retrieveBranch(pkg_id)
                branchinfo = darkgreen("[") + teal(branch) + darkgreen("]")
                mysize = entropy_repository.retrieveOnDiskSize(pkg_id)
                mysize = entropy.tools.bytes_into_human(mysize)
                sizeinfo = brown("[") + purple(mysize) + brown("]")

            if not self._quiet:
                entropy_server.output("%s %s %s" %
                                      (atom, sizeinfo, branchinfo),
                                      header="")
            else:
                entropy_server.output(atom, level="generic")

        if not pkg_ids and not self._quiet:
            entropy_server.output(darkgreen(_("No packages")),
                                  header=brown(" @@ "))


EitCommandDescriptor.register(
    EitCommandDescriptor(EitList, EitList.NAME,
                         _("show repository content (packages)")))
Exemple #34
0
    def _reset(self, entropy_server):
        repository_id = self._reset_repository_id
        if repository_id is None:
            repository_id = entropy_server.repository()
        rev_path = entropy_server._get_local_repository_revision_file(
            repository_id)

        try:
            with open(rev_path, "w") as rev_f:
                rev_f.write("0\n")
        except (IOError, OSError) as err:
            entropy_server.output(
                "%s: %s" % (_("reset error"), err),
                importance=1, level="error")
            return 1

        entropy_server.output(
            darkgreen(_("local repository revision reset complete")),
            importance=1)
        if self._local:
            return 0

        return self._pull(entropy_server)

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitReset,
        EitReset.NAME,
        _('reset repository to remote status'))
    )
Exemple #35
0
        """
        return self._man()

    def parse(self):
        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._log, nsargs.repo]

    def _log(self, entropy_server):
        changelog_path = \
            entropy_server._get_local_repository_compressed_changelog_file(
                entropy_server.repository())

        if not const_file_readable(changelog_path):
            entropy_server.output(_("log is not available"),
                                  importance=1,
                                  level="error")
            return 1

        proc = subprocess.Popen(["bzless", changelog_path])
        return proc.wait()


EitCommandDescriptor.register(
    EitCommandDescriptor(EitLog, EitLog.NAME, _('show log for repository')))
Exemple #36
0
            repo_mirrors = meta['repo_mirrors']
            pkg_mirrors = meta['pkg_mirrors']

            entropy_server.output(
                "%s [%s]%s" % (
                    teal(repository_id),
                    darkgreen(description),
                    default_str,
                ))
            for repo_mirror in repo_mirrors:
                entropy_server.output(
                    "  %s: %s" % (
                        blue(_("repository")),
                        brown(repo_mirror),
                    ))
            for pkg_mirror in pkg_mirrors:
                entropy_server.output(
                    "  %s: %s" % (
                        blue(_("packages")),
                        brown(pkg_mirror),
                    ))

        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitRemote,
        EitRemote.NAME,
        _('manage repositories'))
    )
Exemple #37
0
            key_stream = repo_sec.get_pubkey(repo)
        else:
            key_stream = repo_sec.get_privkey(repo)

        # write to file
        try:
            with open(store_path, "w") as dest_w:
                dest_w.write(key_stream)
                dest_w.flush()
        except IOError as err:
            entropy_server.output("%s: %s [%s]" % (
                darkgreen(_("Unable to export GPG key for repository")),
                bold(repo),
                err,
            ),
                                  level="error")
            return 1

        entropy_server.output("%s: %s [%s]" % (
            darkgreen(_("Exported GPG key for repository")),
            bold(repo),
            brown(store_path),
        ),
                              level="info")

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitKey, EitKey.NAME, _('manage repository GPG keys')))
Exemple #38
0
            description=descriptor.get_description(),
            formatter_class=argparse.RawDescriptionHelpFormatter,
            prog="%s %s" % (sys.argv[0], EitRepack.NAME))

        parser.add_argument("packages", nargs='+', metavar="<package>",
                            help=_("package names"))
        parser.add_argument("--in", metavar="<repository>",
                            help=_("repack to given repository"),
                            default=None, dest="into")
        return parser

    def parse(self):
        """ Overridden from EitCommit """
        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, []

        # setup atoms variable before spawning commit
        self._repackage = nsargs.packages[:]
        return self._call_exclusive, [self._commit, nsargs.into]

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitRepack,
        EitRepack.NAME,
        _('rebuild packages in repository'))
    )
Exemple #39
0
        return self._call_exclusive, [self._reset, nsargs.repo]

    def _reset(self, entropy_server):
        repository_id = self._reset_repository_id
        if repository_id is None:
            repository_id = entropy_server.repository()
        rev_path = entropy_server._get_local_repository_revision_file(
            repository_id)

        try:
            with open(rev_path, "w") as rev_f:
                rev_f.write("0\n")
        except (IOError, OSError) as err:
            entropy_server.output("%s: %s" % (_("reset error"), err),
                                  importance=1,
                                  level="error")
            return 1

        entropy_server.output(darkgreen(
            _("local repository revision reset complete")),
                              importance=1)
        if self._local:
            return 0

        return self._pull(entropy_server)


EitCommandDescriptor.register(
    EitCommandDescriptor(EitReset, EitReset.NAME,
                         _('reset repository to remote status')))
Exemple #40
0
                                   "and slot updates"),
                            default=self._conservative)
        parser.add_argument("--to", metavar="<repository>",
                            help=_("add to given repository"),
                            default=None)
        parser.add_argument("--quick", action="store_true",
                            default=not self._ask,
                            help=_("no stupid questions"))
        return parser

    def parse(self):
        """ Overridden from EitCommit """
        parser = self._get_parser()
        try:
            nsargs = parser.parse_args(self._args)
        except IOError as err:
            return parser.print_help, []

        # setup atoms variable before spawning commit
        self._ask = not nsargs.quick
        self._entropy_class()._inhibit_treeupdates = nsargs.conservative
        self._packages = nsargs.packages[:]
        return self._call_exclusive, [self._commit, nsargs.to]

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitAdd,
        EitAdd.NAME,
        _('commit to repository the provided packages'))
    )
Exemple #41
0
                        purple(repository_id),
                        blue(_("repository not available")),),
                    level="warning", importance=1)
                exit_st = 1
                continue

            parser = RepositoryConfigParser()
            removed = parser.remove(repository_id)
            if not removed:
                exit_st = 1
                entropy_server.output(
                    "[%s] %s" % (
                        purple(repository_id),
                        blue(_("cannot remove repository")),),
                    level="warning", importance=1)
            else:
                entropy_server.output(
                    "[%s] %s" % (
                        purple(repository_id),
                        blue(_("repository removed succesfully")),))

        return exit_st


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitRepo,
        EitRepo.NAME,
        _("manage repositories"))
    )
Exemple #42
0
            except (OSError) as err:
                if err.errno != errno.ENOENT:
                    raise

        # write new actions
        actions_meta = []
        # time is completely fake, no particular precision required
        for unix_time, action in new_actions:
            # make sure unix_time has final .XX
            if "." not in unix_time:
                unix_time += ".00"
            elif unix_time.index(".") == (len(unix_time) - 2):
                # only .X and not .XX
                unix_time += "0"
            actions_meta.append((action, branch, unix_time))

        repo.removeTreeUpdatesActions(self._repository_id)
        try:
            repo.insertTreeUpdatesActions(actions_meta, self._repository_id)
        except Exception as err:
            repo.rollback()
            raise
        repo.commit()

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitPkgmove, EitPkgmove.NAME,
                         _('edit automatic package moves for repository')))
Exemple #43
0
            importance=1, header=brown(" @@ "))

        repo_map = {}
        for pkg_id, repo_id in pkg_matches:
            repo = entropy_server.open_repository(repo_id)
            pkgatom = repo.retrieveAtom(pkg_id)
            entropy_server.output(
                "[%s] %s" % (teal(repo_id), purple(pkgatom)),
                header=brown("   # "))
            obj = repo_map.setdefault(repo_id, [])
            obj.append(pkg_id)

        if self._ask:
            resp = entropy_server.ask_question(
                _("Would you like to continue ?"))
            if resp == _("No"):
                return 0

        for repo_id, pkg_ids in repo_map.items():
            entropy_server.remove_packages(repo_id, pkg_ids)

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitRemove,
        EitRemove.NAME,
        _('remove packages from repository'))
    )
Exemple #44
0
            with open(store_path, "w") as dest_w:
                dest_w.write(key_stream)
                dest_w.flush()
        except IOError as err:
            entropy_server.output("%s: %s [%s]" % (
                    darkgreen(
                        _("Unable to export GPG key for repository")),
                    bold(repo),
                    err,
                ),
                level = "error"
            )
            return 1

        entropy_server.output("%s: %s [%s]" % (
                darkgreen(_("Exported GPG key for repository")),
                bold(repo),
                brown(store_path),
            ),
            level = "info"
        )

        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitKey,
        EitKey.NAME,
        _('manage repository GPG keys'))
    )
Exemple #45
0
            repo = entropy_server.open_repository(repository_id)
            key_sorter = lambda x: repo.retrieveAtom(x)
            for desc in self._nsargs.descriptions:
                pkg_ids = repo.searchDescription(desc, just_id = True)
                for pkg_id in sorted(pkg_ids, key = key_sorter):
                    if self._quiet:
                        entropy_server.output(
                            repo.retrieveAtom(pkg_id), level="generic")
                    else:
                        print_package_info(pkg_id, entropy_server, repo,
                                     extended = self._verbose,
                                     strict_output = False,
                                     quiet = False)

                if not self._quiet:
                    entropy_server.output(
                        "[%s] %s %s" % (
                            darkgreen(desc),
                            bold(str(len(pkg_ids))),
                            teal(_("packages found"))))

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitQuery,
        EitQuery.NAME,
        _('miscellaneous package metadata queries'))
    )
Exemple #46
0
            to_be_added = set(map(pkg_filter, self._packages))
            to_be_added.discard(None)

        if not (to_be_removed or to_be_added or to_be_injected):
            entropy_server.output(red(_("Zarro thinggz to do")),
                                  header=brown(" * "),
                                  importance=1)
            return 0

        exit_st = 0
        if to_be_injected:
            injected_s = sorted(to_be_injected, key=key_sorter)
            self._inject_packages(entropy_server, injected_s)

        if to_be_removed:
            removed_s = sorted(to_be_removed, key=key_sorter)
            self._remove_packages(entropy_server, removed_s)

        if to_be_added:
            # drop spm_uid, no longer needed
            added_s = sorted(to_be_added)
            exit_st = self._add_packages(entropy_server, repository_id,
                                         added_s)

        return exit_st


EitCommandDescriptor.register(
    EitCommandDescriptor(EitCommit, EitCommit.NAME,
                         _("commit changes to repository")))
Exemple #47
0
    def man(self):
        """
        Overridden from EitCommand.
        """
        return self._man()

    def parse(self):
        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, []

        self._source = nsargs.source
        self._dest = nsargs.dest
        self._deps = nsargs.deps
        self._packages += nsargs.packages
        self._copy = False
        self._entropy_class()._inhibit_treeupdates = nsargs.conservative

        return self._call_locked, [self._move_copy, self._source]


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitMv,
        EitMv.NAME,
        _('move packages from a repository to another'))
    )
Exemple #48
0
            repository_id = entropy_server.repository()
        if repository_id not in entropy_server.repositories():
            entropy_server.output(
                "%s: %s" % (
                    purple(_("Invalid repository")),
                    teal(repository_id)),
                importance=1, level="error")
            return 1

        fine, failed, dl_fine, dl_err = \
            entropy_server._verify_local_packages(
                repository_id, [], ask = not self._nsargs.quick)
        if failed:
            return 1
        return 0

    def _rem_pkgtest(self, entropy_server):
        repository_id = self._nsargs.repo
        if repository_id is None:
            repository_id = entropy_server.repository()
        entropy_server._verify_remote_packages(repository_id, [],
            ask = self._ask)
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitTest,
        EitTest.NAME,
        _('run QA tests'))
    )
Exemple #49
0
        if not (to_be_removed or to_be_added or to_be_injected):
            entropy_server.output(
                red(_("Zarro thinggz to do")),
                header=brown(" * "),
                importance=1)
            return 0

        exit_st = 0
        if to_be_injected:
            injected_s = sorted(to_be_injected, key=key_sorter)
            self._inject_packages(entropy_server, injected_s)

        if to_be_removed:
            removed_s = sorted(to_be_removed, key=key_sorter)
            self._remove_packages(entropy_server, removed_s)

        if to_be_added:
            # drop spm_uid, no longer needed
            added_s = sorted(to_be_added)
            exit_st = self._add_packages(entropy_server, repository_id, added_s)

        return exit_st


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitCommit,
        EitCommit.NAME,
        _("commit changes to repository"))
    )
Exemple #50
0
                if pkg_id != -1:
                    etp_repo = entropy_server.open_repository(
                        repo_id).retrieveSpmRepository(pkg_id)
                    if etp_repo != spm_repo:
                        pkg_str += " [%s=>%s]" % (
                            etp_repo, spm_repo,)
            toc.append(("   %s:" % (purple(_("add")),), teal(pkg_str)))

        for package_id, repo_id in sorted(to_be_removed, key = key_sorter):
            pkg_atom = entropy_server.open_repository(
                repo_id).retrieveAtom(package_id)
            toc.append(("   %s:" % (darkred(_("remove")),),
                        brown(pkg_atom)))

        for package_id, repo_id in sorted(to_be_injected,
                                          key = key_sorter):
            pkg_atom = entropy_server.open_repository(
                repo_id).retrieveAtom( package_id)
            toc.append(("   %s:" % (bold(_("switch injected")),),
                        darkgreen(pkg_atom)))

        print_table(entropy_server, toc)
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitStatus,
        EitStatus.NAME,
        _("show repository status"))
    )
Exemple #51
0
        if not_found or no_checksum:
            return 1
        return 0

    def _status(self, entropy_server):
        """
        Show branch information (list of branches, current branch)
        """
        repository_id = entropy_server.repository()
        branch_dir = entropy_server._get_local_repository_dir(
            repository_id, branch="")
        branches = []
        if os.path.isdir(branch_dir):
            branches += [x for x in os.listdir(branch_dir) if \
                os.path.isdir(os.path.join(branch_dir, x))]
        current_branch = self._settings()['repositories']['branch']
        branches.sort()
        for branch in branches:
            cur_txt = ""
            if branch == current_branch:
                cur_txt = purple("*") + " "
            entropy_server.output("%s%s" % (cur_txt, branch))
        return 0

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitBranch,
        EitBranch.NAME,
        _('manage repository branches'))
    )
Exemple #52
0
            nsargs = parser.parse_args(self._args)
        except IOError:
            return parser.print_help, []

        self._quiet = nsargs.quiet
        self._packages += nsargs.packages
        self._complete = nsargs.complete
        self._repository_id = nsargs.inrepo
        return self._call_shared, [self._revgraph, self._repository_id]

    def _revgraph(self, entropy_server):
        """
        Actual Eit revgraph code.
        """
        if self._repository_id is None:
            repository_ids = entropy_server.repositories()
        else:
            repository_ids = [self._repository_id]
        return revgraph_packages(
            self._packages, entropy_server,
            complete = self._complete,
            repository_ids = repository_ids, quiet = self._quiet)


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitRevgraph,
        EitRevgraph.NAME,
        _('show reverse dependency graph for packages'))
    )
Exemple #53
0
        """
        return self._man()

    def parse(self):
        """ Overridden from EitCommit """
        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, []

        self._ask = not nsargs.quick
        self._merge_branch = nsargs.branch
        return self._call_exclusive, [self._branch, nsargs.into]

    def _branch(self, entropy_server):
        """
        Eit branch code.
        """
        return entropy_server.flushback_packages(
            entropy_server.repository(),
            [self._merge_branch], ask = self._ask)

EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitMerge,
        EitMerge.NAME,
        _('merge packages on other branches into current'))
    )
Exemple #54
0
                    (pkg_id not in package_ids)]

        if (not self._packages) and (not package_ids):
            entropy_server.output(
                purple(_("Considering all the packages")),
                importance=1, level="warning")
            repo = entropy_server.open_repository(self._source)
            package_ids = repo.listAllPackageIds()

        if not package_ids:
            return 1

        rc = False
        if self._copy:
            rc = entropy_server.copy_packages(package_ids, self._source,
                self._dest, pull_dependencies = self._deps)
        else:
            rc = entropy_server.move_packages(package_ids, self._source,
                self._dest, pull_dependencies = self._deps)
        if rc:
            return 0
        return 1


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitCp,
        EitCp.NAME,
        _('copy packages from a repository to another'))
    )
Exemple #55
0
        # write new actions
        actions_meta = []
        # time is completely fake, no particular precision required
        for unix_time, action in new_actions:
            # make sure unix_time has final .XX
            if "." not in unix_time:
                unix_time += ".00"
            elif unix_time.index(".") == (len(unix_time) - 2):
                # only .X and not .XX
                unix_time += "0"
            actions_meta.append((action, branch, unix_time))

        repo.removeTreeUpdatesActions(self._repository_id)
        try:
            repo.insertTreeUpdatesActions(actions_meta, self._repository_id)
        except Exception as err:
            repo.rollback()
            raise
        repo.commit()

        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitPkgmove,
        EitPkgmove.NAME,
        _('edit automatic package moves for repository'))
    )
Exemple #56
0
        """
        count = 0
        for package in self._packages:
            pkg_id, pkg_repo = entropy_server.atom_match(package)
            if pkg_id == -1:
                continue

            count += 1
            print_package_info(
                pkg_id,
                entropy_server,
                entropy_server.open_repository(pkg_repo),
                installed_search = True,
                extended = True,
                quiet = self._quiet
            )

        if not count and not self._quiet:
            entropy_server.output(
                purple(_("Nothing found")),
                importance=1, level="warning")
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(
        EitMatch,
        EitMatch.NAME,
        _('match packages in repositories'))
    )
Exemple #57
0
            entropy_server.output(purple(
                _("Users with older repositories will have to update")),
                                  importance=1,
                                  level="warning")
            entropy_server.output("", level="warning")

        repository_id = entropy_server.repository()
        entropy_server.Mirrors.tidy_mirrors(repository_id,
                                            ask=self._ask,
                                            pretend=self._pretend,
                                            expiration_days=self._days)
        return 0


EitCommandDescriptor.register(
    EitCommandDescriptor(EitCleanup, EitCleanup.NAME,
                         _('clean expired packages from a repository')))


class EitVacuum(EitCleanup):
    """
    Main Eit vacuum command (kept for backward compat).
    """

    NAME = "vacuum"
    ALIASES = []

    def __init__(self, args):
        EitCleanup.__init__(self, args)
        # default is 0 here
        self._days = 0