def testGetFirmwareVersions(self):
    self.rc.SetDefaultCmdResult(output='''

flashrom(8): a273d7fd6663c665176159496bc014ff */build/nyan/usr/sbin/flashrom
             ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, BuildID[sha1]=61d8a9676e433414fb0e22fa819b55be86329e44, stripped


BIOS image:   4aba4c07a65b7bf82d72d8ed892f5dc5 */build/nyan/tmp/portage/chromeos-base/chromeos-firmware-nyan-0.0.1-r20/work/chromeos-firmware-nyan-0.0.1/.dist/nyan_fw_5771.10.0.tbz2/image.bin
BIOS version: Google_Nyan.5771.10.0
EC image:     7b6bb5035fa8101b41c954bce5250dae */build/nyan/tmp/portage/chromeos-base/chromeos-firmware-nyan-0.0.1-r20/work/chromeos-firmware-nyan-0.0.1/.dist/nyan_ec_5771.10.0.tbz2/ec.bin
EC version:   nyan_v1.1.1782-23f1337

Package Content:
d7124c9a2680ff57f1c7d6521ac5ef8c *./mosys
ad9520c70add670d8f2770a2a3c4115a *./gbb_utility
7b6bb5035fa8101b41c954bce5250dae *./ec.bin
a273d7fd6663c665176159496bc014ff *./flashrom
d149f6413749ca6a0edddd52926f95ca *./dump_fmap
5bfe13d9b7fef1dfd9d3dac185f94994 *./crossystem
3c3a99346d1ca1273cbcd86c104851ff *./shflags
4aba4c07a65b7bf82d72d8ed892f5dc5 *./bios.bin
2a484f3e107bf27a4d1068e03e74803c *./common.sh
995a97518f90541d37c3f57a336d37db *./vpd
b9270e726180af1ed59077d1ab2fc688 *./crosfw.sh
f6b0b80d5f2d9a2fb41ebb6e2cee7ad8 *./updater4.sh
4363fcfd6849b2ab1a7320b1c98a11f2 *./crosutil.sh
''')
    build_sbin = os.path.join(self._buildroot, constants.DEFAULT_CHROOT_DIR,
                              'build', self._board, 'usr', 'sbin')
    osutils.Touch(os.path.join(build_sbin, 'chromeos-firmwareupdate'),
                  makedirs=True)
    result = commands.GetFirmwareVersions(self._buildroot, self._board)
    versions = ('Google_Nyan.5771.10.0', 'nyan_v1.1.1782-23f1337')
    self.assertEquals(result, versions)
    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)
Beispiel #3
0
    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})
Beispiel #4
0
    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})