Exemplo n.º 1
0
Arquivo: build.py Projeto: hocks/core
    def builder(self, path, file, root):
        if not root:
            root = self.dist.getReleasePath()
        dir	 = os.path.join(root, path)
        fullname = os.path.join(dir, file.getName())

        if file.getFullName() == fullname:
            return

        if not os.path.isdir(dir):
            os.makedirs(dir)

        # Create the new distribution either with all symbolic links
        # into the mirror, contrib, and local rpms.  Or copy
        # everything.  The idea is local distributions should be all
        # symlinks, but a published base distribution (like the NPACI
        # Rocks master) should be copys.  This keeps the FTP chroot
        # environment happy, extends the lifetime of the release past
        # that of scattered RPMS.  It may also make sense to have your
        # master distribution for your cluster done by copy.
        
        if self.useLinks:
            file.symlink(fullname, self.dist.getRootPath())
        else:

            # For copied distributions, the timestamps of the new
            # files are forced to that of the source files.  This
            # keeps wget happy.

            if os.path.islink(file.getFullName()):
                os.symlink(os.readlink(file.getFullName()), fullname)
            else:
                shutil.copy(file.getFullName(), fullname)
                os.utime(fullname, (file.getTimestamp(), file.getTimestamp()))
Exemplo n.º 2
0
Arquivo: build.py Projeto: Sudoka/base
    def builder(self, path, file, root):
        if not root:
            root = self.dist.getReleasePath()
        dir	 = os.path.join(root, path)
        fullname = os.path.join(dir, file.getName())

        if file.getFullName() == fullname:
            return

        if not os.path.isdir(dir):
            os.makedirs(dir)

        # Create the new distribution either with all symbolic links
        # into the mirror, contrib, and local rpms.  Or copy
        # everything.  The idea is local distributions should be all
        # symlinks, but a published base distribution (like the NPACI
        # Rocks master) should be copys.  This keeps the FTP chroot
        # environment happy, extends the lifetime of the release past
        # that of scattered RPMS.  It may also make sense to have your
        # master distribution for your cluster done by copy.
        
        if self.useLinks:
            file.symlink(fullname, self.dist.getRootPath())
        else:

            # For copied distributions, the timestamps of the new
            # files are forced to that of the source files.  This
            # keeps wget happy.

            if os.path.islink(file.getFullName()):
                os.symlink(os.readlink(file.getFullName()), fullname)
            else:
                shutil.copy(file.getFullName(), fullname)
                os.utime(fullname, (file.getTimestamp(), file.getTimestamp()))
Exemplo n.º 3
0
	def run(self):

		# Make a list of all the files that we need to copy onto the
		# rolls cds.  Don't worry about what the file types are right
		# now, we can figure that out later.
			
		list = []
		if self.config.hasRPMS():
			list.extend(self.getRPMS('RPMS'))
		if self.config.hasSRPMS():
			list.extend(self.getRPMS('SRPMS'))
		for rpm in list:
			self.signRPM(rpm)

		# Make a list of both required and optional packages.  The copy
		# code is here since python is by-reference for everything.
		# After we segregate the packages (old rocks-dist style) add
		# any local rpms to the required list.  This makes sure we
		# pick up the roll-os-kickstart package.
		
		required = []
		if self.config.hasRolls():
			(required, optional) = self.getExternalRPMS()
			for file in list:
				required.append(file)
			print 'Required Packages', len(required)
			print 'Optional Packages', len(optional)
			for file in required: # make a copy of the list
				list.append(file)
			list.extend(optional)


		optional = 0
		for (name, id, size, files) in self.spanDisks(list):
			print 'Creating %s (%.2fMB)...' % (name, size),
			if optional:
				print ' This disk is optional (extra rpms)'
			else:
				print 
				
			root = os.path.join(name,
				self.config.getRollName(),
				self.config.getRollVersion(),
				self.config.getRollArch())
			os.makedirs(root)
			os.makedirs(os.path.join(root, 'RedHat', 'RPMS'))
			os.makedirs(os.path.join(root, 'SRPMS'))
			
			# Symlink in all the RPMS and SRPMS
			
			for file in files:
				try:
					#
					# not RPM files will throw an exception
					# in getPackageArch()
					#
					arch = file.getPackageArch()
				except:
					continue

				if arch == 'src':
					file.symlink(os.path.join(root,
						'SRPMS', file.getName()))
				else:
					file.symlink(os.path.join(root,
						'RedHat', 'RPMS',
						file.getName()))
				if file in required:
					del required[required.index(file)]
					
			if len(required) == 0:
				optional = 1
				
			# Copy the Roll XML file onto all the disks
			shutil.copy(self.config.getFullName(), root)
			
			# Create the .discinfo file
					
			self.stampDisk(name, self.config.getRollName(), 
				self.config.getRollArch(), id)
				
			# make the ISO.  This code will change and move into
			# the base class, and supported bootable rolls.  Get
			# this working here and then test on the bootable
			# kernel roll.
			
			isoname = '%s-%s-%s.%s.%s.iso' % (
				self.config.getRollName(),
				self.config.getRollVersion(),
				self.config.getRollRelease(),
				self.config.getRollArch(),
				name)
				
			if id == 1 and self.config.isBootable() == 1:
				self.makeBootable(name)
			
			self.mkisofs(isoname, self.config.getRollName(), name)
