return False
- def runInstall(self, checksize = 0):
- os.environ["HOME"] = "/"
- os.environ["LD_PRELOAD"] = ""
- try:
- (res, resmsg) = self.buildTransaction()
- except yum.Errors.RepoError as e:
- raise CreatorError("Unable to download from repo : %s" %(e,))
-
- if res != 2:
- raise CreatorError("Failed to build transaction : %s" \
- % str.join("\n", resmsg))
-
- dlpkgs = [x.po for x in [txmbr for txmbr in self.tsInfo.getMembers() if txmbr.ts_state in ("i", "u")]]
-
- # record all pkg and the content
- for pkg in dlpkgs:
- pkg_long_name = misc.RPM_FMT % {
- 'name': pkg.name,
- 'arch': pkg.arch,
- 'version': pkg.version,
- 'release': pkg.release
- }
- self.__pkgs_content[pkg_long_name] = pkg.files
- license = pkg.license
- if license in list(self.__pkgs_license.keys()):
- self.__pkgs_license[license].append(pkg_long_name)
- else:
- self.__pkgs_license[license] = [pkg_long_name]
-
- if pkg.name in self.check_pkgs:
- self.check_pkgs.remove(pkg.name)
-
- if self.check_pkgs:
- raise CreatorError('Packages absent in image: %s' % ','.join(self.check_pkgs))
-
- total_count = len(dlpkgs)
- cached_count = 0
- download_total_size = sum([int(x.packagesize) for x in dlpkgs])
-
- msger.info("\nChecking packages cached ...")
- for po in dlpkgs:
- local = po.localPkg()
- repo = list(filter(lambda r: r.id == po.repoid, self.repos.listEnabled()))[0]
- if repo.nocache and os.path.exists(local):
- os.unlink(local)
- if not os.path.exists(local):
- continue
- if not self.verifyPkg(local, po, False):
- msger.warning("Package %s is damaged: %s" \
- % (os.path.basename(local), local))
- else:
- download_total_size -= int(po.packagesize)
- cached_count += 1
-
- cache_avail_size = misc.get_filesystem_avail(self.cachedir)
- if cache_avail_size < download_total_size:
- raise CreatorError("No enough space used for downloading.")
-
- # record the total size of installed pkgs
- pkgs_total_size = 0
- for x in dlpkgs:
- if hasattr(x, 'installedsize'):
- pkgs_total_size += int(x.installedsize)
- else:
- pkgs_total_size += int(x.size)
-
- # check needed size before actually download and install
- if checksize and pkgs_total_size > checksize:
- raise CreatorError("No enough space used for installing, "
- "please resize partition size in ks file")
-
- msger.info("Packages: %d Total, %d Cached, %d Missed" \
- % (total_count, cached_count, total_count - cached_count))
-
- try:
- repos = self.repos.listEnabled()
- for repo in repos:
- repo.setCallback(TextProgress(total_count - cached_count))
-
- self.downloadPkgs(dlpkgs)
- # FIXME: sigcheck?
-
- self.initActionTs()
- self.populateTs(keepold=0)
-
- deps = self.ts.check()
- if len(deps) != 0:
- # This isn't fatal, Ubuntu has this issue but it is ok.
- msger.debug(deps)
- msger.warning("Dependency check failed!")
-
- rc = self.ts.order()
- if rc != 0:
- raise CreatorError("ordering packages for installation failed")
-
- # FIXME: callback should be refactored a little in yum
- cb = rpmmisc.RPMInstallCallback(self.ts)
- cb.tsInfo = self.tsInfo
- cb.filelog = False
-
- msger.warning('\nCaution, do NOT interrupt the installation, '
- 'else mic cannot finish the cleanup.')
-
- installlogfile = "%s/__catched_stderr.buf" % (self.instroot)
- msger.enable_logstderr(installlogfile)
- #clean rpm lock
- self._cleanupRpmdbLocks(self.conf.installroot)
- transactionResult = self.runTransaction(cb)
- if transactionResult.return_code != 0 and self.strict_mode:
- raise CreatorError("mic failes to install some packages")
-
- except rpmUtils.RpmUtilsError as e:
- raise CreatorError("mic does NOT support delta rpm: %s" % e)
- except yum.Errors.RepoError as e:
- raise CreatorError("Unable to download from repo : %s" % e)
- except yum.Errors.YumBaseError as e:
- raise CreatorError("Unable to install: %s" % e)
- finally:
- msger.disable_logstderr()
--
def getVcsInfo(self):
if self.__pkgs_vcsinfo:
return self.__pkgs_vcsinfo