示例#1
0
  def DetermineAndroidBranch(self, package):
    """Returns the Android branch in use by the active container ebuild.

    Workspace version of cbuildbot_run.DetermineAndroidBranch().

    Args:
      package: String name of Android package to get branch of.

    Returns:
      String with the android container branch name.
    """
    ebuild_path = portage_util.FindEbuildForBoardPackage(
        package, self._current_board, buildroot=self._build_root)
    host_ebuild_path = path_util.FromChrootPath(ebuild_path,
                                                source_path=self._build_root)
    # We assume all targets pull from the same branch and that we always
    # have an ARM_TARGET or an X86_USERDEBUG_TARGET.
    targets = ['ARM_TARGET', 'X86_USERDEBUG_TARGET']
    ebuild_content = osutils.SourceEnvironment(host_ebuild_path, targets)
    logging.info('Got ebuild env: %s', ebuild_content)
    for target in targets:
      if target in ebuild_content:
        branch = re.search(r'(.*?)-linux-', ebuild_content[target])
        if branch is not None:
          return branch.group(1)
    raise cbuildbot_run.NoAndroidBranchError(
        'Android branch could not be determined for %s (ebuild empty?)' %
        ebuild_path)
示例#2
0
 def DetermineAndroidBranch(self, board):
     """Returns the Android branch in use by the active container ebuild."""
     try:
         android_package = self.DetermineAndroidPackage(board)
     except cros_build_lib.RunCommandError:
         raise NoAndroidBranchError(
             'Android branch could not be determined for %s' % board)
     if not android_package:
         raise NoAndroidBranchError(
             'Android branch could not be determined for %s (no package?)' %
             board)
     ebuild_path = portage_util.FindEbuildForBoardPackage(
         android_package, board)
     host_ebuild_path = path_util.FromChrootPath(ebuild_path)
     # We assume all targets pull from the same branch and that we always
     # have at least one of the following targets.
     targets = constants.ANDROID_ALL_BUILD_TARGETS
     ebuild_content = osutils.SourceEnvironment(host_ebuild_path, targets)
     for target in targets:
         if target in ebuild_content:
             branch = re.search(r'(.*?)-linux-', ebuild_content[target])
             if branch is not None:
                 return branch.group(1)
     raise NoAndroidBranchError(
         'Android branch could not be determined for %s (ebuild empty?)' %
         board)
def main(argv):
    parser = get_parser()
    options = parser.parse_args(argv)
    options.Freeze()

    board = options.board
    package = options.package
    ebuild_path = portage_util.FindEbuildForBoardPackage(package, board)
    if not ebuild_path:
        cros_build_lib.Die('Could not find package %s for board %s.', package,
                           board)
    logging.info('Found corresponding ebuild at: %s', ebuild_path)
    ebuild = portage_util.EBuild(ebuild_path)

    start_date = options.start_date
    end_date = options.end_date
    if start_date and end_date and start_date > end_date:
        cros_build_lib.Die('Start date must be before end date.')

    ebuild_commits = get_directory_commits(os.path.dirname(ebuild.ebuild_path),
                                           start_date=start_date,
                                           end_date=end_date)
    logging.info('Found %d commits for ebuild.', len(ebuild_commits))

    ebuild_uprev_commits = get_uprev_commits(ebuild_commits)
    ebuild_uprev_commit_count = len(ebuild_uprev_commits)
    logging.info('%d of those commits were uprevs.', ebuild_uprev_commit_count)
    if ebuild_uprev_commit_count < 2:
        cros_build_lib.Die(
            'Alas, you need at least 2 uprevs to compute uprev frequency. '
            'Try setting a larger time range?', ebuild_uprev_commit_count)

    ebuild_uprev_timestamps = get_commit_timestamps(ebuild_uprev_commits)
    average_delta_days = get_average_timestamp_delta_days(
        ebuild_uprev_timestamps)

    logging.info('Package %s for %s was upreved every %.2f days on average.',
                 ebuild.package, board, average_delta_days)
示例#4
0
def determine_android_branch(board):
    """Returns the Android branch in use by the active container ebuild."""
    try:
        android_package = determine_android_package(board)
    except cros_build_lib.RunCommandError:
        raise NoAndroidBranchError(
            'Android branch could not be determined for %s' % board)
    if not android_package:
        return None
    ebuild_path = portage_util.FindEbuildForBoardPackage(
        android_package, board)
    # We assume all targets pull from the same branch and that we always
    # have an ARM_TARGET, ARM_USERDEBUG_TARGET, or an X86_USERDEBUG_TARGET.
    targets = ['ARM_TARGET', 'ARM_USERDEBUG_TARGET', 'X86_USERDEBUG_TARGET']
    ebuild_content = osutils.SourceEnvironment(ebuild_path, targets)
    for target in targets:
        if target in ebuild_content:
            branch = re.search(r'(.*?)-linux-', ebuild_content[target])
            if branch is not None:
                return branch.group(1)
    raise NoAndroidBranchError(
        'Android branch could not be determined for %s (ebuild empty?)' %
        board)