Ejemplo n.º 1
0
    def __initialize_repo_manager(self):
        if self.repo_manager:
            return
        """ Clean up repo metadata """
        shutil.rmtree(self.creator.cachedir + "/etc", ignore_errors=True)
        shutil.rmtree(self.creator.cachedir + "/solv", ignore_errors=True)
        shutil.rmtree(self.creator.cachedir + "/raw", ignore_errors=True)

        zypp.KeyRing.setDefaultAccept(zypp.KeyRing.ACCEPT_UNSIGNED_FILE
                                      | zypp.KeyRing.ACCEPT_VERIFICATION_FAILED
                                      | zypp.KeyRing.ACCEPT_UNKNOWNKEY
                                      | zypp.KeyRing.TRUST_KEY_TEMPORARILY)
        self.repo_manager_options = zypp.RepoManagerOptions(
            zypp.Pathname(self.creator._instroot))
        self.repo_manager_options.knownReposPath = zypp.Pathname(
            self.creator.cachedir + "/etc/zypp/repos.d")
        self.repo_manager_options.repoCachePath = zypp.Pathname(
            self.creator.cachedir)
        self.repo_manager_options.repoRawCachePath = zypp.Pathname(
            self.creator.cachedir + "/raw")
        self.repo_manager_options.repoSolvCachePath = zypp.Pathname(
            self.creator.cachedir + "/solv")
        self.repo_manager_options.repoPackagesCachePath = zypp.Pathname(
            self.creator.cachedir + "/packages")

        self.repo_manager = zypp.RepoManager(self.repo_manager_options)
Ejemplo n.º 2
0
 def testpath(self):
   import zypp
   Z = zypp.ZYppFactory.instance().getZYpp()
   assert Z
   Z.initializeTarget( zypp.Pathname("/") )
   Z.target().load()
   installed_pkgs = Z.pool()
   for item in installed_pkgs:
       if zypp.isKindPackage(item):
           print("Repopath %s" % item.repoInfo().packagesPath())
           item = zypp.asKindPackage(item)
           print("Location filename %s" % item.location().filename())
           print("%s.%s %s:%d" % (item.name(), item.arch(), item.edition(), item.installSize()))
Ejemplo n.º 3
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.º 4
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.º 5
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()
            "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():
        repo = create_repo(
            name, details[0], details[1], details[2], details[3])
        add_repo(rm, repo)
Ejemplo n.º 7
0
 def teststarting(self):
     import zypp
     Z = zypp.ZYppFactory.instance().getZYpp()
     assert Z
     Z.initializeTarget(zypp.Pathname("/"))
     Z.target().load()