def _castKind(self, poolitem): item = None if zypp.isKindPattern(poolitem): item = zypp.asKindPattern(poolitem) elif zypp.isKindPackage(poolitem): item = zypp.asKindPackage(poolitem) elif zypp.isKindResolvable(poolitem): item = zypp.asKindResolvable(poolitem) return item
def derefGroups(self): self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall groups_found = False for xitem in installed_pkgs: if zypp.isKindPattern(xitem): item = self._castKind(xitem) msger.debug("%s is going to be derefed" % item.name()) self.selectGroup(item.name()) groups_found = True return groups_found
def runInstall(self, checksize=0): os.environ["HOME"] = "/" self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall dlpkgs = [] for item in installed_pkgs: if not zypp.isKindPattern(item) and not self.inDeselectPackages( item): dlpkgs.append(item) # record the total size of installed pkgs pkgs_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) # check needed size before actually download and install if checksize and pkgs_total_size > checksize: raise CreatorError( "Size of specified root partition in kickstart file is too small to install all selected packages." ) # record all pkg and the content localpkgs = self.localpkgs.keys() for pkg in dlpkgs: license = '' if pkg.name() in localpkgs: hdr = rpmmisc.readRpmHeader(self.ts, self.localpkgs[pkg.name()]) pkg_long_name = "%s-%s-%s.%s.rpm" % ( hdr['name'], hdr['version'], hdr['release'], hdr['arch']) license = hdr['license'] else: pkg_long_name = "%s-%s.%s.rpm" % (pkg.name(), pkg.edition(), pkg.arch()) package = zypp.asKindPackage(pkg) license = package.license() self.__pkgs_content[pkg_long_name] = {} #TBD: to get file list if license in self.__pkgs_license.keys(): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 localpkgs = self.localpkgs.keys() msger.info("Checking packages cache and packages integrity ...") for po in dlpkgs: """ Check if it is cached locally """ if po.name() in localpkgs: cached_count += 1 else: local = self.getLocalPkgPath(po) if os.path.exists(local): if self.checkPkg(local) != 0: os.unlink(local) else: cached_count += 1 download_count = total_count - cached_count msger.info( "%d packages to be installed, %d packages gotten from cache, %d packages to be downloaded" % (total_count, cached_count, download_count)) try: if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) self.installPkgs(dlpkgs) except RepoError, e: raise CreatorError("Unable to download from repo : %s" % (e, ))
def runInstall(self, checksize = 0): os.environ["HOME"] = "/" os.environ["LD_PRELOAD"] = "" self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall dlpkgs = [] for pitem in installed_pkgs: if not zypp.isKindPattern(pitem) and \ not self.inDeselectPackages(pitem): item = zypp.asKindPackage(pitem) dlpkgs.append(item) if not self.install_debuginfo or str(item.arch()) == "noarch": continue dipkg = self._zyppQueryPackage("%s-debuginfo" % item.name()) if dipkg: ditem = zypp.asKindPackage(dipkg) dlpkgs.append(ditem) else: msger.warning("No debuginfo rpm found for: %s" \ % item.name()) # record all pkg and the content localpkgs = self.localpkgs.keys() for pkg in dlpkgs: license = '' if pkg.name() in localpkgs: hdr = rpmmisc.readRpmHeader(self.ts, self.localpkgs[pkg.name()]) pkg_long_name = misc.RPM_FMT % { 'name': hdr['name'], 'arch': hdr['arch'], 'version': hdr['version'], 'release': hdr['release'] } license = hdr['license'] else: pkg_long_name = misc.RPM_FMT % { 'name': pkg.name(), 'arch': pkg.arch(), 'version': pkg.edition().version(), 'release': pkg.edition().release() } license = pkg.license() if license in self.__pkgs_license.keys(): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 download_total_size = sum(map(lambda x: int(x.downloadSize()), dlpkgs)) localpkgs = self.localpkgs.keys() msger.info("Checking packages cached ...") for po in dlpkgs: # Check if it is cached locally if po.name() in localpkgs: cached_count += 1 else: local = self.getLocalPkgPath(po) name = str(po.repoInfo().name()) try: repo = filter(lambda r: r.name == name, self.repos)[0] except IndexError: repo = None nocache = repo.nocache if repo else False if os.path.exists(local): if nocache or self.checkPkg(local) !=0: os.unlink(local) else: download_total_size -= int(po.downloadSize()) 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 install_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) # check needed size before actually download and install # FIXME: for multiple partitions for loop type, check fails # skip the check temporarily #if checksize and install_total_size > checksize: # raise CreatorError("No enough space used for installing, " # "please resize partition size in ks file") download_count = total_count - cached_count msger.info("Packages: %d Total, %d Cached, %d Missed" \ % (total_count, cached_count, download_count)) try: if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) self.installPkgs(dlpkgs) except (RepoError, RpmError): raise except Exception, e: raise CreatorError("Package installation failed: %s" % (e,))
def runInstall(self, checksize = 0): os.environ["HOME"] = "/" self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall dlpkgs = [] for item in installed_pkgs: if not zypp.isKindPattern(item) and \ not self.inDeselectPackages(item): dlpkgs.append(item) # record all pkg and the content localpkgs = self.localpkgs.keys() for pkg in dlpkgs: license = '' if pkg.name() in localpkgs: hdr = rpmmisc.readRpmHeader(self.ts, self.localpkgs[pkg.name()]) pkg_long_name = misc.RPM_FMT % { 'name': hdr['name'], 'arch': hdr['arch'], 'ver_rel': '%s-%s' % (hdr['version'], hdr['release']), } license = hdr['license'] else: pkg_long_name = misc.RPM_FMT % { 'name': pkg.name(), 'arch': pkg.arch(), 'ver_rel': pkg.edition(), } package = zypp.asKindPackage(pkg) license = package.license() self.__pkgs_content[pkg_long_name] = {} #TBD: to get file list if license in self.__pkgs_license.keys(): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 download_total_size = sum(map(lambda x: int(x.downloadSize()), dlpkgs)) localpkgs = self.localpkgs.keys() msger.info("Checking packages cache and packages integrity ...") for po in dlpkgs: # Check if it is cached locally if po.name() in localpkgs: cached_count += 1 else: local = self.getLocalPkgPath(po) if os.path.exists(local): if self.checkPkg(local) != 0: os.unlink(local) else: download_total_size -= int(po.downloadSize()) 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 install_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) # check needed size before actually download and install # FIXME: for multiple partitions for loop type, check fails # skip the check temporarily #if checksize and install_total_size > checksize: # raise CreatorError("No enough space used for installing, " # "please resize partition size in ks file") download_count = total_count - cached_count msger.info("%d packages to be installed, " "%d packages gotten from cache, " "%d packages to be downloaded" \ % (total_count, cached_count, download_count)) try: if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) self.installPkgs(dlpkgs) except (RepoError, RpmError): raise except Exception, e: raise CreatorError("Package installation failed: %s" % (e,))
def runInstall(self, checksize = 0): #FIXME: WHY? os.environ["HOME"] = "/" os.environ["LD_PRELOAD"] = "" self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall dlpkgs = [] for xitem in installed_pkgs: if not zypp.isKindPattern(xitem): item = self._castKind(xitem) if not self.inDeselectPackages(item): dlpkgs.append(item) msger.debug("%s is going to be installed" % item.name()) # record all pkg and the content localpkgs = list(self.localpkgs.keys()) for package in dlpkgs: license = '' if package.name() in localpkgs: hdr = rpmmisc.readRpmHeader(self.ts, self.localpkgs[package.name()]) pkg_long_name = misc.RPM_FMT % { 'name': hdr['name'], 'arch': hdr['arch'], 'ver_rel': '%s-%s' % (hdr['version'], hdr['release']), } license = hdr['license'] else: pkg_long_name = misc.RPM_FMT % { 'name': package.name(), 'arch': package.arch(), 'ver_rel': package.edition(), } license = package.license() self.__pkgs_content[pkg_long_name] = {} #TBD: to get file list self.__pkgs_urls[pkg_long_name] = self.get_url(package) if license in list(self.__pkgs_license.keys()): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 download_total_size = sum([int(x.downloadSize()) for x in dlpkgs]) localpkgs = list(self.localpkgs.keys()) msger.info("Checking packages cache and packages integrity ...") for po in dlpkgs: # Check if it is cached locally if po.name() in localpkgs: cached_count += 1 else: local = self.getLocalPkgPath(po) if os.path.exists(local): if self.checkPkg(local, po.checksum()) != 0: os.unlink(local) else: download_total_size -= int(po.downloadSize()) 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 install_total_size = sum([int(x.installSize()) for x in dlpkgs]) # check needed size before actually download and install # FIXME: for multiple partitions for loop type, check fails # skip the check temporarily #if checksize and install_total_size > checksize: # raise CreatorError("No enough space used for installing, " # "please resize partition size in ks file") download_count = total_count - cached_count msger.info("%d packages to be installed, " "%d packages gotten from cache, " "%d packages to be downloaded" \ % (total_count, cached_count, download_count)) try: if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) self.installPkgs(dlpkgs) except (RepoError, RpmError): raise except Exception as e: raise CreatorError("Package installation failed: %s" % (e,))
def runInstall(self, checksize = 0): os.environ["HOME"] = "/" os.environ["LD_PRELOAD"] = "" self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall dlpkgs = [] for pitem in installed_pkgs: if not zypp.isKindPattern(pitem) and \ not self.inDeselectPackages(pitem): item = zypp.asKindPackage(pitem) dlpkgs.append(item) if item.name() in self.check_pkgs: self.check_pkgs.remove(item.name()) if not self.install_debuginfo or str(item.arch()) == "noarch": continue dipkg = self._zyppQueryPackage("%s-debuginfo" % item.name()) if dipkg: ditem = zypp.asKindPackage(dipkg) dlpkgs.append(ditem) else: msger.warning("No debuginfo rpm found for: %s" \ % item.name()) if self.check_pkgs: raise CreatorError('Packages absent in image: %s' % ','.join(self.check_pkgs)) # record all pkg and the content localpkgs = self.localpkgs.keys() for pkg in dlpkgs: license = '' if pkg.name() in localpkgs: hdr = rpmmisc.readRpmHeader(self.ts, self.localpkgs[pkg.name()]) pkg_long_name = misc.RPM_FMT % { 'name': hdr['name'], 'arch': hdr['arch'], 'version': hdr['version'], 'release': hdr['release'] } license = hdr['license'] else: pkg_long_name = misc.RPM_FMT % { 'name': pkg.name(), 'arch': pkg.arch(), 'version': pkg.edition().version(), 'release': pkg.edition().release() } license = pkg.license() if license in self.__pkgs_license.keys(): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 download_total_size = sum(map(lambda x: int(x.downloadSize()), dlpkgs)) localpkgs = self.localpkgs.keys() msger.info("Checking packages cached ...") for po in dlpkgs: # Check if it is cached locally if po.name() in localpkgs: cached_count += 1 else: local = self.getLocalPkgPath(po) name = str(po.repoInfo().name()) try: repo = filter(lambda r: r.name == name, self.repos)[0] except IndexError: repo = None nocache = repo.nocache if repo else False if os.path.exists(local): if nocache or self.checkPkg(local) !=0: os.unlink(local) else: download_total_size -= int(po.downloadSize()) 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 install_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) # check needed size before actually download and install # FIXME: for multiple partitions for loop type, check fails # skip the check temporarily #if checksize and install_total_size > checksize: # raise CreatorError("No enough space used for installing, " # "please resize partition size in ks file") download_count = total_count - cached_count msger.info("Packages: %d Total, %d Cached, %d Missed" \ % (total_count, cached_count, download_count)) try: if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) except CreatorError, e: raise CreatorError("Package download failed: %s" %(e,))
def runInstall(self, checksize=0): os.environ["HOME"] = "/" self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall dlpkgs = [] for item in installed_pkgs: if not zypp.isKindPattern(item) and \ not self.inDeselectPackages(item): dlpkgs.append(item) # record all pkg and the content localpkgs = self.localpkgs.keys() for pkg in dlpkgs: license = '' if pkg.name() in localpkgs: hdr = rpmmisc.readRpmHeader(self.ts, self.localpkgs[pkg.name()]) pkg_long_name = misc.RPM_FMT % { 'name': hdr['name'], 'arch': hdr['arch'], 'ver_rel': '%s-%s' % (hdr['version'], hdr['release']), } license = hdr['license'] else: pkg_long_name = misc.RPM_FMT % { 'name': pkg.name(), 'arch': pkg.arch(), 'ver_rel': pkg.edition(), } package = zypp.asKindPackage(pkg) license = package.license() self.__pkgs_content[pkg_long_name] = {} #TBD: to get file list if license in self.__pkgs_license.keys(): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 download_total_size = sum(map(lambda x: int(x.downloadSize()), dlpkgs)) localpkgs = self.localpkgs.keys() msger.info("Checking packages cache and packages integrity ...") for po in dlpkgs: # Check if it is cached locally if po.name() in localpkgs: cached_count += 1 else: local = self.getLocalPkgPath(po) if os.path.exists(local): if self.checkPkg(local) != 0: os.unlink(local) else: download_total_size -= int(po.downloadSize()) 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 install_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) # check needed size before actually download and install if checksize and install_total_size > checksize: raise CreatorError("No enough space used for installing, " "please resize partition size in ks file") download_count = total_count - cached_count msger.info("%d packages to be installed, " "%d packages gotten from cache, " "%d packages to be downloaded" \ % (total_count, cached_count, download_count)) try: if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) self.installPkgs(dlpkgs) except RepoError, e: raise CreatorError("Unable to download from repo : %s" % (e, ))
def runInstall(self, checksize = 0): os.environ["HOME"] = "/" self.buildTransaction() todo = zypp.GetResolvablesToInsDel(self.Z.pool()) installed_pkgs = todo._toInstall dlpkgs = [] for item in installed_pkgs: if not zypp.isKindPattern(item) and not self.inDeselectPackages(item): dlpkgs.append(item) # record the total size of installed pkgs pkgs_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) # check needed size before actually download and install if checksize and pkgs_total_size > checksize: raise CreatorError("Size of specified root partition in kickstart file is too small to install all selected packages.") # record all pkg and the content localpkgs = self.localpkgs.keys() for pkg in dlpkgs: license = '' if pkg.name() in localpkgs: hdr = rpmmisc.readRpmHeader(self.ts, self.localpkgs[pkg.name()]) pkg_long_name = "%s-%s-%s.%s.rpm" % (hdr['name'], hdr['version'], hdr['release'], hdr['arch']) license = hdr['license'] else: pkg_long_name = "%s-%s.%s.rpm" % (pkg.name(), pkg.edition(), pkg.arch()) package = zypp.asKindPackage(pkg) license = package.license() self.__pkgs_content[pkg_long_name] = {} #TBD: to get file list if license in self.__pkgs_license.keys(): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 localpkgs = self.localpkgs.keys() msger.info("Checking packages cache and packages integrity ...") for po in dlpkgs: """ Check if it is cached locally """ if po.name() in localpkgs: cached_count += 1 else: local = self.getLocalPkgPath(po) if os.path.exists(local): if self.checkPkg(local) != 0: os.unlink(local) else: cached_count += 1 download_count = total_count - cached_count msger.info("%d packages to be installed, %d packages gotten from cache, %d packages to be downloaded" % (total_count, cached_count, download_count)) try: if download_count > 0: msger.info("Downloading packages ...") self.downloadPkgs(dlpkgs, download_count) self.installPkgs(dlpkgs) except RepoError, e: raise CreatorError("Unable to download from repo : %s" % (e,))