Exemplo n.º 4
0
    def run(self):

        # Make a list of all the files that we need to copy onto the
        # rolls cds.  Don't worry about what the file types are right
        # now, we can figure that out later.

        list = []
        if self.config.hasRPMS():
            list.extend(self.getRPMS('RPMS'))
        if self.config.hasSRPMS():
            list.extend(self.getRPMS('SRPMS'))
        for rpm in list:
            self.signRPM(rpm)

        # Make a list of both required and optional packages.  The copy
        # code is here since python is by-reference for everything.
        # After we segregate the packages (old rocks-dist style) add
        # any local rpms to the required list.  This makes sure we
        # pick up the roll-os-kickstart package.

        required = []
        if self.config.hasRolls():
            (required, optional) = self.getExternalRPMS()
            for file in list:
                required.append(file)
            print 'Required Packages', len(required)
            print 'Optional Packages', len(optional)
            for file in required:  # make a copy of the list
                list.append(file)
            list.extend(optional)

        optional = 0
        for (name, id, size, files) in self.spanDisks(list):
            print 'Creating %s (%.2fMB)...' % (name, size),
            if optional:
                print ' This disk is optional (extra rpms)'
            else:
                print

            root = os.path.join(name, self.config.getRollName(),
                                self.config.getRollVersion(),
                                self.config.getRollArch())
            os.makedirs(root)
            os.makedirs(os.path.join(root, 'RedHat', 'RPMS'))
            os.makedirs(os.path.join(root, 'SRPMS'))

            # Symlink in all the RPMS and SRPMS

            for file in files:
                try:
                    #
                    # not RPM files will throw an exception
                    # in getPackageArch()
                    #
                    arch = file.getPackageArch()
                except:
                    continue

                if arch == 'src':
                    file.symlink(os.path.join(root, 'SRPMS', file.getName()))
                else:
                    file.symlink(
                        os.path.join(root, 'RedHat', 'RPMS', file.getName()))
                if file in required:
                    del required[required.index(file)]

            if len(required) == 0:
                optional = 1

            # Copy the Roll XML file onto all the disks
            shutil.copy(self.config.getFullName(), root)

            # Create the .discinfo file

            self.stampDisk(name, self.config.getRollName(),
                           self.config.getRollArch(), id)

            # make the ISO.  This code will change and move into
            # the base class, and supported bootable rolls.  Get
            # this working here and then test on the bootable
            # kernel roll.

            isoname = '%s-%s-%s.%s.%s.iso' % (
                self.config.getRollName(), self.config.getRollVersion(),
                self.config.getRollRelease(), self.config.getRollArch(), name)

            if id == 1 and self.config.isBootable() == 1:
                self.makeBootable(name)

            self.mkisofs(isoname, self.config.getRollName(), name)