def readPackages(self, packagetype="iso", release="", releasePrefix="", releaseType="beta"): packagesXML = getPackagesXML(self.packageGroups) packageData = PackageData(packagesXML.fullInstallDepot) for basename, requirement in packagesXML.rpmBasenames: #TODO: know which sep to use here, os.path.sep or '/' pkgPath = "%s/%s" % (packagesXML.fullInstallDepot, basename) log.debug('Creating Package object for %s' % pkgPath) if isURL(pkgPath) and '*' in basename: log.error('WILDCARDS CANNOT BE USED WITH REMOTE MEDIA. FIXME') continue elif not isURL(pkgPath) and not os.path.exists(pkgPath): # TODO: this glob stuff should die because wildcards make # things unpredictable and make it so there are # different rules for local vs. remote packages.xml # files. matches = glob.glob(pkgPath) if not matches: log.debug("Couldn't find %s" % pkgPath) continue if len(matches) > 1: log.debug("More than one package matches %s using %s" % (pkgPath, matches[-1])) pkgPath = matches[-1] try: (pkgName, pkgSize, hdrStart, hdrEnd) = \ packageData.headerDict[basename] package = Package(pkgPath, requirement, hdrStart, hdrEnd, pkgSize, pkgName) self.packages.append(package) except KeyError: msg = ('Encountered an error while creating the packages list.' ' Metadata for a package (%s) listed in the packages.xml file' ' was not found in the packageData.pkl database in your RPM' ' repository. Re-run createinstdepot.py and try' ' again' % (basename) ) log.error(msg) raise Exception(msg) # include any supplementary packages for pkg in userchoices.getPackageObjectsToInstall(): self.packages.append(pkg)
def readPackages(self, packagetype="iso", release="", releasePrefix="", releaseType="beta"): packagesXML = getPackagesXML(self.packageGroups) packageData = PackageData(packagesXML.fullInstallDepot) for basename, requirement in packagesXML.rpmBasenames: #TODO: know which sep to use here, os.path.sep or '/' pkgPath = "%s/%s" % (packagesXML.fullInstallDepot, basename) log.debug('Creating Package object for %s' % pkgPath) if isURL(pkgPath) and '*' in basename: log.error('WILDCARDS CANNOT BE USED WITH REMOTE MEDIA. FIXME') continue elif not isURL(pkgPath) and not os.path.exists(pkgPath): # TODO: this glob stuff should die because wildcards make # things unpredictable and make it so there are # different rules for local vs. remote packages.xml # files. matches = glob.glob(pkgPath) if not matches: log.debug("Couldn't find %s" % pkgPath) continue if len(matches) > 1: log.debug("More than one package matches %s using %s" % (pkgPath, matches[-1])) pkgPath = matches[-1] try: (pkgName, pkgSize, hdrStart, hdrEnd) = \ packageData.headerDict[basename] package = Package(pkgPath, requirement, hdrStart, hdrEnd, pkgSize, pkgName) self.packages.append(package) except KeyError: msg = ( 'Encountered an error while creating the packages list.' ' Metadata for a package (%s) listed in the packages.xml file' ' was not found in the packageData.pkl database in your RPM' ' repository. Re-run createinstdepot.py and try' ' again' % (basename)) log.error(msg) raise Exception(msg) # include any supplementary packages for pkg in userchoices.getPackageObjectsToInstall(): self.packages.append(pkg)
def _ksFileOption(match): '''Handle the "ks=http://<urn>", "ks=file://<path>", etc option.''' filePath = match.group(1) if remote_files.isURL(filePath) and not filePath.startswith('file'): networkChoiceMaker = getNetworkChoiceMaker() networkChoiceMaker.needed = True return [('-s', filePath)]
def __init__(self, fileName): self.fileName = fileName if remote_files.isURL(self.fileName): fp = remote_files.remoteOpen(self.fileName) self.lines = fp.readlines() else: self.lines = open(fileName).readlines() self.lines = [line.replace('\r\n', '\n') for line in self.lines] self.index = -1 self.keyWords = '^(%post|%pre|%packages|%vmlicense_text)'
def __init__(self, supportedPackageGroups, fullPath="packages.xml", mediaRoot="."): '''Warning: the constructor can potentially raise remote_files exceptions. ''' log.debug("Reading packages.xml...") getTagText = XMLGetTextInUniqueElement # handy alias if isURL(fullPath): # this can potentially raise HTTPError or URLError log.debug('Downloading the packages.xml file') fullPath = downloadLocally(fullPath, integrityChecker=self.parse) doc = self.parse(fullPath, shouldRaise=True) products = doc.getElementsByTagName("product") if len(products) != 1: log.warn('Expected to find only one <product> in packages.xml') product = products[0] self.name = getTagText(product, 'name') self.esxVersion = getTagText(product, 'esx_version') self.esxThirdPartyVersion = getTagText(product, 'esx_tp_version') self.esxThirdPartyCompatVersion = getTagText(product, 'esx_tp_compat_version') self.release = '%s.%s' % (getTagText(product, 'esx_release'), getTagText(product, 'release')) # bootloader.py needs these two self.kernLabel = getTagText(product, "kernel_name") self.kernVersion = getTagText(product, "kernel_version") self.installDepot = getTagText(product, 'install_depot') if isURL(mediaRoot): self.fullInstallDepot = urljoin(mediaRoot, self.installDepot) else: self.fullInstallDepot = os.path.join(mediaRoot, self.installDepot) log.info("Full install depot is %s" % (self.fullInstallDepot)) self.rpmBasenames = [] for depot in doc.getElementsByTagName("depot"): element = depot.getAttribute("name") if supportedPackageGroups != None: #NOTE: [] != None if element not in supportedPackageGroups: log.debug("Skipping depot %s" % (element)) continue for rpmlist in depot.getElementsByTagName("rpmlist"): repo = rpmlist.getAttribute('repo') for node in rpmlist.getElementsByTagName("rpm"): archOpt = node.getAttribute("arch") #TODO: at some point 'both' should be 'i386,x86_64' and we # should split on ',' if archOpt == "both": archList = ['i386', 'x86_64'] else: archList = [getTagText(depot, 'arch')] reqOpt = node.getAttribute("requirement").lower() if reqOpt not in REQUIREMENT_OPTIONS: reqOpt = "required" package = node.getAttribute('package') changeset = node.getAttribute('changeset') for arch in archList: basename = XMLGetText(node) basename = basename.replace("${esx_version}", self.esxVersion) basename = basename.replace("${esx_tp_version}", self.esxThirdPartyVersion) basename = basename.replace("${esx_tp_compat_version}", self.esxThirdPartyCompatVersion) basename = basename.replace("${release}", self.release) basename = basename.replace("${driver_release}", self.release) basename = basename.replace("${arch}", arch) basename = basename.replace('${repo}', repo) basename = basename.replace('${package}', package) basename = basename.replace('${changeset}', changeset) self.rpmBasenames.append((basename, reqOpt))
def __init__(self, supportedPackageGroups, fullPath="packages.xml", mediaRoot="."): '''Warning: the constructor can potentially raise remote_files exceptions. ''' log.debug("Reading packages.xml...") getTagText = XMLGetTextInUniqueElement # handy alias if isURL(fullPath): # this can potentially raise HTTPError or URLError log.debug('Downloading the packages.xml file') fullPath = downloadLocally(fullPath, integrityChecker=self.parse) doc = self.parse(fullPath, shouldRaise=True) products = doc.getElementsByTagName("product") if len(products) != 1: log.warn('Expected to find only one <product> in packages.xml') product = products[0] self.name = getTagText(product, 'name') self.esxVersion = getTagText(product, 'esx_version') self.esxThirdPartyVersion = getTagText(product, 'esx_tp_version') self.esxThirdPartyCompatVersion = getTagText(product, 'esx_tp_compat_version') self.release = '%s.%s' % (getTagText( product, 'esx_release'), getTagText(product, 'release')) # bootloader.py needs these two self.kernLabel = getTagText(product, "kernel_name") self.kernVersion = getTagText(product, "kernel_version") self.installDepot = getTagText(product, 'install_depot') if isURL(mediaRoot): self.fullInstallDepot = urljoin(mediaRoot, self.installDepot) else: self.fullInstallDepot = os.path.join(mediaRoot, self.installDepot) log.info("Full install depot is %s" % (self.fullInstallDepot)) self.rpmBasenames = [] for depot in doc.getElementsByTagName("depot"): element = depot.getAttribute("name") if supportedPackageGroups != None: #NOTE: [] != None if element not in supportedPackageGroups: log.debug("Skipping depot %s" % (element)) continue for rpmlist in depot.getElementsByTagName("rpmlist"): repo = rpmlist.getAttribute('repo') for node in rpmlist.getElementsByTagName("rpm"): archOpt = node.getAttribute("arch") #TODO: at some point 'both' should be 'i386,x86_64' and we # should split on ',' if archOpt == "both": archList = ['i386', 'x86_64'] else: archList = [getTagText(depot, 'arch')] reqOpt = node.getAttribute("requirement").lower() if reqOpt not in REQUIREMENT_OPTIONS: reqOpt = "required" package = node.getAttribute('package') changeset = node.getAttribute('changeset') for arch in archList: basename = XMLGetText(node) basename = basename.replace("${esx_version}", self.esxVersion) basename = basename.replace("${esx_tp_version}", self.esxThirdPartyVersion) basename = basename.replace( "${esx_tp_compat_version}", self.esxThirdPartyCompatVersion) basename = basename.replace("${release}", self.release) basename = basename.replace("${driver_release}", self.release) basename = basename.replace("${arch}", arch) basename = basename.replace('${repo}', repo) basename = basename.replace('${package}', package) basename = basename.replace('${changeset}', changeset) self.rpmBasenames.append((basename, reqOpt))