def build(self, build_bin=False, build_sources=False, cdrom_size=None, skip_pkglist=False, skip_pbuild=False): # pylint: disable=too-many-arguments # pylint: disable=too-many-locals # pylint: disable=too-many-statements # pylint: disable=too-many-branches # Write the log header self.write_log_header() # Validate Apt Sources if build_sources: m = ValidationMode.CHECK_ALL else: m = ValidationMode.CHECK_BINARIES self.xml.validate_apt_sources(m, self.arch) if self.xml.has('target/pbuilder') and not skip_pbuild: if not os.path.exists(os.path.join(self.builddir, "pbuilder")): self.create_pbuilder(cross=False) for p in self.xml.node('target/pbuilder'): self.pbuild(p) # the package might be needed by a following pbuild, so update # the project repo that it can be installed in as # build-dependency self.repo.finalize() # To avoid update cache errors, the project repo needs to have # Release and Packages files, even if it's empty. So don't do this # in the if case above! self.repo.finalize() # Create the build environment, if it does not a valid one # self.buildenv might be set when we come here. # However, if its not a full_buildenv, we specify clean here, # so it gets rebuilt properly. if not self.has_full_buildenv(): do('mkdir -p "%s"' % self.chrootpath) self.buildenv = BuildEnv(self.xml, self.chrootpath, build_sources=build_sources, clean=True) skip_pkglist = False # Import keyring self.buildenv.import_keys() logging.info("Keys imported") # Install packages if not skip_pkglist: self.install_packages(self.buildenv) try: self.buildenv.rfs.dump_elbeversion(self.xml) except IOError: logging.exception("Dump elbeversion failed") # Extract target FS. We always create a new instance here with # clean=true, because we want a pristine directory. self.targetfs = TargetFs(self.targetpath, self.buildenv.xml, clean=True) os.chdir(self.buildenv.rfs.fname('')) extract_target(self.buildenv.rfs, self.xml, self.targetfs, self.get_rpcaptcache()) # Package validation and package list if not skip_pkglist: pkgs = self.xml.xml.node("/target/pkg-list") if self.xml.has("fullpkgs"): check_full_pkgs(pkgs, self.xml.xml.node("/fullpkgs"), self.get_rpcaptcache()) else: check_full_pkgs(pkgs, None, self.get_rpcaptcache()) dump_fullpkgs(self.xml, self.buildenv.rfs, self.get_rpcaptcache()) self.xml.dump_elbe_version() self.targetfs.write_fstab(self.xml) # Dump ELBE version try: self.targetfs.dump_elbeversion(self.xml) except MemoryError: logging.exception("Dump elbeversion failed") # install packages for buildenv if not skip_pkglist: self.install_packages(self.buildenv, buildenv=True) # Write source.xml try: sourcexmlpath = os.path.join(self.builddir, "source.xml") self.xml.xml.write(sourcexmlpath) except MemoryError: logging.exception("Write source.xml failed (archive to huge?)") # Elbe report cache = self.get_rpcaptcache() tgt_pkgs = elbe_report(self.xml, self.buildenv, cache, self.targetfs) # chroot' licenses self.gen_licenses("chroot", self.buildenv, [p.name for p in cache.get_installed_pkgs()]) self.gen_licenses("target", self.buildenv, tgt_pkgs) # Use some handwaving to determine grub version grub_arch = "ia32" if self.arch == "i386" else self.arch grub_fw_type = [] grub_version = 0 if self.get_rpcaptcache().is_installed('grub-pc'): grub_version = 202 grub_fw_type.append("bios") if self.get_rpcaptcache().is_installed('grub-efi-%s-bin' % grub_arch): grub_version = 202 grub_tgt = "x86_64" if self.arch == "amd64" else self.arch grub_fw_type.extend(["efi", grub_tgt + "-efi"]) if (self.get_rpcaptcache().is_installed('shim-signed') and self.get_rpcaptcache().is_installed( 'grub-efi-%s-signed' % grub_arch)): grub_version = 202 grub_fw_type.append("shimfix") if self.get_rpcaptcache().is_installed('grub-legacy'): logging.warning("package grub-legacy is installed, " "this is obsolete.") grub_version = 97 grub_fw_type.append("bios") elif not grub_fw_type: logging.warning( "neither package grub-pc nor grub-efi-%s-bin " "are installed, skipping grub", grub_arch) self.targetfs.part_target(self.builddir, grub_version, grub_fw_type) self.build_cdroms(build_bin, build_sources, cdrom_size, tgt_pkg_lst=tgt_pkgs) if self.postbuild_file: logging.info("Postbuild script") cmd = ' "%s %s %s"' % (self.builddir, self.xml.text("project/version"), self.xml.text("project/name")) do(self.postbuild_file + cmd, allow_fail=True) do_prj_finetuning(self.xml, self.buildenv, self.targetfs, self.builddir) self.targetfs.pack_images(self.builddir) system('cat "%s"' % self.validationpath)
def build(self, build_bin=False, build_sources=False, cdrom_size=None, skip_pkglist=False, skip_pbuild=False): # pylint: disable=too-many-arguments # pylint: disable=too-many-locals # pylint: disable=too-many-statements # pylint: disable=too-many-branches # Write the log header self.write_log_header() # Validate Apt Sources if build_sources: m = ValidationMode.CHECK_ALL else: m = ValidationMode.CHECK_BINARIES self.xml.validate_apt_sources(m, self.arch) if self.xml.has('target/pbuilder') and not skip_pbuild: if not os.path.exists(os.path.join(self.builddir, "pbuilder")): self.create_pbuilder() for p in self.xml.node('target/pbuilder'): self.pbuild(p) # the package might be needed by a following pbuild, so update # the project repo that it can be installed in as # build-dependency self.repo.finalize() # To avoid update cache errors, the project repo needs to have # Release and Packages files, even if it's empty. So don't do this # in the if case above! self.repo.finalize() # Create the build environment, if it does not a valid one # self.buildenv might be set when we come here. # However, if its not a full_buildenv, we specify clean here, # so it gets rebuilt properly. if not self.has_full_buildenv(): self.log.do('mkdir -p "%s"' % self.chrootpath) self.buildenv = BuildEnv(self.xml, self.log, self.chrootpath, build_sources=build_sources, clean=True) skip_pkglist = False # Import keyring self.buildenv.import_keys() self.log.printo("Keys imported") # Install packages if not skip_pkglist: self.install_packages(self.buildenv) try: self.buildenv.rfs.dump_elbeversion(self.xml) except IOError: self.log.printo("dump elbeversion failed") # Extract target FS. We always create a new instance here with # clean=true, because we want a pristine directory. self.targetfs = TargetFs(self.targetpath, self.log, self.buildenv.xml, clean=True) os.chdir(self.buildenv.rfs.fname('')) extract_target(self.buildenv.rfs, self.xml, self.targetfs, self.log, self.get_rpcaptcache()) # The validation file is created using check_full_pkgs() and # elbe_report(), both opening the file in append mode. So if an # old validation file already exists, it must be deleted first. if os.path.isfile(self.validationpath): os.unlink(self.validationpath) # Package validation and package list if not skip_pkglist: pkgs = self.xml.xml.node("/target/pkg-list") if self.xml.has("fullpkgs"): check_full_pkgs(pkgs, self.xml.xml.node("/fullpkgs"), self.validationpath, self.get_rpcaptcache()) else: check_full_pkgs(pkgs, None, self.validationpath, self.get_rpcaptcache()) dump_fullpkgs(self.xml, self.buildenv.rfs, self.get_rpcaptcache()) self.xml.dump_elbe_version() self.targetfs.write_fstab(self.xml) # Dump ELBE version try: self.targetfs.dump_elbeversion(self.xml) except MemoryError: self.log.printo("dump elbeversion failed") # install packages for buildenv if not skip_pkglist: self.install_packages(self.buildenv, buildenv=True) # Write source.xml try: sourcexmlpath = os.path.join(self.builddir, "source.xml") self.xml.xml.write(sourcexmlpath) except MemoryError: self.log.printo("write source.xml failed (archive to huge?)") # Elbe report reportpath = os.path.join(self.builddir, "elbe-report.txt") elbe_report(self.xml, self.buildenv, self.get_rpcaptcache(), reportpath, self.validationpath, self.targetfs) # the current license code raises an exception that interrupts the hole # build if a licence can't be converted to utf-8. Exception handling # can be removed as soon as the licence code is more stable lic_err = False try: f = io.open(os.path.join(self.builddir, "licence.txt"), "w+", encoding='utf-8') self.buildenv.rfs.write_licenses( f, self.log, os.path.join(self.builddir, "licence.xml")) except Exception: self.log.printo("error during generating licence.txt/xml") self.log.printo(sys.exc_info()[0]) lic_err = True finally: f.close() if lic_err: os.remove(os.path.join(self.builddir, "licence.txt")) os.remove(os.path.join(self.builddir, "licence.xml")) # Use some handwaving to determine grub version # jessie and wheezy grubs are 2.0 but differ in behaviour # # We might also want support for legacy grub if (self.get_rpcaptcache().is_installed('grub-pc') and self.get_rpcaptcache().is_installed('grub-efi-amd64-bin')): grub_version = 202 grub_fw_type = "hybrid" elif self.get_rpcaptcache().is_installed('grub-pc'): if self.codename == "wheezy": grub_version = 199 else: grub_version = 202 grub_fw_type = "bios" elif self.get_rpcaptcache().is_installed('grub-efi-amd64'): grub_version = 202 grub_fw_type = "efi" elif self.get_rpcaptcache().is_installed('grub-legacy'): self.log.printo("package grub-legacy is installed, " "this is obsolete, skipping grub") grub_version = 0 grub_fw_type = "" else: self.log.printo("package grub-pc is not installed, skipping grub") # version 0 == skip_grub grub_version = 0 grub_fw_type = "" self.targetfs.part_target(self.builddir, grub_version, grub_fw_type) self.build_cdroms(build_bin, build_sources, cdrom_size) if self.postbuild_file: self.log.h2("postbuild script:") self.log.do(self.postbuild_file + ' "%s %s %s"' % (self.builddir, self.xml.text("project/version"), self.xml.text("project/name")), allow_fail=True) do_prj_finetuning(self.xml, self.log, self.buildenv, self.targetfs, self.builddir) self.targetfs.pack_images(self.builddir) system('cat "%s"' % self.validationpath)
def build(self, skip_debootstrap=False, build_bin=False, build_sources=False, cdrom_size=None, debug=False, skip_pkglist=False): # Write the log header self.write_log_header() # Create the build environment, if it does not exist yet if not self.buildenv: self.log.do('mkdir -p "%s"' % self.chrootpath) self.buildenv = BuildEnv(self.xml, self.log, self.chrootpath, build_sources=build_sources) skip_pkglist = False # Install packages if not skip_pkglist: self.install_packages() try: self.buildenv.rfs.dump_elbeversion(self.xml) except IOError: self.log.printo("dump elbeversion failed") # Extract target FS. We always create a new instance here with # clean=true, because we want a pristine directory. self.targetfs = TargetFs(self.targetpath, self.log, self.buildenv.xml, clean=True) os.chdir(self.buildenv.rfs.fname('')) extract_target(self.buildenv.rfs, self.xml, self.targetfs, self.log, self.get_rpcaptcache()) # Package validation and package list if not skip_pkglist: validationpath = os.path.join(self.builddir, "validation.txt") pkgs = self.xml.xml.node("/target/pkg-list") if self.xml.has("fullpkgs"): check_full_pkgs(pkgs, self.xml.xml.node("/fullpkgs"), validationpath, self.get_rpcaptcache()) else: check_full_pkgs(pkgs, None, validationpath, self.get_rpcaptcache()) dump_fullpkgs(self.xml, self.buildenv.rfs, self.get_rpcaptcache()) self.xml.dump_elbe_version() self.targetfs.write_fstab(self.xml) # Dump ELBE version try: self.targetfs.dump_elbeversion(self.xml) except MemoryError: self.log.printo("dump elbeversion failed") # install packages for buildenv if not skip_pkglist: self.install_packages(buildenv=True) # Write source.xml try: sourcexmlpath = os.path.join(self.builddir, "source.xml") self.xml.xml.write(sourcexmlpath) except MemoryError: self.log.printo("write source.xml failed (archive to huge?)") # Elbe report reportpath = os.path.join(self.builddir, "elbe-report.txt") elbe_report(self.xml, self.buildenv, self.get_rpcaptcache(), reportpath, self.targetfs) # Licenses f = open(os.path.join(self.builddir, "licence.txt"), "w+") self.buildenv.rfs.write_licenses(f, self.log) f.close() # Read arch and codename from xml arch = self.xml.text("project/arch", key="arch") codename = self.xml.text("project/suite") # Use some handwaving to determine grub version # jessie and wheezy grubs are 2.0 but differ in behaviour # # We might also want support for legacy grub if self.get_rpcaptcache().is_installed('grub-pc'): if codename == "jessie": grub_version = 202 else: grub_version = 199 elif self.get_rpcaptcache().is_installed('grub-legacy'): self.log.printo( "package grub-legacy is installed, this is obsolete, skipping grub" ) grub_version = 0 else: self.log.printo("package grub-pc is not installed, skipping grub") # version 0 == skip_grub grub_version = 0 self.targetfs.part_target(self.builddir, grub_version) # Build cdrom images self.repo_images = [] with self.buildenv: init_codename = self.xml.get_initvm_codename() if build_bin: self.repo_images += mk_binary_cdrom(self.buildenv.rfs, arch, codename, init_codename, self.xml, self.builddir, self.log, cdrom_size=cdrom_size) if build_sources: try: self.repo_images += mk_source_cdrom(self.buildenv.rfs, arch, codename, init_codename, self.builddir, self.log, cdrom_size=cdrom_size) except SystemError as e: # e.g. no deb-src urls specified self.log.printo(str(e)) if self.postbuild_file: self.log.h2("postbuild script:") self.log.do(self.postbuild_file + ' "%s %s %s"' % (self.builddir, self.xml.text("project/version"), self.xml.text("project/name")), allow_fail=True) os.system('cat "%s"' % os.path.join(self.builddir, "validation.txt"))
def build(self, build_bin=False, build_sources=False, cdrom_size=None, skip_pkglist=False, skip_pbuild=False): # pylint: disable=too-many-arguments # pylint: disable=too-many-locals # pylint: disable=too-many-statements # pylint: disable=too-many-branches # Write the log header self.write_log_header() # Validate Apt Sources if build_sources: m = ValidationMode.CHECK_ALL else: m = ValidationMode.CHECK_BINARIES self.xml.validate_apt_sources(m, self.arch) if self.xml.has('target/pbuilder') and not skip_pbuild: if not os.path.exists(os.path.join(self.builddir, "pbuilder")): self.create_pbuilder() for p in self.xml.node('target/pbuilder'): self.pbuild(p) # the package might be needed by a following pbuild, so update # the project repo that it can be installed in as # build-dependency self.repo.finalize() # To avoid update cache errors, the project repo needs to have # Release and Packages files, even if it's empty. So don't do this # in the if case above! self.repo.finalize() # Create the build environment, if it does not a valid one # self.buildenv might be set when we come here. # However, if its not a full_buildenv, we specify clean here, # so it gets rebuilt properly. if not self.has_full_buildenv(): self.log.do('mkdir -p "%s"' % self.chrootpath) self.buildenv = BuildEnv(self.xml, self.log, self.chrootpath, build_sources=build_sources, clean=True) skip_pkglist = False # Import keyring self.buildenv.import_keys() self.log.printo("Keys imported") # Install packages if not skip_pkglist: self.install_packages(self.buildenv) try: self.buildenv.rfs.dump_elbeversion(self.xml) except IOError: self.log.printo("dump elbeversion failed") # Extract target FS. We always create a new instance here with # clean=true, because we want a pristine directory. self.targetfs = TargetFs(self.targetpath, self.log, self.buildenv.xml, clean=True) os.chdir(self.buildenv.rfs.fname('')) extract_target(self.buildenv.rfs, self.xml, self.targetfs, self.log, self.get_rpcaptcache()) # The validation file is created using check_full_pkgs() and # elbe_report(), both opening the file in append mode. So if an # old validation file already exists, it must be deleted first. if os.path.isfile(self.validationpath): os.unlink(self.validationpath) # Package validation and package list if not skip_pkglist: pkgs = self.xml.xml.node("/target/pkg-list") if self.xml.has("fullpkgs"): check_full_pkgs(pkgs, self.xml.xml.node("/fullpkgs"), self.validationpath, self.get_rpcaptcache()) else: check_full_pkgs(pkgs, None, self.validationpath, self.get_rpcaptcache()) dump_fullpkgs(self.xml, self.buildenv.rfs, self.get_rpcaptcache()) self.xml.dump_elbe_version() self.targetfs.write_fstab(self.xml) # Dump ELBE version try: self.targetfs.dump_elbeversion(self.xml) except MemoryError: self.log.printo("dump elbeversion failed") # install packages for buildenv if not skip_pkglist: self.install_packages(self.buildenv, buildenv=True) # Write source.xml try: sourcexmlpath = os.path.join(self.builddir, "source.xml") self.xml.xml.write(sourcexmlpath) except MemoryError: self.log.printo("write source.xml failed (archive to huge?)") # Elbe report reportpath = os.path.join(self.builddir, "elbe-report.txt") elbe_report(self.xml, self.buildenv, self.get_rpcaptcache(), reportpath, self.validationpath, self.targetfs) # the current license code raises an exception that interrupts the hole # build if a licence can't be converted to utf-8. Exception handling # can be removed as soon as the licence code is more stable lic_err = False try: f = io.open( os.path.join( self.builddir, "licence.txt"), "w+", encoding='utf-8') self.buildenv.rfs.write_licenses( f, self.log, os.path.join( self.builddir, "licence.xml")) except Exception: self.log.printo("error during generating licence.txt/xml") self.log.printo(sys.exc_info()[0]) lic_err = True finally: f.close() if lic_err: os.remove(os.path.join(self.builddir, "licence.txt")) os.remove(os.path.join(self.builddir, "licence.xml")) # Use some handwaving to determine grub version # jessie and wheezy grubs are 2.0 but differ in behaviour # # We might also want support for legacy grub if (self.get_rpcaptcache().is_installed('grub-pc') and self.get_rpcaptcache().is_installed('grub-efi-amd64-bin')): grub_version = 202 grub_fw_type = "hybrid" elif self.get_rpcaptcache().is_installed('grub-pc'): if self.codename == "wheezy": grub_version = 199 else: grub_version = 202 grub_fw_type = "bios" elif self.get_rpcaptcache().is_installed('grub-efi-amd64'): grub_version = 202 grub_fw_type = "efi" elif self.get_rpcaptcache().is_installed('grub-legacy'): self.log.printo("package grub-legacy is installed, " "this is obsolete, skipping grub") grub_version = 0 grub_fw_type = "" else: self.log.printo("package grub-pc is not installed, skipping grub") # version 0 == skip_grub grub_version = 0 grub_fw_type = "" self.targetfs.part_target(self.builddir, grub_version, grub_fw_type) self.build_cdroms(build_bin, build_sources, cdrom_size) if self.postbuild_file: self.log.h2("postbuild script:") self.log.do(self.postbuild_file + ' "%s %s %s"' % ( self.builddir, self.xml.text("project/version"), self.xml.text("project/name")), allow_fail=True) do_prj_finetuning(self.xml, self.log, self.buildenv, self.targetfs, self.builddir) self.targetfs.pack_images(self.builddir) os.system('cat "%s"' % self.validationpath)
def build (self, skip_debootstrap = False, build_bin = False, build_sources = False, cdrom_size = None, debug = False, skip_pkglist = False): # Write the log header self.write_log_header() # Create the build environment, if it does not exist yet if not self.buildenv: self.log.do( 'mkdir -p "%s"' % self.chrootpath ) self.buildenv = BuildEnv( self.xml, self.log, self.chrootpath, build_sources = build_sources ) skip_pkglist = False # Install packages if not skip_pkglist: self.install_packages() try: self.buildenv.rfs.dump_elbeversion (self.xml) except IOError: self.log.printo ("dump elbeversion failed") # Extract target FS. We always create a new instance here with # clean=true, because we want a pristine directory. self.targetfs = TargetFs( self.targetpath, self.log, self.buildenv.xml, clean=True ) os.chdir( self.buildenv.rfs.fname( '' ) ) extract_target( self.buildenv.rfs, self.xml, self.targetfs, self.log, self.get_rpcaptcache() ) # Package validation and package list if not skip_pkglist: validationpath = os.path.join( self.builddir, "validation.txt" ) pkgs = self.xml.xml.node( "/target/pkg-list" ) if self.xml.has( "fullpkgs" ): check_full_pkgs( pkgs, self.xml.xml.node( "/fullpkgs" ), validationpath, self.get_rpcaptcache() ) else: check_full_pkgs( pkgs, None, validationpath, self.get_rpcaptcache() ) dump_fullpkgs( self.xml, self.buildenv.rfs, self.get_rpcaptcache() ) self.xml.dump_elbe_version () self.targetfs.write_fstab (self.xml ) # Dump ELBE version try: self.targetfs.dump_elbeversion( self.xml ) except MemoryError: self.log.printo( "dump elbeversion failed" ) # install packages for buildenv if not skip_pkglist: self.install_packages(buildenv=True) # Write source.xml try: sourcexmlpath = os.path.join( self.builddir, "source.xml" ) self.xml.xml.write( sourcexmlpath ) except MemoryError: self.log.printo( "write source.xml failed (archive to huge?)" ) # Elbe report reportpath = os.path.join( self.builddir, "elbe-report.txt" ) elbe_report( self.xml, self.buildenv, self.get_rpcaptcache(), reportpath, self.targetfs ) # Licenses f = open( os.path.join( self.builddir, "licence.txt" ), "w+" ) self.buildenv.rfs.write_licenses(f, self.log) f.close() # Read arch and codename from xml arch = self.xml.text( "project/arch", key="arch" ) codename = self.xml.text( "project/suite" ) # Use some handwaving to determine grub version # jessie and wheezy grubs are 2.0 but differ in behaviour # # We might also want support for legacy grub if self.get_rpcaptcache().is_installed( 'grub-pc' ): if codename == "jessie": grub_version = 202 else: grub_version = 199 elif self.get_rpcaptcache().is_installed( 'grub-legacy' ): self.log.printo( "package grub-legacy is installed, this is obsolete, skipping grub" ) grub_version = 0 else: self.log.printo( "package grub-pc is not installed, skipping grub" ) # version 0 == skip_grub grub_version = 0 self.targetfs.part_target( self.builddir, grub_version ) # Build cdrom images self.repo_images = [] with self.buildenv: init_codename = self.xml.get_initvm_codename() if build_bin: self.repo_images += mk_binary_cdrom( self.buildenv.rfs, arch, codename, init_codename, self.xml, self.builddir, self.log, cdrom_size=cdrom_size ) if build_sources: try: self.repo_images += mk_source_cdrom( self.buildenv.rfs, arch, codename, init_codename, self.builddir, self.log, cdrom_size=cdrom_size ) except SystemError as e: # e.g. no deb-src urls specified self.log.printo( str (e) ) if self.postbuild_file: self.log.h2 ("postbuild script:") self.log.do (self.postbuild_file + ' "%s %s %s"' % ( self.builddir, self.xml.text ("project/version"), self.xml.text ("project/name")), allow_fail=True) os.system( 'cat "%s"' % os.path.join( self.builddir, "validation.txt" ) )
def build(self, skip_debootstrap=False, build_bin=False, build_sources=False, cdrom_size=None, debug=False, skip_pkglist=False, skip_pbuild=False): # Write the log header self.write_log_header() # Validate Apt Sources m = ValidationMode.NO_CHECK if build_bin: m = ValidationMode.CHECK_BINARIES if build_sources: m = ValidationMode.CHECK_ALL self.xml.validate_apt_sources(m, self.arch) if (self.xml.has('target/pbuilder') and not skip_pbuild): if not os.path.exists(os.path.join(self.builddir, "pbuilder")): self.create_pbuilder() for p in self.xml.node('target/pbuilder'): self.pbuild(p) # the package might be needed by a following pbuild, so update # the project repo that it can be installed in as # build-dependency self.repo.finalize() # To avoid update cache errors, the project repo needs to have # Release and Packages files, even if it's empty. So don't do this # in the if case above! self.repo.finalize() # Create the build environment, if it does not a valid one # self.buildenv might be set when we come here. # However, if its not a full_buildenv, we specify clean here, # so it gets rebuilt properly. if not self.has_full_buildenv(): self.log.do('mkdir -p "%s"' % self.chrootpath) self.buildenv = BuildEnv(self.xml, self.log, self.chrootpath, build_sources=build_sources, clean=True) skip_pkglist = False # Import keyring self.buildenv.import_keys() self.log.printo("Keys imported") # Install packages if not skip_pkglist: self.install_packages() try: self.buildenv.rfs.dump_elbeversion(self.xml) except IOError: self.log.printo("dump elbeversion failed") # Extract target FS. We always create a new instance here with # clean=true, because we want a pristine directory. self.targetfs = TargetFs(self.targetpath, self.log, self.buildenv.xml, clean=True) os.chdir(self.buildenv.rfs.fname('')) extract_target(self.buildenv.rfs, self.xml, self.targetfs, self.log, self.get_rpcaptcache()) # Package validation and package list if not skip_pkglist: validationpath = os.path.join(self.builddir, "validation.txt") pkgs = self.xml.xml.node("/target/pkg-list") if self.xml.has("fullpkgs"): check_full_pkgs(pkgs, self.xml.xml.node("/fullpkgs"), validationpath, self.get_rpcaptcache()) else: check_full_pkgs(pkgs, None, validationpath, self.get_rpcaptcache()) dump_fullpkgs(self.xml, self.buildenv.rfs, self.get_rpcaptcache()) self.xml.dump_elbe_version() self.targetfs.write_fstab(self.xml) # Dump ELBE version try: self.targetfs.dump_elbeversion(self.xml) except MemoryError: self.log.printo("dump elbeversion failed") # install packages for buildenv if not skip_pkglist: self.install_packages(buildenv=True) # Write source.xml try: sourcexmlpath = os.path.join(self.builddir, "source.xml") self.xml.xml.write(sourcexmlpath) except MemoryError: self.log.printo("write source.xml failed (archive to huge?)") # Elbe report reportpath = os.path.join(self.builddir, "elbe-report.txt") elbe_report(self.xml, self.buildenv, self.get_rpcaptcache(), reportpath, self.targetfs) # Licenses f = io.open(os.path.join(self.builddir, "licence.txt"), "w+", encoding='utf-8') self.buildenv.rfs.write_licenses( f, self.log, os.path.join(self.builddir, "licence.xml")) f.close() # Use some handwaving to determine grub version # jessie and wheezy grubs are 2.0 but differ in behaviour # # We might also want support for legacy grub if self.get_rpcaptcache().is_installed('grub-pc'): if self.codename == "wheezy": grub_version = 199 else: grub_version = 202 elif self.get_rpcaptcache().is_installed('grub-legacy'): self.log.printo( "package grub-legacy is installed, this is obsolete, skipping grub" ) grub_version = 0 else: self.log.printo("package grub-pc is not installed, skipping grub") # version 0 == skip_grub grub_version = 0 self.targetfs.part_target(self.builddir, grub_version) # Build cdrom images self.repo_images = [] with self.buildenv: init_codename = self.xml.get_initvm_codename() if build_bin: self.repo_images += mk_binary_cdrom(self.buildenv.rfs, self.arch, self.codename, init_codename, self.xml, self.builddir, self.log, cdrom_size=cdrom_size) if build_sources: try: self.repo_images += mk_source_cdrom(self.buildenv.rfs, self.arch, self.codename, init_codename, self.builddir, self.log, cdrom_size=cdrom_size, xml=self.xml) except SystemError as e: # e.g. no deb-src urls specified self.log.printo(str(e)) if self.postbuild_file: self.log.h2("postbuild script:") self.log.do(self.postbuild_file + ' "%s %s %s"' % (self.builddir, self.xml.text("project/version"), self.xml.text("project/name")), allow_fail=True) os.system('cat "%s"' % os.path.join(self.builddir, "validation.txt"))