コード例 #1
0
def FindChromeCandidates(package_dir):
    """Return a tuple of chrome's unstable ebuild and stable ebuilds.

  Args:
    package_dir: The path to where the package ebuild is stored.

  Returns:
    Tuple [unstable_ebuild, stable_ebuilds].

  Raises:
    Exception: if no unstable ebuild exists for Chrome.
  """
    stable_ebuilds = []
    unstable_ebuilds = []
    for path in [
            os.path.join(package_dir, entry)
            for entry in os.listdir(package_dir)
    ]:
        if path.endswith('.ebuild'):
            ebuild = ChromeEBuild(path)
            if not ebuild.chrome_version:
                logging.warning('Poorly formatted ebuild found at %s' % path)
            else:
                if '9999' in ebuild.version:
                    unstable_ebuilds.append(ebuild)
                else:
                    stable_ebuilds.append(ebuild)

    # Apply some sanity checks.
    if not unstable_ebuilds:
        raise Exception('Missing 9999 ebuild for %s' % package_dir)
    if not stable_ebuilds:
        logging.warning('Missing stable ebuild for %s' % package_dir)

    return portage_util.BestEBuild(unstable_ebuilds), stable_ebuilds
コード例 #2
0
def FindAndroidCandidates(package_dir):
    """Return a tuple of Android's unstable ebuild and stable ebuilds.

  Args:
    package_dir: The path to where the package ebuild is stored.

  Returns:
    Tuple [unstable_ebuild, stable_ebuilds].

  Raises:
    Exception: if no unstable ebuild exists for Android.
  """
    stable_ebuilds = []
    unstable_ebuilds = []
    for path in glob.glob(os.path.join(package_dir, '*.ebuild')):
        ebuild = portage_util.EBuild(path)
        if ebuild.version == '9999':
            unstable_ebuilds.append(ebuild)
        else:
            stable_ebuilds.append(ebuild)

    # Apply some sanity checks.
    if not unstable_ebuilds:
        raise Exception('Missing 9999 ebuild for %s' % package_dir)
    if not stable_ebuilds:
        logging.warning('Missing stable ebuild for %s' % package_dir)

    return portage_util.BestEBuild(unstable_ebuilds), stable_ebuilds
コード例 #3
0
def main(argv):
    parser = GetParser()
    options = parser.parse_args(argv)
    options.Freeze()

    overlay_dir = os.path.abspath(_OVERLAY_DIR % {'srcroot': options.srcroot})
    android_package_dir = os.path.join(overlay_dir, constants.ANDROID_CP)
    version_to_uprev = None
    subpaths = None

    (unstable_ebuild,
     stable_ebuilds) = FindAndroidCandidates(android_package_dir)

    if options.force_version:
        version_to_uprev = options.force_version
        subpaths = IsBuildIdValid(options.android_bucket_url,
                                  options.android_build_branch,
                                  version_to_uprev)
        if not subpaths:
            logging.error('Requested build %s is not valid' % version_to_uprev)
    else:
        version_to_uprev, subpaths = GetLatestBuild(
            options.android_bucket_url, options.android_build_branch)

    acls = MakeAclDict(android_package_dir)
    CopyToArcBucket(options.android_bucket_url, options.android_build_branch,
                    version_to_uprev, subpaths, options.arc_bucket_url, acls)

    stable_candidate = portage_util.BestEBuild(stable_ebuilds)

    if stable_candidate:
        logging.info('Stable candidate found %s' % stable_candidate.version)
    else:
        logging.info('No stable candidate found.')

    tracking_branch = 'remotes/m/%s' % os.path.basename(
        options.tracking_branch)
    existing_branch = git.GetCurrentBranch(android_package_dir)
    work_branch = cros_mark_as_stable.GitBranch(constants.STABLE_EBUILD_BRANCH,
                                                tracking_branch,
                                                android_package_dir)
    work_branch.CreateBranch()

    # In the case of uprevving overlays that have patches applied to them,
    # include the patched changes in the stabilizing branch.
    if existing_branch:
        git.RunGit(overlay_dir, ['rebase', existing_branch])

    android_version_atom = MarkAndroidEBuildAsStable(
        stable_candidate, unstable_ebuild, constants.ANDROID_PN,
        version_to_uprev, android_package_dir, options.android_build_branch,
        options.arc_bucket_url)
    if android_version_atom:
        if options.boards:
            cros_mark_as_stable.CleanStalePackages(options.srcroot,
                                                   options.boards.split(':'),
                                                   [android_version_atom])

        # Explicit print to communicate to caller.
        print('ANDROID_VERSION_ATOM=%s' % android_version_atom)
