def run(self, args): import stack (clean, prefix, treeinfo) = args name = None vers = None arch = None file = open(treeinfo, 'r') for line in file.readlines(): a = line.split('=') if len(a) != 2: continue key = a[0].strip() value = a[1].strip() if key == 'family': if value == 'Red Hat Enterprise Linux': name = 'RHEL' elif value == 'CentOS': name = 'CentOS' elif key == 'version': vers = value elif key == 'arch': arch = value file.close() if not name: name = "BaseOS" if not vers: vers = stack.version if not arch: arch = 'x86_64' OS = 'redhat' roll_dir = os.path.join(prefix, name, vers, OS, arch) destdir = roll_dir if stack.release == '7.x': liveosdir = os.path.join(roll_dir, 'LiveOS') if clean and os.path.exists(roll_dir): print('Cleaning %s version %s ' % (name, vers), end=' ') print('for %s from pallets directory' % arch) os.system('/bin/rm -rf %s' % roll_dir) os.makedirs(roll_dir) print('Copying "%s" (%s,%s) pallet ...' % (name, vers, arch)) if not os.path.exists(destdir): os.makedirs(destdir) cmd = 'rsync -a --exclude "TRANS.TBL" %s/ %s/' \ % (self.owner.mountPoint, destdir) subprocess.call(shlex.split(cmd)) return (name, vers, arch)
def check_impl(self): self.diskinfo = os.path.join(self.owner.mountPoint, '.disk/info') if os.path.exists(self.diskinfo): file = open(self.diskinfo, 'r') line = file.readlines() file.close() info = line[0].split() dashidx = info.index('-') rel = info[dashidx - 2].strip('"') self.name, self.vers, self.release = info[0], info[1], rel if not self.name: self.name = "Ubuntu-Server" if not self.vers: self.vers = stack.version if not self.arch: self.arch = 'x86_64' if not self.release: self.release = stack.release if self.name and self.vers: return True return False
def createSkeletonSiteAttrs(self): self.getSiteDotAttrs() if os.path.exists('/tmp/site.attrs'): return file = open('/tmp/site.attrs', 'w') # # set the language # cmdline = open('/proc/cmdline', 'r') args = string.split(cmdline.readline()) cmdline.close() # # the default language # lang = 'en_US' langsupport = 'en_US' for arg in args: if arg.count('lang='): a = string.split(arg, '=') if len(a) > 1 and a[1] == 'ko': lang = 'ko_KR' langsupport = string.join( ['ko_KR.UTF-8', 'ko_KR', 'ko', 'en_US.UTF-8', 'en_US']) file.write('Kickstart_Lang:%s\n' % lang) file.write('Kickstart_Langsupport:%s\n' % langsupport) file.close() return
def createPopt(self, dir=None): if dir == None: dir = self.rootdir if not os.path.exists(dir): os.system('mkdir -p %s' % (dir)) filename = os.path.join(dir, '.popt') if not os.path.exists(filename): file = open(filename, 'w') file.write("rpm alias --dbpath --define '_dbpath !#:+'") file.write("\n") file.close() return
def createPopt(self, dir=None): if dir is None: dir = self.rootdir if not os.path.exists(dir): os.system('mkdir -p %s' % (dir)) filename = os.path.join(dir, '.popt') if not os.path.exists(filename): file = open(filename, 'w') file.write("rpm alias --dbpath --define '_dbpath !#:+'") file.write("\n") file.close() return
def createSkeletonSiteAttrs(self): self.getSiteDotAttrs() if os.path.exists('/tmp/site.attrs'): return file = open('/tmp/site.attrs', 'w') # # set the language # cmdline = open('/proc/cmdline', 'r') args = string.split(cmdline.readline()) cmdline.close() # # the default language # lang = 'en_US' langsupport = 'en_US' for arg in args: if arg.count('lang='): a = string.split(arg, '=') if len(a) > 1 and a[1] == 'ko': lang = 'ko_KR' langsupport = string.join([ 'ko_KR.UTF-8', 'ko_KR', 'ko', 'en_US.UTF-8', 'en_US' ]) file.write('Kickstart_Lang:%s\n' % lang) file.write('Kickstart_Langsupport:%s\n' % langsupport) file.close() return
def getCDInfo(self): self.mountCD() timestamp = None name = None archinfo = None diskid = None vers = None release = None if os.path.exists('/mnt/cdrom/.treeinfo'): file = open('/mnt/cdrom/.treeinfo', 'r') for line in file.readlines(): a = line.split('=') if len(a) != 2: continue key = a[0].strip() value = a[1].strip() if key == 'family': if value == 'Red Hat Enterprise Linux': name = 'RHEL' elif value == 'CentOS': name = 'CentOS' elif value == 'Oracle Linux Server': name = 'Oracle' elif key == 'version': vers = value elif key == 'arch': archinfo = value elif key == 'discnum': diskid = value file.close() try: file = open('/mnt/cdrom/.discinfo', 'r') t = file.readline() n = file.readline() a = file.readline() d = file.readline() file.close() timestamp = t[:-1] if not name: name = n[:-1].replace(' ', '_') if not archinfo: archinfo = a[:-1] # # always get the disk id # if there are multiple disks, this will be 1, 2, etc. # # the diskid from .treeinfo appears to be hardcoded to # 1 (at least for CentOS media). # diskid = d[:-1] except: pass if not name: name = "BaseOS" if not archinfo: archinfo = 'x86_64' return (timestamp, name, archinfo, diskid, vers)
packages = { } found = False for filename in manifests: print('reading %s' % filename) found = True file = open(filename, 'r') for line in file.readlines(): l = line.strip() if len(l) == 0 or (len(l) > 0 and l[0] == '#'): continue if l[0] == '-': # use '-package' to turn off the check packages[l[1:]] = False elif l not in packages: packages[l] = True file.close() manifest = [ ] for pkg in packages: if packages[pkg]: manifest.append(pkg) if not found: print('Cannot find any manifest files') sys.exit(0) built = [] notmanifest = [] for rpm in builtfiles: try:
def getExternalRPMS(self): import stack.roll import stack.redhat.gen attrs = {} for row in self.call('list.host.attr', ['localhost']): attrs[row['attr']] = row['value'] xml = self.command('list.node.xml', ['everything', 'eval=n', 'attrs=%s' % attrs]) # # make sure the XML string is ASCII and not unicode, # otherwise, the parser will fail # xmlinput = xml.encode('ascii', 'ignore') generator = stack.redhat.gen.Generator() generator.setProfileType('native') generator.setArch(self.arch) generator.setOS('redhat') generator.parse(xmlinput) # call the getPackages, for just enabled packages and flatten it rpms = [ pkg for node_pkgs in generator.packageSet.getPackages() ['enabled'].values() for pkg in node_pkgs ] # create a yum.conf file that contains only repos from the # default-all box # cwd = os.getcwd() yumconf = os.path.join(cwd, 'yum.conf') file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=os-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-all' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write( 'baseurl=file:///export/stack/pallets/%s/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['release'], o['arch'])) file.close() # Use system python (2.x) cmd = ['/usr/bin/python', '/opt/stack/sbin/yumresolver', yumconf] cmd.extend(rpms) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stdrr = proc.communicate() try: selected = json.loads(stdout) except ValueError: raise CommandError(self, 'Unable to parse yum dependency resolution') # # copy all the selected files into the pallet but before we # do that, rewrite the yum.conf file to include only the # 'default-os' box which will ensure that we only put # os-related packages in the os pallet (otherwise, packages # from the 'stacki' pallet would leak into the os pallet # file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=os-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-os' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write( 'baseurl=file:///export/stack/pallets/%s/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['release'], o['arch'])) file.close() destdir = os.path.join(cwd, 'RPMS') cmd = ['yumdownloader', '--destdir=%s' % destdir, '-y', '-c', yumconf] cmd.extend(selected) subprocess.call(cmd, stdin=None) stacki = [] nonstacki = [] tree = stack.file.Tree(destdir) for rpm in tree.getFiles(): if rpm.getBaseName() in selected: stacki.append(rpm) else: nonstacki.append(rpm) return (stacki, nonstacki)
def getExternalRPMS(self): import stack.roll import stack.redhat.gen xml = self.command('list.node.xml', ['everything', 'eval=n']) # # make sure the XML string is ASCII and not unicode, # otherwise, the parser will fail # xmlinput = xml.encode('ascii', 'ignore') generator = stack.redhat.gen.Generator() generator.setArch(self.arch) generator.setOS('redhat') generator.parse(xmlinput) rpms = [] for line in generator.generate('packages'): if len(line) and line[0] not in ['#', '%']: rpms.append(line) # # use yum to resolve dependencies # if stack.release == '7.x': pythonver = '2.7' else: pythonver = '2.6' sys.path.append('/usr/lib/python%s/site-packages' % pythonver) sys.path.append('/usr/lib64/python%s/site-packages' % pythonver) sys.path.append('/usr/lib/python%s/lib-dynload' % pythonver) sys.path.append('/usr/lib64/python%s/lib-dynload' % pythonver) import yum # # create a yum.conf file that contains only repos from the # default-all box # cwd = os.getcwd() yumconf = os.path.join(cwd, 'yum.conf') file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=redhat-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-all' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write( 'baseurl=file:///export/stack/pallets/%s/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['release'], o['arch'])) file.close() a = yum.YumBase() a.doConfigSetup(fn='%s' % yumconf, init_plugins=False) a.conf.cache = 0 a.doTsSetup() a.doRepoSetup() a.doRpmDBSetup() a.doSackSetup() a.doGroupSetup() selected = [] for rpm in rpms + ['@base', '@core']: if rpm[0] == '@': group = a.comps.return_group(rpm[1:].encode('utf-8')) for r in group.mandatory_packages.keys() + \ group.default_packages.keys(): if r not in selected: selected.append(r) elif rpm not in selected: selected.append(rpm) pkgs = [] avail = a.pkgSack.returnNewestByNameArch() for p in avail: if p.name in selected: pkgs.append(p) done = 0 while not done: done = 1 results = a.findDeps(pkgs) for pkg in results.keys(): for req in results[pkg].keys(): reqlist = results[pkg][req] for r in reqlist: if r.name not in selected: selected.append(r.name) pkgs.append(r) done = 0 # # copy all the selected files into the pallet but before we # do that, rewrite the yum.conf file to include only the # 'default-os' box which will ensure that we only put # os-related packages in the os pallet (otherwise, packages # from the 'stacki' pallet would leak into the os pallet # file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=redhat-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-os' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write( 'baseurl=file:///export/stack/pallets/%s/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['release'], o['arch'])) file.close() destdir = os.path.join(cwd, 'RPMS') for s in selected: subprocess.call( ['yumdownloader', '--destdir=%s' % destdir, '-c', yumconf, s], stdin=None, stdout=None, stderr=None) stacki = [] nonstacki = [] tree = stack.file.Tree(destdir) for rpm in tree.getFiles(): if rpm.getBaseName() in selected: stacki.append(rpm) else: nonstacki.append(rpm) return (stacki, nonstacki)
def run(self, args): import stack (clean, prefix) = args name = None vers = None arch = None release = None file = open(self.treeinfo, 'r') for line in file.readlines(): a = line.split('=') if len(a) != 2: continue key = a[0].strip() value = a[1].strip() if key == 'family': if value == 'Red Hat Enterprise Linux': name = 'RHEL' elif value.startswith('CentOS'): name = 'CentOS' elif value.startswith('Oracle'): name = 'OLE' elif value.startswith('Scientific'): name = 'SL' elif key == 'version': vers = value elif key == 'arch': arch = value file.close() if not name: name = "BaseOS" if not vers: vers = stack.version if not arch: arch = 'x86_64' if not release: release = stack.release OS = 'redhat' roll_dir = os.path.join(prefix, name, vers, release, OS, arch) destdir = roll_dir if clean and os.path.exists(roll_dir): self.owner.out.write('Cleaning %s %s-%s\n' % (name, vers, release)) self.owner.out.write('for %s from pallets directory\n' % self.arch) if not self.owner.dryrun: os.system('/bin/rm -rf %s' % roll_dir) os.makedirs(roll_dir) self.owner.out.write('Copying %s %s-%s pallet ...\n' % (name, vers, release)) if not self.owner.dryrun: if not os.path.exists(destdir): os.makedirs(destdir) cmd = 'rsync -a --exclude "TRANS.TBL" %s/ %s/' \ % (self.owner.mountPoint, destdir) subprocess.call(shlex.split(cmd)) # # create roll-<name>.xml file # xmlfile = open('%s/roll-%s.xml' % (roll_dir, name), 'w') xmlfile.write('<roll name="%s" interface="6.0.2">\n' % name) xmlfile.write('<color edge="white" node="white"/>\n') xmlfile.write('<info version="%s" release="%s" arch="%s" os="%s"/>\n' % (vers, release, arch, OS)) xmlfile.write('<iso maxsize="0" addcomps="0" bootable="0"/>\n') xmlfile.write('<rpm rolls="0" bin="1" src="0"/>\n') xmlfile.write('</roll>\n') xmlfile.close() return (name, vers, release, arch, OS, roll_dir)
def getExternalRPMS(self): import stack.roll import stack.gen xml = self.command('list.node.xml', [ 'everything', 'eval=n' ] ) # # make sure the XML string is ASCII and not unicode, # otherwise, the parser will fail # xmlinput = xml.encode('ascii', 'ignore') generator = stack.gen.Generator_redhat() generator.setArch(self.arch) generator.setOS('redhat') generator.parse(xmlinput) rpms = [] for line in generator.generate('packages'): if len(line) and line[0] not in [ '#', '%' ]: rpms.append(line) # # use yum to resolve dependencies # if stack.release == '7.x': pythonver = '2.7' else: pythonver = '2.6' sys.path.append('/usr/lib/python%s/site-packages' % pythonver) sys.path.append('/usr/lib64/python%s/site-packages' % pythonver) sys.path.append('/usr/lib/python%s/lib-dynload' % pythonver) sys.path.append('/usr/lib64/python%s/lib-dynload' % pythonver) import yum # # create a yum.conf file that contains only repos from the # default-all box # cwd = os.getcwd() yumconf = os.path.join(cwd, 'yum.conf') file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=redhat-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-all' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write('baseurl=file:///export/stack/pallets/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['arch'])) file.close() a = yum.YumBase() a.doConfigSetup(fn='%s' % yumconf, init_plugins=False) a.conf.cache = 0 a.doTsSetup() a.doRepoSetup() a.doRpmDBSetup() a.doSackSetup() a.doGroupSetup() selected = [] for rpm in rpms + [ '@base', '@core' ]: if rpm[0] == '@': group = a.comps.return_group( rpm[1:].encode('utf-8')) for r in group.mandatory_packages.keys() + \ group.default_packages.keys(): if r not in selected: selected.append(r) elif rpm not in selected: selected.append(rpm) pkgs = [] avail = a.pkgSack.returnNewestByNameArch() for p in avail: if p.name in selected: pkgs.append(p) done = 0 while not done: done = 1 results = a.findDeps(pkgs) for pkg in results.keys(): for req in results[pkg].keys(): reqlist = results[pkg][req] for r in reqlist: if r.name not in selected: selected.append(r.name) pkgs.append(r) done = 0 # # copy all the selected files into the pallet but before we # do that, rewrite the yum.conf file to include only the # 'default-os' box which will ensure that we only put # os-related packages in the os pallet (otherwise, packages # from the 'stacki' pallet would leak into the os pallet # file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=redhat-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-os' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write('baseurl=file:///export/stack/pallets/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['arch'])) file.close() destdir = os.path.join(cwd, 'RPMS') for s in selected: subprocess.call([ 'yumdownloader', '--destdir=%s' % destdir, '-c', yumconf, s ], stdin = None, stdout = None, stderr = None) stacki = [] nonstacki = [] tree = stack.file.Tree(destdir) for rpm in tree.getFiles(): if rpm.getBaseName() in selected: stacki.append(rpm) else: nonstacki.append(rpm) return (stacki, nonstacki)
def getExternalRPMS(self): import stack.roll import stack.redhat.gen attrs = {} for row in self.call('list.host.attr', [ 'localhost' ]): attrs[row['attr']] = row['value'] xml = self.command('list.node.xml', [ 'everything', 'eval=n', 'attrs=%s' % attrs ] ) # # make sure the XML string is ASCII and not unicode, # otherwise, the parser will fail # xmlinput = xml.encode('ascii', 'ignore') generator = stack.redhat.gen.Generator() generator.setProfileType('native') generator.setArch(self.arch) generator.setOS('redhat') generator.parse(xmlinput) # call the getPackages, for just enabled packages and flatten it rpms = [pkg for node_pkgs in generator.packageSet.getPackages()['enabled'].values() for pkg in node_pkgs] # create a yum.conf file that contains only repos from the # default-all box # cwd = os.getcwd() yumconf = os.path.join(cwd, 'yum.conf') file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=os-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-all' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write('baseurl=file:///export/stack/pallets/%s/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['release'], o['arch'])) file.close() # Use system python (2.x) cmd = ['/usr/bin/python', '/opt/stack/sbin/yumresolver', yumconf] cmd.extend(rpms) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stdrr = proc.communicate() try: selected = json.loads(stdout) except ValueError: raise CommandError(self, 'Unable to parse yum dependency resolution') # # copy all the selected files into the pallet but before we # do that, rewrite the yum.conf file to include only the # 'default-os' box which will ensure that we only put # os-related packages in the os pallet (otherwise, packages # from the 'stacki' pallet would leak into the os pallet # file = open(yumconf, 'w') file.write('[main]\n') file.write('cachedir=%s/cache\n' % cwd) file.write('keepcache=0\n') file.write('debuglevel=2\n') file.write('logfile=%s/yum.log\n' % cwd) file.write('pkgpolicy=newest\n') file.write('distroverpkg=os-release\n') file.write('tolerant=1\n') file.write('exactarch=1\n') file.write('obsoletes=1\n') file.write('gpgcheck=0\n') file.write('plugins=0\n') file.write('metadata_expire=1800\n') file.write('reposdir=%s\n' % cwd) for o in self.call('list.pallet', []): boxes = o['boxes'].split() if 'default-os' in boxes: file.write('[%s]\n' % o['name']) file.write('name=%s\n' % o['name']) file.write('baseurl=file:///export/stack/pallets/%s/%s/%s/redhat/%s\n' % (o['name'], o['version'], o['release'], o['arch'])) file.close() destdir = os.path.join(cwd, 'RPMS') cmd = [ 'yumdownloader', '--destdir=%s' % destdir, '-y', '-c', yumconf ] cmd.extend(selected) subprocess.call(cmd, stdin=None) stacki = [] nonstacki = [] tree = stack.file.Tree(destdir) for rpm in tree.getFiles(): if rpm.getBaseName() in selected: stacki.append(rpm) else: nonstacki.append(rpm) return (stacki, nonstacki)
def run(self, args): import stack (clean, prefix, treeinfo) = args name = None vers = None arch = None file = open(treeinfo, 'r') for line in file.readlines(): a = line.split('=') if len(a) != 2: continue key = a[0].strip() value = a[1].strip() if key == 'family': if value == 'Red Hat Enterprise Linux': name = 'RHEL' elif value == 'CentOS': name = 'CentOS' elif value == 'Oracle Linux Server': name = 'Oracle' elif key == 'version': vers = value elif key == 'arch': arch = value file.close() if not name: name = "BaseOS" if not vers: vers = stack.version if not arch: arch = 'x86_64' OS = 'redhat' roll_dir = os.path.join(prefix, name, vers, OS, arch) destdir = roll_dir if stack.release == '7.x': liveosdir = os.path.join(roll_dir, 'LiveOS') if clean and os.path.exists(roll_dir): print('Cleaning %s version %s ' % (name, vers), end=' ') print('for %s from pallets directory' % arch) os.system('/bin/rm -rf %s' % roll_dir) os.makedirs(roll_dir) print('Copying "%s" (%s,%s) pallet ...' % (name, vers, arch)) if not os.path.exists(destdir): os.makedirs(destdir) cmd = 'rsync -a --exclude "TRANS.TBL" %s/ %s/' \ % (self.owner.mountPoint, destdir) subprocess.call(shlex.split(cmd)) # # create roll-<name>.xml file # xmlfile = open('%s/roll-%s.xml' % (roll_dir, name), 'w') xmlfile.write('<roll name="%s" interface="6.0.2">\n' % name) xmlfile.write('<color edge="white" node="white"/>\n') xmlfile.write('<info version="%s" release="%s" arch="%s" os="%s"/>\n' % (vers, stack.release, arch, OS)) xmlfile.write('<iso maxsize="0" addcomps="0" bootable="0"/>\n') xmlfile.write('<rpm rolls="0" bin="1" src="0"/>\n') xmlfile.write('</roll>\n') xmlfile.close() return (name, vers, arch)
builtfiles += tree.getFiles(os.path.join(buildpath, 'RPMS', arch)) manifest = [] found = False for filename in [ 'manifest', 'manifest.%s' % rollname ]: if not os.path.exists(filename): continue found = True file = open(filename, 'r') for line in file.readlines(): l = line.strip() if len(l) == 0 or (len(l) > 0 and l[0] == '#'): continue manifest.append(l) file.close() if not found: print('error - cannot manifest') sys.exit(0) built = [] notmanifest = [] for rpm in builtfiles: try: pkg = rpm.getPackageName() if pkg in manifest: if pkg not in built: # # this check will catch duplicate package
def run(self, args): (clean, prefix, treeinfo) = args name = None vers = None arch = None file = open(treeinfo, 'r') for line in file.readlines(): a = line.split('=') if len(a) != 2: continue key = a[0].strip() value = a[1].strip() if key == 'family': if value == 'Red Hat Enterprise Linux': name = 'RHEL' elif value == 'CentOS': name = 'CentOS' elif key == 'version': vers = value elif key == 'arch': arch = value file.close() if not name: name = "BaseOS" if not vers: vers = stack.version if not arch: arch = 'x86_64' OS = 'redhat' roll_dir = os.path.join(prefix, name, vers, OS, arch) destdir = os.path.join(roll_dir, 'RPMS') if clean and os.path.exists(roll_dir): print 'Cleaning %s version %s ' % (name, vers), print 'for %s from pallets directory' % arch os.system('/bin/rm -rf %s' % roll_dir) os.makedirs(roll_dir) print 'Copying "%s" (%s,%s) pallet ...' % (name, vers, arch) if not os.path.exists(destdir): os.makedirs(destdir) cdtree = stack.file.Tree(self.owner.mountPoint) for dir in cdtree.getDirs(): for file in cdtree.getFiles(dir): if not file.getName().endswith('.rpm'): continue if file.getPackageArch() != 'src' and \ file.getBaseName() != 'comps' and \ file.getName() != 'comps.rpm' \ and not (arch == 'i386' and \ re.match('^kudzu.*', file.getBaseName())): os.system('cp -p %s %s' % ( file.getFullName(), destdir)) # # lay down a minimal roll XML config file # f = open('%s' % os.path.join(roll_dir, 'roll-%s.xml' % name), 'w') f.write('<roll name="%s" interface="6.0.2">\n' % name) f.write('<info version="%s" release="%s" arch="%s" os="%s"/>\n' % (vers, stack.release, arch, OS)) f.write('<iso maxsize="0" bootable="0"/>\n') f.write('</roll>\n') f.close() return (name, vers, arch)
def run(self, args): import stack (clean, prefix, treeinfo) = args name = None vers = None arch = None file = open(treeinfo, 'r') for line in file.readlines(): a = line.split('=') if len(a) != 2: continue key = a[0].strip() value = a[1].strip() if key == 'family': if value == 'Red Hat Enterprise Linux': name = 'RHEL' elif value == 'CentOS': name = 'CentOS' elif key == 'version': vers = value elif key == 'arch': arch = value file.close() if not name: name = "BaseOS" if not vers: vers = stack.version if not arch: arch = 'x86_64' OS = 'redhat' roll_dir = os.path.join(prefix, name, vers, OS, arch) destdir = os.path.join(roll_dir, 'RPMS') print 'stack.release (%s)' % stack.release if stack.release == '7.x': liveosdir = os.path.join(roll_dir, 'LiveOS') if clean and os.path.exists(roll_dir): print 'Cleaning %s version %s ' % (name, vers), print 'for %s from pallets directory' % arch os.system('/bin/rm -rf %s' % roll_dir) os.makedirs(roll_dir) print 'Copying "%s" (%s,%s) pallet ...' % (name, vers, arch) if not os.path.exists(destdir): os.makedirs(destdir) if stack.release == '7.x' and not os.path.exists(liveosdir): os.makedirs(liveosdir) cdtree = stack.file.Tree(self.owner.mountPoint) for dir in cdtree.getDirs(): for file in cdtree.getFiles(dir): if stack.release == '7.x' and dir == 'LiveOS' \ and file.getName().endswith('.img'): os.system('cp -p %s %s' % ( file.getFullName(), liveosdir)) else: if not file.getName().endswith('.rpm'): continue if file.getPackageArch() != 'src' and \ file.getBaseName() != 'comps' and \ file.getName() != 'comps.rpm' \ and not (arch == 'i386' and \ re.match('^kudzu.*', file.getBaseName())): os.system('cp -p %s %s' % ( file.getFullName(), destdir)) # # lay down a minimal roll XML config file # f = open('%s' % os.path.join(roll_dir, 'roll-%s.xml' % name), 'w') f.write('<roll name="%s" interface="6.0.2">\n' % name) f.write('<info version="%s" release="%s" arch="%s" os="%s"/>\n' % (vers, stack.release, arch, OS)) f.write('<iso maxsize="0" bootable="0"/>\n') f.write('</roll>\n') f.close() return (name, vers, arch)