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 run(self, params, args): path = os.path.dirname(__file__) copyright = {} copyright['stacki-long'] = os.path.join(path, 'copyright-stacki') copyright['stacki-short'] = os.path.join(path, 'copyright-stacki-short') copyright['rocks-long'] = os.path.join(path, 'copyright-rocks') copyright['rocks-short'] = os.path.join(path, 'copyright-rocks-short') for (k, v) in copyright.items(): file = open(v, 'r') copyright[k] = [] for line in file.readlines(): copyright[k].append(line[:-1]) # We breakup the string below to protect this code segment # for insert-copyright detecting the tags. Otherwise we # could not run on ourselves. self.tree = stack.file.Tree('../../..') print('Inserting stacki copyright into source code files...') self.pattern = ['@' + 'SI_Copyright@', '@' + 'SI_Copyright@'] self.copyright = copyright['stacki-long'] self.tree.apply(self.iter) print('Inserting stacki copyright into XML files...') self.pattern = ['<' + 'si_copyright>', '<' + '/si_copyright>'] self.copyright = copyright['stacki-short'] self.tree.apply(self.iter)
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 run(self, params, args): path = os.path.dirname(__file__) copyright = {} copyright['stacki-long'] = os.path.join(path, 'copyright-stacki') copyright['stacki-short'] = os.path.join(path, 'copyright-stacki-short') copyright['rocks-long'] = os.path.join(path, 'copyright-rocks') copyright['rocks-short'] = os.path.join(path, 'copyright-rocks-short') for (k,v) in copyright.items(): file = open(v, 'r') copyright[k] = [] for line in file.readlines(): copyright[k].append(line[:-1]) # We breakup the string below to protect this code segment # for insert-copyright detecting the tags. Otherwise we # could not run on ourselves. self.tree = stack.file.Tree('../../..') print('Inserting stacki copyright into source code files...') self.pattern = [ '@' + 'SI_Copyright@', '@' + 'SI_Copyright@' ] self.copyright = copyright['stacki-long'] self.tree.apply(self.iter) print('Inserting stacki copyright into XML files...') self.pattern = [ '<' + 'si_copyright>', '<' + '/si_copyright>' ] self.copyright = copyright['stacki-short'] self.tree.apply(self.iter)
def run(self, params, args): (clean, dir, updatedb) = self.fillParams([('clean', 'n'), ('dir', '/export/stack/pallets'), ('updatedb', 'y')]) clean = self.str2bool(clean) updatedb = self.str2bool(updatedb) self.mountPoint = '/mnt/cdrom' if not os.path.exists(self.mountPoint): os.makedirs(self.mountPoint) # Get a list of all the iso files mentioned in # the command line. Make sure we get the complete # path for each file. isolist = [] for arg in args: arg = os.path.join(os.getcwd(), arg) if os.path.exists(arg) and arg.endswith('.iso'): isolist.append(arg) else: print("Cannot find %s or %s "\ "is not and ISO image" % (arg, arg)) if isolist: # # before we mount the ISO, make sure there are no active # mounts on the mountpoint # file = open('/proc/mounts') for line in file.readlines(): l = line.split() if l[1].strip() == self.mountPoint: subprocess.call(['umount', self.mountPoint]) for iso in isolist: # have a set of iso files cwd = os.getcwd() self.runImplementation('mount_%s' % self.os, iso) self.copy(clean, dir, updatedb) os.chdir(cwd) self.runImplementation('umount_%s' % self.os) else: # # no files specified look for a cdrom # if self.runImplementation('mounted_%s' % self.os): self.copy(clean, dir, updatedb) else: raise CommandError(self, 'CDROM not mounted')
def run(self, params, args): path = os.path.dirname(__file__) copyright = {} copyright['stacki-long'] = os.path.join(path, 'copyright-stacki-short') copyright['stacki-short'] = os.path.join(path, 'copyright-stacki-short') copyright['rocks-long'] = os.path.join(path, 'copyright-rocks-short') copyright['rocks-short'] = os.path.join(path, 'copyright-rocks-short') for (k, v) in copyright.items(): file = open(v, 'r') copyright[k] = [] print(file) for line in file.readlines(): copyright[k].append(line[:-1]) # We breakup the string below to protect this code segment # for insert-copyright detecting the tags. Otherwise we # could not run on ourselves. self.tree = stack.file.Tree('../../../../..') print('Inserting stacki copyright into source code files...') self.pattern = ['@' + 'copyright@', '@' + 'copyright@'] self.copyright = copyright['stacki-long'] self.tree.apply(self.iter) print('Inserting stacki copyright into XML files...') self.pattern = ['<' + 'copyright>', '<' + '/copyright>'] self.copyright = copyright['stacki-short'] self.tree.apply(self.iter) self.pattern = ['<' + 'stack:copyright>', '<' + '/stack:copyright>'] self.tree.apply(self.iter) # No reason to keep updating the Rocks stuff, we forked years # ago and never looked back. # # Keep the code here if for when/if the trees ever come back # together. print('Inserting rocks copyright into source code files...') self.pattern = ['@' + 'rocks@', '@' + 'rocks@'] self.copyright = copyright['rocks-long'] self.tree.apply(self.iter) print('Inserting rocks copyright into XML files...') self.pattern = ['<' + 'rocks>', '<' + '/rocks>'] self.copyright = copyright['rocks-short'] self.tree.apply(self.iter) self.pattern = ['<' + 'stack:rocks>', '<' + '/stack:rocks>'] self.tree.apply(self.iter)
def run(self, params, args): path = os.path.dirname(__file__) copyright = {} copyright['stacki-long'] = os.path.join(path, 'copyright-stacki-short') copyright['stacki-short'] = os.path.join(path, 'copyright-stacki-short') copyright['rocks-long'] = os.path.join(path, 'copyright-rocks-short') copyright['rocks-short'] = os.path.join(path, 'copyright-rocks-short') for (k, v) in copyright.items(): file = open(v, 'r') copyright[k] = [] print(file) for line in file.readlines(): copyright[k].append(line[:-1]) # We breakup the string below to protect this code segment # for insert-copyright detecting the tags. Otherwise we # could not run on ourselves. self.tree = stack.file.Tree('../../../../..') print('Inserting stacki copyright into source code files...') self.pattern = [ '@' + 'copyright@', '@' + 'copyright@' ] self.copyright = copyright['stacki-long'] self.tree.apply(self.iter) print('Inserting stacki copyright into XML files...') self.pattern = [ '<' + 'copyright>', '<' + '/copyright>' ] self.copyright = copyright['stacki-short'] self.tree.apply(self.iter) self.pattern = [ '<' + 'stack:copyright>', '<' + '/stack:copyright>' ] self.tree.apply(self.iter) # No reason to keep updating the Rocks stuff, we forked years # ago and never looked back. # # Keep the code here if for when/if the trees ever come back # together. print('Inserting rocks copyright into source code files...') self.pattern = [ '@' + 'rocks@', '@' + 'rocks@' ] self.copyright = copyright['rocks-long'] self.tree.apply(self.iter) print('Inserting rocks copyright into XML files...') self.pattern = [ '<' + 'rocks>', '<' + '/rocks>' ] self.copyright = copyright['rocks-short'] self.tree.apply(self.iter) self.pattern = [ '<' + 'stack:rocks>', '<' + '/stack:rocks>' ] self.tree.apply(self.iter)
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)
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)
def run(self, params, args): (clean, dir, updatedb, dryrun, username, password) = self.fillParams([ ('clean', 'n'), ('dir', '/export/stack/pallets'), ('updatedb', 'y'), ('dryrun', 'n'), ('username', None), ('password', None), ]) #Validate username and password #need to provide either both or none if username and not password: raise UsageError(self, 'must supply a password with the username') if password and not username: raise UsageError(self, 'must supply a username with the password') clean = self.str2bool(clean) updatedb = self.str2bool(updatedb) self.dryrun = self.str2bool(dryrun) if self.dryrun: updatedb = False self.out = sys.stderr else: self.out = sys.stdout self.mountPoint = '/mnt/cdrom' if not os.path.exists(self.mountPoint): os.makedirs(self.mountPoint) # Get a list of all the iso files mentioned in # the command line. Make sure we get the complete # path for each file. isolist = [] network_pallets = [] disk_pallets = [] network_isolist = [] for arg in args: if arg.startswith(('http', 'ftp')) and arg.endswith('.iso'): network_isolist.append(arg) continue elif arg.startswith(('http', 'ftp')): network_pallets.append(arg) continue arg = os.path.join(os.getcwd(), arg) if os.path.exists(arg) and arg.endswith('.iso'): isolist.append(arg) elif os.path.isdir(arg): disk_pallets.append(arg) else: msg = "Cannot find %s or %s is not an ISO image" raise CommandError(self, msg % (arg, arg)) if self.dryrun: self.beginOutput() if not isolist and not network_pallets and not disk_pallets and not network_isolist: # # no files specified look for a cdrom # rc = os.system('mount | grep %s' % self.mountPoint) if rc == 0: self.copy(clean, dir, updatedb, self.mountPoint) else: raise CommandError(self, 'no pallets provided and /mnt/cdrom is unmounted') for iso in network_isolist: #determine the name of the iso file and get the destined path filename = os.path.basename(urlparse(iso).path) local_path = '/'.join([os.getcwd(),filename]) try: # passing True will display a % progress indicator in stdout local_path = fetch(iso, username, password, True) except FetchError as e: raise CommandError(self, e) cwd = os.getcwd() os.system('mount -o loop %s %s > /dev/null 2>&1' % (local_path, self.mountPoint)) self.copy(clean, dir, updatedb, iso) os.chdir(cwd) os.system('umount %s > /dev/null 2>&1' % self.mountPoint) print('cleaning up temporary files ...') p = subprocess.run(['rm', filename]) if isolist: # # before we mount the ISO, make sure there are no active # mounts on the mountpoint # file = open('/proc/mounts') for line in file.readlines(): l = line.split() if l[1].strip() == self.mountPoint: cmd = 'umount %s' % self.mountPoint cmd += ' > /dev/null 2>&1' subprocess.run([ cmd ], shell=True) for iso in isolist: # have a set of iso files cwd = os.getcwd() os.system('mount -o loop %s %s > /dev/null 2>&1' % (iso, self.mountPoint)) self.copy(clean, dir, updatedb, iso) os.chdir(cwd) os.system('umount %s > /dev/null 2>&1' % self.mountPoint) if network_pallets: for pallet in network_pallets: self.runImplementation('network_pallet', (clean, dir, pallet, updatedb)) if disk_pallets: for pallet in disk_pallets: self.runImplementation('disk_pallet', (clean, dir, pallet, updatedb)) self.endOutput(header=['name', 'version', 'release', 'arch', 'os'], trimOwner=False) # Clear the old packages self.clean_ludicrous_packages()
dirname = os.path.join(path, 'manifest.d') if os.path.exists(dirname): for filename in os.listdir(dirname): name, ext = os.path.splitext(filename) if ext == '.manifest': manifests.append(os.path.join(dirname, filename)) elif release and ext == '.%s' % release: manifests.append(os.path.join(dirname, filename)) 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:
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)
tree = stack.file.Tree(os.getcwd()) builtfiles = [] for arch in [ 'noarch', 'i386', 'x86_64' ]: 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:
def run(self, params, args): (clean, dir, updatedb, dryrun, username, password) = self.fillParams([ ('clean', 'n'), ('dir', '/export/stack/pallets'), ('updatedb', 'y'), ('dryrun', 'n'), ('username', None), ('password', None), ]) #Validate username and password #need to provide either both or none if username and not password: raise UsageError(self, 'must supply a password with the username') if password and not username: raise UsageError(self, 'must supply a username with the password') clean = self.str2bool(clean) updatedb = self.str2bool(updatedb) self.dryrun = self.str2bool(dryrun) if self.dryrun: updatedb = False self.out = sys.stderr else: self.out = sys.stdout self.mountPoint = '/mnt/cdrom' tempMountPoint = tempfile.TemporaryDirectory() if not os.path.exists(self.mountPoint): try: os.makedirs(self.mountPoint) except OSError: self.mountPoint = tempMountPoint.name # Get a list of all the iso files mentioned in # the command line. Make sure we get the complete # path for each file. isolist = [] network_pallets = [] disk_pallets = [] network_isolist = [] for arg in args: if arg.startswith(('http', 'ftp')) and arg.endswith('.iso'): network_isolist.append(arg) continue elif arg.startswith(('http', 'ftp')): network_pallets.append(arg) continue arg = os.path.join(os.getcwd(), arg) if os.path.exists(arg) and arg.endswith('.iso'): isolist.append(arg) elif os.path.isdir(arg): disk_pallets.append(arg) else: msg = "Cannot find %s or %s is not an ISO image" raise CommandError(self, msg % (arg, arg)) if self.dryrun: self.beginOutput() if not isolist and not network_pallets and not disk_pallets and not network_isolist: # # no files specified look for a cdrom # rc = os.system('mount | grep %s' % self.mountPoint) if rc == 0: self.copy(clean, dir, updatedb, self.mountPoint) else: raise CommandError(self, 'no pallets provided and /mnt/cdrom is unmounted') for iso in network_isolist: #determine the name of the iso file and get the destined path filename = os.path.basename(urlparse(iso).path) local_path = '/'.join([os.getcwd(),filename]) try: # passing True will display a % progress indicator in stdout local_path = fetch(iso, username, password, True) except FetchError as e: raise CommandError(self, e) cwd = os.getcwd() os.system('mount -o loop %s %s > /dev/null 2>&1' % (local_path, self.mountPoint)) self.copy(clean, dir, updatedb, iso) os.chdir(cwd) os.system('umount %s > /dev/null 2>&1' % self.mountPoint) print('cleaning up temporary files ...') p = subprocess.run(['rm', filename]) if isolist: # # before we mount the ISO, make sure there are no active # mounts on the mountpoint # file = open('/proc/mounts') for line in file.readlines(): l = line.split() if l[1].strip() == self.mountPoint: cmd = 'umount %s' % self.mountPoint cmd += ' > /dev/null 2>&1' subprocess.run([ cmd ], shell=True) for iso in isolist: # have a set of iso files cwd = os.getcwd() os.system('mount -o loop %s %s > /dev/null 2>&1' % (iso, self.mountPoint)) self.copy(clean, dir, updatedb, iso) os.chdir(cwd) os.system('umount %s > /dev/null 2>&1' % self.mountPoint) if network_pallets: for pallet in network_pallets: self.runImplementation('network_pallet', (clean, dir, pallet, updatedb)) if disk_pallets: for pallet in disk_pallets: self.runImplementation('disk_pallet', (clean, dir, pallet, updatedb)) self.endOutput(header=['name', 'version', 'release', 'arch', 'os'], trimOwner=False) # Clear the old packages self.clean_ludicrous_packages()
def run(self, params, args): (clean, dir, updatedb, dryrun) = self.fillParams([ ('clean', 'n'), ('dir', '/export/stack/pallets'), ('updatedb', 'y'), ('dryrun', 'n'), ]) clean = self.str2bool(clean) updatedb = self.str2bool(updatedb) self.dryrun = self.str2bool(dryrun) if self.dryrun: updatedb = False self.out = sys.stderr else: self.out = sys.stdout self.mountPoint = '/mnt/cdrom' if not os.path.exists(self.mountPoint): os.makedirs(self.mountPoint) # Get a list of all the iso files mentioned in # the command line. Make sure we get the complete # path for each file. isolist = [] network_pallets = [] disk_pallets = [] for arg in args: if arg.startswith(('http', 'ftp')): network_pallets.append(arg) continue arg = os.path.join(os.getcwd(), arg) if os.path.exists(arg) and arg.endswith('.iso'): isolist.append(arg) elif os.path.isdir(arg): disk_pallets.append(arg) else: msg = "Cannot find %s or %s is not an ISO image" raise CommandError(self, msg % (arg, arg)) if self.dryrun: self.beginOutput() if not isolist and not network_pallets and not disk_pallets: # # no files specified look for a cdrom # rc = os.system('mount | grep %s' % self.mountPoint) if rc == 0: self.copy(clean, dir, updatedb) else: raise CommandError( self, 'no pallets provided and /mnt/cdrom is unmounted') if isolist: # # before we mount the ISO, make sure there are no active # mounts on the mountpoint # file = open('/proc/mounts') for line in file.readlines(): l = line.split() if l[1].strip() == self.mountPoint: cmd = 'umount %s' % self.mountPoint cmd += ' > /dev/null 2>&1' subprocess.run([cmd], shell=True) for iso in isolist: # have a set of iso files cwd = os.getcwd() os.system('mount -o loop %s %s > /dev/null 2>&1' % (iso, self.mountPoint)) self.copy(clean, dir, updatedb) os.chdir(cwd) os.system('umount %s > /dev/null 2>&1' % self.mountPoint) if network_pallets: for pallet in network_pallets: self.runImplementation('network_pallet', (clean, dir, pallet, updatedb)) if disk_pallets: for pallet in disk_pallets: self.runImplementation('disk_pallet', (clean, dir, pallet, updatedb)) self.endOutput(header=['name', 'version', 'release', 'arch', 'os'], trimOwner=False) # Clear the old packages self.clean_ludicrous_packages()
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)