コード例 #4
0
def main(argv):
    parser = GetParser()
    options = parser.parse_args(argv)
    options.Freeze()

    overlay_dir = os.path.abspath(_OVERLAY_DIR % {'srcroot': options.srcroot})
    android_package_dir = os.path.join(overlay_dir, constants.ANDROID_CP)
    version_to_uprev = None

    (unstable_ebuild,
     stable_ebuilds) = FindAndroidCandidates(android_package_dir)
    acls = MakeAclDict(android_package_dir)
    # Mirror artifacts, i.e., images and some sdk tools (e.g., adb, aapt).
    version_to_uprev = MirrorArtifacts(options.android_bucket_url,
                                       options.android_build_branch,
                                       options.arc_bucket_url, acls,
                                       constants.ANDROID_BUILD_TARGETS,
                                       options.force_version)

    # Mirror GTS.
    MirrorArtifacts(options.android_bucket_url,
                    options.android_gts_build_branch, options.arc_bucket_url,
                    acls, constants.ANDROID_GTS_BUILD_TARGETS)

    stable_candidate = portage_util.BestEBuild(stable_ebuilds)

    if stable_candidate:
        logging.info('Stable candidate found %s' % stable_candidate.version)
    else:
        logging.info('No stable candidate found.')

    tracking_branch = 'remotes/m/%s' % os.path.basename(
        options.tracking_branch)
    existing_branch = git.GetCurrentBranch(android_package_dir)
    work_branch = cros_mark_as_stable.GitBranch(constants.STABLE_EBUILD_BRANCH,
                                                tracking_branch,
                                                android_package_dir)
    work_branch.CreateBranch()

    # In the case of uprevving overlays that have patches applied to them,
    # include the patched changes in the stabilizing branch.
    if existing_branch:
        git.RunGit(overlay_dir, ['rebase', existing_branch])

    android_version_atom = MarkAndroidEBuildAsStable(
        stable_candidate, unstable_ebuild, constants.ANDROID_PN,
        version_to_uprev, android_package_dir, options.android_build_branch,
        options.arc_bucket_url)
    if android_version_atom:
        if options.boards:
            cros_mark_as_stable.CleanStalePackages(options.srcroot,
                                                   options.boards.split(':'),
                                                   [android_version_atom])

        # Explicit print to communicate to caller.
        print('ANDROID_VERSION_ATOM=%s' % android_version_atom)
コード例 #5
0
def _GetStickyEBuild(stable_ebuilds):
    """Returns the sticky ebuild."""
    sticky_ebuilds = []
    non_sticky_re = re.compile(_NON_STICKY_REGEX)
    for ebuild in stable_ebuilds:
        if not non_sticky_re.match(ebuild.version):
            sticky_ebuilds.append(ebuild)

    if not sticky_ebuilds:
        raise Exception('No sticky ebuilds found')
    elif len(sticky_ebuilds) > 1:
        logging.warning('More than one sticky ebuild found')

    return portage_util.BestEBuild(sticky_ebuilds)
コード例 #6
0
def FindChromeUprevCandidate(stable_ebuilds, chrome_rev, sticky_branch):
    """Finds the Chrome uprev candidate for the given chrome_rev.

  Using the pre-flight logic, this means the stable ebuild you are uprevving
  from.  The difference here is that the version could be different and in
  that case we want to find it to delete it.

  Args:
    stable_ebuilds: A list of stable ebuilds.
    chrome_rev: The chrome_rev designating which candidate to find.
    sticky_branch: The the branch that is currently sticky with Major/Minor
      components.  For example: 9.0.553. Can be None but not if chrome_rev
      is CHROME_REV_STICKY.

  Returns:
    The EBuild, otherwise None if none found.
  """
    candidates = []
    if chrome_rev in [
            constants.CHROME_REV_LOCAL, constants.CHROME_REV_TOT,
            constants.CHROME_REV_SPEC
    ]:
        # These are labelled alpha, for historic reasons,
        # not just for the fun of confusion.
        chrome_branch_re = re.compile(r'%s.*_alpha.*' % _CHROME_VERSION_REGEX)
        for ebuild in stable_ebuilds:
            if chrome_branch_re.search(ebuild.version):
                candidates.append(ebuild)

    elif chrome_rev == constants.CHROME_REV_STICKY:
        assert sticky_branch is not None
        chrome_branch_re = re.compile(r'%s\..*' % sticky_branch)
        for ebuild in stable_ebuilds:
            if chrome_branch_re.search(ebuild.version):
                candidates.append(ebuild)

    else:
        chrome_branch_re = re.compile(r'%s.*_rc.*' % _CHROME_VERSION_REGEX)
        for ebuild in stable_ebuilds:
            if chrome_branch_re.search(ebuild.version):
                candidates.append(ebuild)

    if candidates:
        return portage_util.BestEBuild(candidates)
    else:
        return None