def PerformStage(self): new_chroot_dir = 'new-sdk-chroot' tarball_location = os.path.join(self._build_root, SDK_TARBALL_NAME) new_chroot_args = ['--chroot', new_chroot_dir] if self._run.options.chrome_root: new_chroot_args += ['--chrome_root', self._run.options.chrome_root] # Build a new SDK using the provided tarball. chroot_args = new_chroot_args + [ '--download', '--replace', '--nousepkg', '--url', 'file://' + tarball_location ] cros_build_lib.run(['true'], cwd=self._build_root, enter_chroot=True, chroot_args=chroot_args, extra_env=self._portage_extra_env) # Inject the toolchain binpkgs from the previous sdk build. On end user # systems, they'd be fetched from the binpkg mirror, but we don't have one # set up for this local build. pkgdir = os.path.join('var', 'lib', 'portage', 'pkgs') old_pkgdir = os.path.join(self._build_root, constants.DEFAULT_CHROOT_DIR, pkgdir) new_pkgdir = os.path.join(self._build_root, new_chroot_dir, pkgdir) osutils.SafeMakedirs(new_pkgdir, sudo=True) cros_build_lib.sudo_run(['cp', '-r'] + glob.glob(os.path.join(old_pkgdir, '*')) + [new_pkgdir]) # Now install those toolchains in the new chroot. We skip the chroot # upgrade below which means we need to install the toolchain manually. cmd = [ 'cros_setup_toolchains', '--targets=boards', '--include-boards=%s' % ','.join(self._boards) ] commands.RunBuildScript(self._build_root, cmd, chromite_cmd=True, enter_chroot=True, sudo=True, chroot_args=new_chroot_args, extra_env=self._portage_extra_env) # Build all the boards with the new sdk. for board in self._boards: logging.PrintBuildbotStepText(board) commands.SetupBoard(self._build_root, board, usepkg=True, chroot_upgrade=False, extra_env=self._portage_extra_env, chroot_args=new_chroot_args) commands.Build(self._build_root, board, build_autotest=True, usepkg=False, extra_env=self._portage_extra_env, chroot_args=new_chroot_args, disable_revdep_logic=True)
def testBuild(self, default=False, **kwargs): """Base case where Build is called with minimal options.""" kwargs.setdefault('build_autotest', default) kwargs.setdefault('usepkg', default) kwargs.setdefault('chrome_binhost_only', default) kwargs.setdefault('skip_chroot_upgrade', default) commands.Build(buildroot=self._buildroot, board='x86-generic', **kwargs) self.assertCommandContains(['./build_packages'])
def PerformStage(self): # If we have rietveld patches, always compile Chrome from source. noworkon = not self._run.options.rietveld_patches packages = self.GetListOfPackagesToBuild() self.VerifyChromeBinpkg(packages) self.RecordPackagesUnderTest(packages) commands.Build( self._build_root, self._current_board, build_autotest=self._run.ShouldBuildAutotest(), usepkg=self._run.config.usepkg_build_packages, chrome_binhost_only=self._run.config.chrome_binhost_only, packages=packages, skip_chroot_upgrade=True, chrome_root=self._run.options.chrome_root, noworkon=noworkon, noretry=self._run.config.nobuildretry, extra_env=self._portage_extra_env) if self._update_metadata: # TODO: Consider moving this into its own stage if there are other similar # things to do after build_packages. # Extract firmware version information from the newly created updater. main, ec = commands.GetFirmwareVersions(self._build_root, self._current_board) update_dict = { 'main-firmware-version': main, 'ec-firmware-version': ec } self._run.attrs.metadata.UpdateBoardDictWithDict( self._current_board, update_dict) # Write board metadata update to cidb build_id, db = self._run.GetCIDBHandle() if db: db.UpdateBoardPerBuildMetadata(build_id, self._current_board, update_dict)
def PerformStage(self): packages = self.GetListOfPackagesToBuild() self.VerifyChromeBinpkg(packages) if self._record_packages_under_test: self.RecordPackagesUnderTest() # Set up goma. Use goma iff chrome needs to be built. chroot_args = self._SetupGomaIfNecessary() run_goma = bool(chroot_args) if self._run.options.cache_dir: chroot_args = chroot_args or [] chroot_args += ['--cache-dir', self._run.options.cache_dir] # Disable revdep logic on full and release builders. These builders never # reuse sysroots, so the revdep logic only causes unnecessary # rebuilds in the SDK. The SDK rebuilds sometimes hit build critical # packages causing races & build failures. clean_build = (self._run.config.build_type == constants.CANARY_TYPE or self._run.config.build_type == constants.FULL_TYPE or self._run.config.build_type == constants.TOOLCHAIN_TYPE) # Set property to specify bisection builder job to run for Findit. logging.PrintKitchenSetBuildProperty( 'BISECT_BUILDER', self._current_board + '-postsubmit-tryjob') try: commands.Build( self._build_root, self._current_board, build_autotest=self._run.ShouldBuildAutotest(), usepkg=self._run.config.usepkg_build_packages, packages=packages, skip_chroot_upgrade=True, chrome_root=self._run.options.chrome_root, noretry=self._run.config.nobuildretry, chroot_args=chroot_args, extra_env=self._portage_extra_env, run_goma=run_goma, build_all_with_goma=self._run.config.build_all_with_goma, disable_revdep_logic=clean_build, ) except failures_lib.PackageBuildFailure as ex: failure_json = ex.BuildCompileFailureOutputJson() failures_filename = os.path.join(self.archive_path, 'BuildCompileFailureOutput.json') osutils.WriteFile(failures_filename, failure_json) self.UploadArtifact(os.path.basename(failures_filename), archive=False) self.PrintDownloadLink(os.path.basename(failures_filename), text_to_display='BuildCompileFailureOutput') gs_url = os.path.join(self.upload_url, 'BuildCompileFailureOutput.json') logging.PrintKitchenSetBuildProperty('BuildCompileFailureOutput', gs_url) raise if self._update_metadata: # Extract firmware version information from the newly created updater. fw_versions = commands.GetFirmwareVersions(self._build_root, self._current_board) main = fw_versions.main_rw or fw_versions.main ec = fw_versions.ec_rw or fw_versions.ec update_dict = { 'main-firmware-version': main, 'ec-firmware-version': ec } self._run.attrs.metadata.UpdateBoardDictWithDict( self._current_board, update_dict) # Write board metadata update to cidb build_identifier, _ = self._run.GetCIDBHandle() build_id = build_identifier.cidb_id if self.buildstore.AreClientsReady(): self.buildstore.InsertBoardPerBuild(build_id, self._current_board, update_dict) # Get a list of models supported by this board. models = commands.GetModels(self._build_root, self._current_board, log_output=False) self._run.attrs.metadata.UpdateWithDict({'unibuild': bool(models)}) if models: all_fw_versions = commands.GetAllFirmwareVersions( self._build_root, self._current_board) models_data = {} for model in models: if model in all_fw_versions: fw_versions = all_fw_versions[model] ec = fw_versions.ec_rw or fw_versions.ec main_ro = fw_versions.main main_rw = fw_versions.main_rw or main_ro # Get the firmware key-id for the current board and model. model_arg = '--model=' + model key_id_list = commands.RunCrosConfigHost( self._build_root, self._current_board, [model_arg, 'get', '/firmware-signing', 'key-id']) key_id = None if len(key_id_list) == 1: key_id = key_id_list[0] models_data[model] = { 'main-readonly-firmware-version': main_ro, 'main-readwrite-firmware-version': main_rw, 'ec-firmware-version': ec, 'firmware-key-id': key_id } if models_data: self._run.attrs.metadata.UpdateBoardDictWithDict( self._current_board, {'models': models_data})
def PerformStage(self): packages = self.GetListOfPackagesToBuild() self.VerifyChromeBinpkg(packages) self.RecordPackagesUnderTest(packages) try: event_filename = 'build-events.json' event_file = os.path.join(self.archive_path, event_filename) logging.info('Logging events to %s', event_file) event_file_in_chroot = path_util.ToChrootPath(event_file) except cbuildbot_run.VersionNotSetError: #TODO(chingcodes): Add better detection of archive options logging.info('Unable to archive, disabling build events file') event_filename = None event_file = None event_file_in_chroot = None # Set up goma. Use goma iff chrome needs to be built. chroot_args = self._SetupGomaIfNecessary() build_id, _ = self._run.GetCIDBHandle() install_plan_fn = ('/tmp/%s_install_plan.%s' % (self._current_board, build_id)) commands.Build( self._build_root, self._current_board, build_autotest=self._run.ShouldBuildAutotest(), usepkg=self._run.config.usepkg_build_packages, chrome_binhost_only=self._run.config.chrome_binhost_only, packages=packages, skip_chroot_upgrade=True, chrome_root=self._run.options.chrome_root, noretry=self._run.config.nobuildretry, chroot_args=chroot_args, extra_env=self._portage_extra_env, event_file=event_file_in_chroot, run_goma=bool(chroot_args), save_install_plan=install_plan_fn) if event_file and os.path.isfile(event_file): logging.info('Archive build-events.json file') #TODO: @chingcodes Remove upload after events DB is final self.UploadArtifact(event_filename, archive=False, strict=True) creds_file = topology.topology.get( topology.DATASTORE_WRITER_CREDS_KEY) build_id, db = self._run.GetCIDBHandle() if db and creds_file: parent_key = ('Build', build_id, 'BuildStage', self._build_stage_id) commands.ExportToGCloud(self._build_root, creds_file, event_file, parent_key=parent_key, caller=type(self).__name__) else: logging.info('No build-events.json file to archive') if self._update_metadata: # Extract firmware version information from the newly created updater. fw_versions = commands.GetFirmwareVersions(self._build_root, self._current_board) main = fw_versions.main_rw or fw_versions.main ec = fw_versions.ec_rw or fw_versions.ec update_dict = { 'main-firmware-version': main, 'ec-firmware-version': ec } self._run.attrs.metadata.UpdateBoardDictWithDict( self._current_board, update_dict) # Write board metadata update to cidb build_id, db = self._run.GetCIDBHandle() if db: db.UpdateBoardPerBuildMetadata(build_id, self._current_board, update_dict) # Get a list of models supported by this board. models = commands.GetModels(self._build_root, self._current_board, log_output=False) self._run.attrs.metadata.UpdateWithDict({'unibuild': bool(models)}) if models: all_fw_versions = commands.GetAllFirmwareVersions( self._build_root, self._current_board) models_data = {} for model in models: if model in all_fw_versions: fw_versions = all_fw_versions[model] ec = fw_versions.ec_rw or fw_versions.ec main_ro = fw_versions.main main_rw = fw_versions.main_rw or main_ro # Get the firmware key-id for the current board and model. model_arg = '--model=' + model key_id_list = commands.RunCrosConfigHost( self._build_root, self._current_board, [model_arg, 'get', '/firmware', 'key-id']) key_id = None if len(key_id_list) == 1: key_id = key_id_list[0] models_data[model] = { 'main-readonly-firmware-version': main_ro, 'main-readwrite-firmware-version': main_rw, 'ec-firmware-version': ec, 'firmware-key-id': key_id } if models_data: self._run.attrs.metadata.UpdateBoardDictWithDict( self._current_board, {'models': models_data})