def setUp(self): subs = copy.deepcopy(CONFIG_SUBS) subs['@INSTALLROOT@'] = INSTALLROOT os.mkdir(INSTALLROOT) rewrite_config(RELEASE_CONFIG_FILE_IN, RELEASE_CONFIG_FILE, subs) farbconfig, handler = ZConfig.loadConfig(SCHEMA, RELEASE_CONFIG_FILE) # Copy in each release and package root needed for release in RELEASE_NAMES: rewrite_config( CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@': 'CD_VERSION = ' + release.upper()}) releasedest = os.path.join(BUILDROOT, release, 'releaseroot', builder.RELEASE_CD_PATH) utils.copyRecursive(ISO_MOUNTPOINT, releasedest) # The fake CD image we have is for 6.2, so we might need to rename a # directory os.rename(os.path.join(releasedest, '6.2-RELEASE'), os.path.join(releasedest, release.upper())) # Create the package root and its package directory pkgdest = os.path.join(BUILDROOT, release, 'pkgroot', 'usr', 'ports', 'packages') utils.copyRecursive(PACKAGEDIR, pkgdest) self.nbr = runner.NetInstallAssemblerRunner(farbconfig) self.nbr.run()
def setUp(self): self.assembler = builder.PackageChrootAssembler(RELEASEROOT, PKGROOT) self.log = open(PROCESS_LOG, 'w+') self.dists = {'base' : ['base'], 'src' : ['szomg', 'swtf']} # Copy in a release to RELEASEROOT rewrite_config(CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@' : 'CD_VERSION = 6.2-RELEASE'}) utils.copyRecursive(ISO_MOUNTPOINT, os.path.join(RELEASEROOT, builder.RELEASE_CD_PATH))
def setUp(self): self.log = open(PROCESS_LOG, 'w+') self.installs = [builder.InstallAssembler('testinstall', 'Test Install', RELEASEROOT, INSTALL_CFG),] self.releaseInstalls = [builder.ReleaseAssembler('6.2', RELEASEROOT, PKGROOT),] self.irb = builder.NetInstallAssembler(INSTALLROOT, self.releaseInstalls, self.installs) # Create dummy "release" to copy to netinstall directory rewrite_config(CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@' : 'CD_VERSION = 6.2-RELEASE'}) utils.copyRecursive(ISO_MOUNTPOINT, os.path.join(RELEASEROOT, builder.RELEASE_CD_PATH))
def setUp(self): self.log = open(PROCESS_LOG, 'w+') self.destdir = os.path.join(TFTPROOT, 'testinstall') self.mfsroot = os.path.join(self.destdir, 'mfsroot') self.installCfg = os.path.join(self.destdir, 'mnt', 'install.cfg') self.bootConf = os.path.join(self.destdir, 'boot.conf') self.builder = builder.InstallAssembler('testinstall', 'Test Install', RELEASEROOT, INSTALL_CFG) os.mkdir(TFTPROOT) os.mkdir(self.destdir) # Create dummy "release" containing the kernel and mfsroot needed rewrite_config(CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@' : 'CD_VERSION = 6.2-RELEASE'}) utils.copyRecursive(ISO_MOUNTPOINT, os.path.join(RELEASEROOT, builder.RELEASE_CD_PATH))
def build(self, log): """ Create the install root, copy in the release data, write out the bootloader configuration and kernels. @param log: Open log file. """ try: # Create the installation root, if necessary if (not os.path.exists(self.installroot)): os.mkdir(self.installroot) # Create the tftproot, if necessary if (not os.path.exists(self.tftproot)): os.mkdir(self.tftproot) # Copy over the shared boot loader and kernel. Lacking any better heuristic, we # grab the boot loader from the first release provided -- shouldn't # matter where we get it, really. However, there are some differences between # where releases store the generic kernel, so we try to impedence match. release = self.releaseAssemblers[0] source = os.path.join(release.cdroot, 'boot') dest = os.path.join(self.tftproot, os.path.basename(source)) # Copy it log.write("Copying shared boot loader and kernel from %s to %s\n" % (source, dest)) utils.copyRecursive(source, dest, symlinks=True) # Configure it log.write( "Generating netinstall.4th and copying loader.conf and loader.rc to %s\n" % dest) self._doConfigureBootLoader(dest) # Assemble the release data for release in self.releaseAssemblers: destdir = os.path.join(self.installroot, release.name) log.write("Assembling release data in %s\n" % destdir) release.build(destdir, log) # Assemble the installation data for install in self.installAssemblers: destdir = os.path.join(self.tftproot, install.name) log.write("Assembling installation-specific data in %s\n" % destdir) install.build(destdir, log) except exceptions.IOError, e: raise NetInstallAssembleError, "An I/O error occured: %s" % e
def setUp(self): rewrite_config(RELEASE_CONFIG_FILE_IN, RELEASE_CONFIG_FILE, CONFIG_SUBS) farbconfig, handler = ZConfig.loadConfig(SCHEMA, RELEASE_CONFIG_FILE) config.verifyPackages(farbconfig) # Copy in each release needed for release in RELEASE_NAMES: rewrite_config(CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@' : 'CD_VERSION = ' + release.upper()}) dest = os.path.join(BUILDROOT, release, 'releaseroot', builder.RELEASE_CD_PATH) utils.copyRecursive(ISO_MOUNTPOINT, dest) # The fake CD image we have is for 6.2, so we might need to rename a # directory os.rename(os.path.join(dest, '6.2-RELEASE'), os.path.join(dest, release.upper())) self.pbr = runner.PackageBuildRunner(farbconfig) self.pbr.run()
class ISOReader(object): """ Copy a binary FreeBSD release from a mounted CD image into a build chroot's RELEASE_CD_PATH. """ def __init__(self, mountpoint, releaseroot): """ Create a new ISOReader instance @param mountpoint: Mount point of FreeBSD install ISO @param releaseroot Release directory to copy the release to. The full contents of the ISO are copied to RELEASE_CD_PATH in this directory """ self.mountpoint = mountpoint self.releaseroot = releaseroot self.cdroot = os.path.join(self.releaseroot, RELEASE_CD_PATH) def copy(self, log): """ Copy release from ISO to target directory. @param log: Open log file """ # Clean out release try: cc = ChrootCleaner(self.releaseroot) cc.clean(log) except ChrootCleanerError, e: raise ISOReaderError, "Error cleaning chroot %s: %s" % ( self.releaseroot, e) # Now do the copy try: utils.copyRecursive(self.mountpoint, self.cdroot, symlinks=True) except utils.Error, e: raise ISOReaderError, "Error copying contents of ISO at %s to %s: %s" % ( self.mountpoint, self.cdroot, e)
def build(self, log): """ Create the install root, copy in the release data, write out the bootloader configuration and kernels. @param log: Open log file. """ try: # Create the installation root, if necessary if (not os.path.exists(self.installroot)): os.mkdir(self.installroot) # Create the tftproot, if necessary if (not os.path.exists(self.tftproot)): os.mkdir(self.tftproot) # Copy over the shared boot loader and kernel. Lacking any better heuristic, we # grab the boot loader from the first release provided -- shouldn't # matter where we get it, really. However, there are some differences between # where releases store the generic kernel, so we try to impedence match. release = self.releaseAssemblers[0] source = os.path.join(release.cdroot, 'boot') dest = os.path.join(self.tftproot, os.path.basename(source)) # Copy it log.write("Copying shared boot loader and kernel from %s to %s\n" % (source, dest)) utils.copyRecursive(source, dest, symlinks=True) # Configure it log.write("Generating netinstall.4th and copying loader.conf and loader.rc to %s\n" % dest) self._doConfigureBootLoader(dest) # Assemble the release data for release in self.releaseAssemblers: destdir = os.path.join(self.installroot, release.name) log.write("Assembling release data in %s\n" % destdir) release.build(destdir, log) # Assemble the installation data for install in self.installAssemblers: destdir = os.path.join(self.tftproot, install.name) log.write("Assembling installation-specific data in %s\n" % destdir) install.build(destdir, log) except exceptions.IOError, e: raise NetInstallAssembleError, "An I/O error occured: %s" % e
def setUp(self): rewrite_config(RELEASE_CONFIG_FILE_IN, RELEASE_CONFIG_FILE, CONFIG_SUBS) farbconfig, handler = ZConfig.loadConfig(SCHEMA, RELEASE_CONFIG_FILE) config.verifyPackages(farbconfig) # Copy in each release needed for release in RELEASE_NAMES: rewrite_config( CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@': 'CD_VERSION = ' + release.upper()}) dest = os.path.join(BUILDROOT, release, 'releaseroot', builder.RELEASE_CD_PATH) utils.copyRecursive(ISO_MOUNTPOINT, dest) # The fake CD image we have is for 6.2, so we might need to rename a # directory os.rename(os.path.join(dest, '6.2-RELEASE'), os.path.join(dest, release.upper())) self.pbr = runner.PackageBuildRunner(farbconfig) self.pbr.run()
def setUp(self): subs = copy.deepcopy(CONFIG_SUBS) subs['@INSTALLROOT@'] = INSTALLROOT os.mkdir(INSTALLROOT) rewrite_config(RELEASE_CONFIG_FILE_IN, RELEASE_CONFIG_FILE, subs) farbconfig, handler = ZConfig.loadConfig(SCHEMA, RELEASE_CONFIG_FILE) # Copy in each release and package root needed for release in RELEASE_NAMES: rewrite_config(CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@' : 'CD_VERSION = ' + release.upper()}) releasedest = os.path.join(BUILDROOT, release, 'releaseroot', builder.RELEASE_CD_PATH) utils.copyRecursive(ISO_MOUNTPOINT, releasedest) # The fake CD image we have is for 6.2, so we might need to rename a # directory os.rename(os.path.join(releasedest, '6.2-RELEASE'), os.path.join(releasedest, release.upper())) # Create the package root and its package directory pkgdest = os.path.join(BUILDROOT, release, 'pkgroot', 'usr', 'ports', 'packages') utils.copyRecursive(PACKAGEDIR, pkgdest) self.nbr = runner.NetInstallAssemblerRunner(farbconfig) self.nbr.run()
def build(self, destdir, log): """ Create the install root, copy in the release data, write out the bootloader configuration and kernels. @param destdir: Per-release installation data directory. @param log: Open log file. """ try: # Copy the installation data log.write("Copying release files from %s to %s\n" % (os.path.join( self.cdroot, _getCDRelease(self.cdroot)), destdir)) utils.copyRecursive(os.path.join(self.cdroot, _getCDRelease(self.cdroot)), destdir, symlinks=True) # If there are packages, copy those too packagedir = os.path.join(self.pkgroot, RELEASE_PACKAGE_PATH) log.write("Copying packages from %s to %s\n" % (packagedir, os.path.join(destdir, 'packages'))) if (os.path.exists(packagedir)): utils.copyRecursive(packagedir, os.path.join(destdir, 'packages'), symlinks=True) # Copy in any local data if (len(self.localData)): # Create the local directory localdir = os.path.join(destdir, 'local') os.mkdir(localdir) for path in self.localData: log.write( "Copying extra local data from %s to %s\n" % (path, os.path.join(localdir, os.path.basename(path)))) if (os.path.isdir(path)): utils.copyRecursive(path, os.path.join( localdir, os.path.basename(path)), symlinks=True) else: utils.copyWithOwnership(path, localdir) # Add the FarBot package installer script and make it executable log.write("Installing package installer script to %s\n" % destdir) utils.copyWithOwnership(farb.INSTALL_PACKAGE_SH, destdir) os.chmod( os.path.join(destdir, os.path.basename(farb.INSTALL_PACKAGE_SH)), 0755) except exceptions.IOError, e: raise ReleaseAssembleError, "An I/O error occured: %s" % e
def build(self, destdir, log): """ Create the install root, copy in the release data, write out the bootloader configuration and kernels. @param destdir: Per-release installation data directory. @param log: Open log file. """ try: # Copy the installation data log.write("Copying release files from %s to %s\n" % (os.path.join(self.cdroot, _getCDRelease(self.cdroot)), destdir)) utils.copyRecursive(os.path.join(self.cdroot, _getCDRelease(self.cdroot)), destdir, symlinks=True) # If there are packages, copy those too packagedir = os.path.join(self.pkgroot, RELEASE_PACKAGE_PATH) log.write("Copying packages from %s to %s\n" % (packagedir, os.path.join(destdir, 'packages'))) if (os.path.exists(packagedir)): utils.copyRecursive(packagedir, os.path.join(destdir, 'packages'), symlinks=True) # Copy in any local data if (len(self.localData)): # Create the local directory localdir = os.path.join(destdir, 'local') os.mkdir(localdir) for path in self.localData: log.write("Copying extra local data from %s to %s\n" % (path, os.path.join(localdir, os.path.basename(path)))) if (os.path.isdir(path)): utils.copyRecursive(path, os.path.join(localdir, os.path.basename(path)), symlinks=True) else: utils.copyWithOwnership(path, localdir) # Add the FarBot package installer script and make it executable log.write("Installing package installer script to %s\n" % destdir) utils.copyWithOwnership(farb.INSTALL_PACKAGE_SH, destdir) os.chmod(os.path.join(destdir, os.path.basename(farb.INSTALL_PACKAGE_SH)), 0755) except exceptions.IOError, e: raise ReleaseAssembleError, "An I/O error occured: %s" % e
def test_copyRecursive(self): utils.copyRecursive(BUILDROOT, self.copyRecursiveDst) # TODO Would need root running this test in order to test # if the ownership copying code works self.assert_(os.path.exists(os.path.join(self.copyRecursiveDst, 'Makefile')))
def _copyKernel(self, destdir): """ Copy the kernel directory to the install-specific directory """ dest = os.path.join(destdir, 'kernel') utils.copyRecursive(self.kernel, dest, symlinks=True)
def setUp(self): self.log = open(PROCESS_LOG, 'w+') self.destdir = os.path.join(INSTALLROOT, 'buildtest') # Create dummy "release" rewrite_config(CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@' : 'CD_VERSION = 6.2-RELEASE'}) utils.copyRecursive(ISO_MOUNTPOINT, os.path.join(RELEASEROOT, builder.RELEASE_CD_PATH))
def test_clean(self): # Now try the same thing with a chroot that isn't empty rewrite_config(CDROM_INF_IN, CDROM_INF, {'@CD_VERSION_LINE@' : 'CD_VERSION = 6.2-RELEASE'}) utils.copyRecursive(ISO_MOUNTPOINT, os.path.join(RELEASEROOT, builder.RELEASE_CD_PATH)) self.cleaner.clean(self.log) self._dirCreated()