class Yum(BackendPlugin, yum.YumBase):
name = 'yum'
- def __init__(self, creator = None):
- if not isinstance(creator, BaseImageCreator):
- raise CreatorError("Invalid argument: creator")
+ def __init__(self, target_arch, instroot, cachedir):
yum.YumBase.__init__(self)
- self.creator = creator
+ self.cachedir = cachedir
+ self.instroot = instroot
+ self.target_arch = target_arch
- if self.creator.target_arch:
- if not rpmUtils.arch.arches.has_key(self.creator.target_arch):
+ if self.target_arch:
+ if not rpmUtils.arch.arches.has_key(self.target_arch):
rpmUtils.arch.arches["armv7hl"] = "noarch"
rpmUtils.arch.arches["armv7tnhl"] = "armv7nhl"
rpmUtils.arch.arches["armv7tnhl"] = "armv7thl"
rpmUtils.arch.arches["armv7thl"] = "armv7hl"
rpmUtils.arch.arches["armv7nhl"] = "armv7hl"
- self.arch.setup_arch(self.creator.target_arch)
+ self.arch.setup_arch(self.target_arch)
self.__pkgs_license = {}
self.__pkgs_content = {}
cb.filelog = False
msger.warning('\nCaution, do NOT interrupt the installation, else mic cannot finish the cleanup.')
- installlogfile = "%s/__catched_stderr.buf" % (self.creator._instroot)
+ installlogfile = "%s/__catched_stderr.buf" % (self.instroot)
msger.enable_logstderr(installlogfile)
ret = self.runTransaction(cb)
self._cleanupRpmdbLocks(self.conf.installroot)
class Zypp(BackendPlugin):
name = 'zypp'
- def __init__(self, creator = None):
- if not isinstance(creator, BaseImageCreator):
- raise CreatorError("Invalid argument: creator")
+ def __init__(self, target_arch, instroot, cachedir):
+ self.cachedir = cachedir
+ self.instroot = instroot
+ self.target_arch = target_arch
self.__pkgs_license = {}
self.__pkgs_content = {}
- self.creator = creator
self.repos = []
self.to_deselect = []
self.localpkgs = {}
arch = None
if len(sp) == 2:
arch = sp[1]
- if self.creator.target_arch == None:
- # TODO, get the default_arch from conf or detected from global settings
- sysarch = zypp.Arch('i686')
- else:
- sysarch = zypp.Arch(self.creator.target_arch)
+ sysarch = zypp.Arch(self.target_arch)
if not zypp.Arch(arch).compatible_with (sysarch):
arch = None
name = ".".join(sp)
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)
+ shutil.rmtree(self.cachedir + "/etc", ignore_errors = True)
+ shutil.rmtree(self.cachedir + "/solv", ignore_errors = True)
+ shutil.rmtree(self.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_options = zypp.RepoManagerOptions(zypp.Pathname(self.instroot))
+ self.repo_manager_options.knownReposPath = zypp.Pathname(self.cachedir + "/etc/zypp/repos.d")
+ self.repo_manager_options.repoCachePath = zypp.Pathname(self.cachedir)
+ self.repo_manager_options.repoRawCachePath = zypp.Pathname(self.cachedir + "/raw")
+ self.repo_manager_options.repoSolvCachePath = zypp.Pathname(self.cachedir + "/solv")
+ self.repo_manager_options.repoPackagesCachePath = zypp.Pathname(self.cachedir + "/packages")
self.repo_manager = zypp.RepoManager(self.repo_manager_options)
zconfig = zypp.ZConfig_instance()
""" Set system architecture """
- if self.creator.target_arch:
- zconfig.setSystemArchitecture(zypp.Arch(self.creator.target_arch))
+ if self.target_arch:
+ zconfig.setSystemArchitecture(zypp.Arch(self.target_arch))
msger.info("zypp architecture is <%s>" % zconfig.systemArchitecture())
self.repo_manager.loadFromCache(repo)
self.Z = zypp.ZYppFactory_instance().getZYpp()
- self.Z.initializeTarget(zypp.Pathname(self.creator._instroot))
+ self.Z.initializeTarget(zypp.Pathname(self.instroot))
self.Z.target().load()
def installLocal(self, pkg, po=None, updateonly=False):
if not self.ts:
self.__initialize_transaction()
- solvfile = "%s/.solv" % (self.creator.cachedir)
+ solvfile = "%s/.solv" % (self.cachedir)
rc, out = runner.runtool([fs_related.find_binary_path("rpms2solv"), pkg])
if rc == 0:
f = open(solvfile, "w+")
msger.warning('Can not get %s solv data.' % pkg)
hdr = rpmmisc.readRpmHeader(self.ts, pkg)
arch = zypp.Arch(hdr['arch'])
- if self.creator.target_arch == None:
- # TODO, get the default_arch from conf or detected from global settings
- sysarch = zypp.Arch('i686')
- else:
- sysarch = zypp.Arch(self.creator.target_arch)
+ sysarch = zypp.Arch(self.target_arch)
if arch.compatible_with (sysarch):
pkgname = hdr['name']
self.localpkgs[pkgname] = pkg
if not unresolved_dependencies:
self.ts.order()
cb = rpmmisc.RPMInstallCallback(self.ts)
- installlogfile = "%s/__catched_stderr.buf" % (self.creator._instroot)
+ installlogfile = "%s/__catched_stderr.buf" % (self.instroot)
msger.enable_logstderr(installlogfile)
errors = self.ts.run(cb.callback, '')
if errors is None:
def __initialize_transaction(self):
if not self.ts:
- self.ts = rpm.TransactionSet(self.creator._instroot)
+ self.ts = rpm.TransactionSet(self.instroot)
# Set to not verify DSA signatures.
self.ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS)