def _CleanUpAndRunCommand(self, *args, **kwargs): """Clean up repository and run command""" commands.BuildRootGitCleanup(self.directory) local_manifest = kwargs.pop('local_manifest', None) # Always re-initialize to the current branch. self.Initialize(local_manifest) # Fix existing broken mirroring configurations. self._EnsureMirroring() cros_build_lib.RunCommand(*args, **kwargs)
def _CleanUpAndRunCommand(self, *args, **kwargs): """Clean up repository and run command. This is only called in repo network Sync retries. """ commands.BuildRootGitCleanup(self.directory) local_manifest = kwargs.pop('local_manifest', None) # Always re-initialize to the current branch. self.Initialize(local_manifest) # Fix existing broken mirroring configurations. self._EnsureMirroring() fields = {'manifest_repo': self.manifest_repo_url} metrics.Counter( constants.MON_REPO_SYNC_RETRY_COUNT).increment(fields=fields) cros_build_lib.RunCommand(*args, **kwargs)
def PerformStage(self): overlays, push_overlays = self._ExtractOverlays() staging_branch = None if self.stage_push: if not config_lib.IsMasterChromePFQ(self._run.config): raise ValueError( 'This build must be a master chrome PFQ build ' 'when stage_push is True.') build_id, db = self._run.GetCIDBHandle() # If the master passed BinHostTest and all the important slaves passed # UploadPrebuiltsTest, push uprev commits to a staging_branch. if (self.CheckMasterBinhostTest(db, build_id) and self.CheckSlaveUploadPrebuiltsTest(db, build_id)): staging_branch = ('refs/' + constants.PFQ_REF + '/' + constants.STAGING_PFQ_BRANCH_PREFIX + str(build_id)) assert push_overlays, 'push_overlays must be set to run this stage' # If we're a commit queue, we should clean out our local changes, resync, # and reapply our uprevs. This is necessary so that 1) we are sure to point # at the remote SHA1s, not our local SHA1s; 2) we can avoid doing a # rebase; 3) in the case of failure and staging_branch is None, we don't # submit the changes that were committed locally. # # If we're not a commit queue and the build succeeded, we can skip the # cleanup here. This is a cheap trick so that the Chrome PFQ pushes its # earlier uprev from the SyncChrome stage (it would be a bit tricky to # replicate the uprev here, so we'll leave it alone). # If we're not a commit queue and staging_branch is not None, we can skip # the cleanup here. When staging_branch is not None, we're going to push # the local commits generated in AFDOUpdateEbuild stage to the # staging_branch, cleaning up repository here will wipe out the local # commits. if (config_lib.IsCQType(self._run.config.build_type) or not (self.success or staging_branch is not None)): # Clean up our root and sync down the latest changes that were # submitted. commands.BuildRootGitCleanup(self._build_root) # Sync down the latest changes we have submitted. if self._run.options.sync: next_manifest = self._run.config.manifest repo = self.GetRepoRepository() repo.Sync(next_manifest) # Commit an uprev locally. if self._run.options.uprev and self._run.config.uprev: commands.UprevPackages(self._build_root, self._boards, overlays) # When prebuilts is True, if it's a successful run or staging_branch is # not None for a master-chrome-pfq run, update binhost conf if (self._run.config.prebuilts and (self.success or staging_branch is not None)): confwriter = prebuilts.BinhostConfWriter(self._run) confwriter.Perform() # Push the uprev and binhost commits. commands.UprevPush(self._build_root, push_overlays, self._run.options.debug, staging_branch=staging_branch) if config_lib.IsMasterChromePFQ(self._run.config) and self.success: self._run.attrs.metadata.UpdateWithDict({'UprevvedChrome': True})
def _BuildRootGitCleanup(self): logging.info('Cleaning up buildroot git repositories.') # Run git gc --auto --prune=all on all repos in CleanUpStage commands.BuildRootGitCleanup(self._build_root, prune_all=True)