Ejemplo n.º 1
0
    def __initialize_zypp(self):
        if self.Z:
            return

        zconfig = zypp.ZConfig_instance()
        """ Set system architecture """
        if self.creator.target_arch:
            zconfig.setSystemArchitecture(zypp.Arch(self.creator.target_arch))

        msger.info("zypp architecture is <%s>" % zconfig.systemArchitecture())
        """ repoPackagesCachePath is corrected by this """
        self.repo_manager = zypp.RepoManager(self.repo_manager_options)
        repos = self.repo_manager.knownRepositories()
        for repo in repos:
            if not repo.enabled():
                continue
            self.repo_manager.loadFromCache(repo)

        self.Z = zypp.ZYppFactory_instance().getZYpp()
        self.Z.initializeTarget(zypp.Pathname(self.creator._instroot))
        self.Z.target().load()
Ejemplo n.º 2
0
    def __init__(self):
        """
        Initialize Zypp and load all enabled repositories.
        """
        self.Z = zypp.ZYppFactory_instance().getZYpp()

        # Load system rooted at "/"...
        self.Z.initializeTarget(zypp.Pathname("/"))
        self.Z.target().load()

        # Load all enabled repositories...
        repoManager = zypp.RepoManager()
        for repo in repoManager.knownRepositories():
            if not repo.enabled():
                continue
            if not repoManager.isCached(repo):
                repoManager.buildCache(repo)
            repoManager.loadFromCache(repo)

        # Now all installed and available items are in the pool:
        log.debug("Known items: %d" % (self.Z.pool().size()))
Ejemplo n.º 3
0
    def setUp(self):
        #
        # Normal zypp startup
        #
        self.Z = zypp.ZYppFactory_instance().getZYpp()
        self.Z.initializeTarget(zypp.Pathname("/"))
        self.Z.target().load()

        # The 'zypp.CommitCallbacksEmitter()' is a test/debug class
        # which can be used to trigger various callbacks
        # (This is callback test code - we cannot do an actual package uninstall here!)
        self.commit_callbacks_emitter = zypp.CommitCallbacksEmitter()

        #
        # create an instance of our CommitReceiver class defined above
        #
        self.commit_receiver = CommitReceiver()

        # zypp.CommitCallbacks is the callback 'handler' which must be informed
        # about the receiver
        self.commit_callbacks = zypp.CommitCallbacks()

        #
        # Ensure that no other receiver is registered
        #
        assert None == self.commit_callbacks.receiver()

        #
        # Connect the receiver instance with the callback handler
        #
        self.commit_callbacks.connect(self.commit_receiver)

        #
        # Ensure that its set correctly
        #
        assert self.commit_receiver == self.commit_callbacks.receiver()
            "curl",
            "git-core",
            "lua-devel",
            "psmisc",
            "python-devel",
            "shadow",
            "sudo",
            "tmux",
            "util-linux",
            "vim",
            "wget",
            "zsh")


if __name__ == "__main__":
    zp = zypp.ZYppFactory_instance().getZYpp()

    # Must init.
    # https://github.com/openSUSE/libzypp/blob/master/zypp/ZYpp.h
    zp.initializeTarget(zypp.Pathname("/"))

    # https://github.com/openSUSE/libzypp/blob/master/zypp/Target.h
    zp.target().load()

    # https://github.com/openSUSE/libzypp/blob/master/zypp/RepoManager.h
    rm = zypp.RepoManager()
    # remove current repos
    remove_repo(rm)

    # add repos
    for name, details in REPOS.iteritems():