Exemplo n.º 1
0
    def _ExtractOverlays(self):
        """Extracts list of overlays into class."""
        overlays = portage_utilities.FindOverlays(
            self._build_config['overlays'], buildroot=self._build_root)
        push_overlays = portage_utilities.FindOverlays(
            self._build_config['push_overlays'], buildroot=self._build_root)

        # Sanity checks.
        # We cannot push to overlays that we don't rev.
        assert set(push_overlays).issubset(set(overlays))
        # Either has to be a master or not have any push overlays.
        assert self._build_config['master'] or not push_overlays

        return overlays, push_overlays
    def testUpdateCommitHashesForChanges(self):
        """Tests that we can update the commit hashes for changes correctly."""
        cls = portage_utilities.EBuild
        ebuild1 = self.mox.CreateMock(cls)
        ebuild1.ebuild_path = 'public_overlay/ebuild.ebuild'
        ebuild1.package = 'test/project'

        self.mox.StubOutWithMock(portage_utilities, 'FindOverlays')
        self.mox.StubOutWithMock(cls, '_GetEBuildProjects')
        self.mox.StubOutWithMock(cls, '_GetSHA1ForProject')
        self.mox.StubOutWithMock(cls, 'UpdateEBuild')
        self.mox.StubOutWithMock(cls, 'CommitChange')
        self.mox.StubOutWithMock(cls, 'GitRepoHasChanges')

        build_root = 'fakebuildroot'
        overlays = ['public_overlay']
        changes = ['fake change']
        projects = ['fake_project1', 'fake_project2']
        project_ebuilds = {ebuild1: projects}
        portage_utilities.FindOverlays(
            constants.BOTH_OVERLAYS, buildroot=build_root).AndReturn(overlays)
        cls._GetEBuildProjects(build_root, overlays,
                               changes).AndReturn(project_ebuilds)
        for i, p in enumerate(projects):
            cls._GetSHA1ForProject(mox.IgnoreArg(),
                                   p).InAnyOrder().AndReturn(str(i))
        cls.UpdateEBuild(ebuild1.ebuild_path,
                         dict(CROS_WORKON_COMMIT='("0" "1")'))
        cls.GitRepoHasChanges('public_overlay').AndReturn(True)
        cls.CommitChange(mox.IgnoreArg(), overlay='public_overlay')
        self.mox.ReplayAll()
        cls.UpdateCommitHashesForChanges(changes, build_root)
        self.mox.VerifyAll()
 def setUp(self):
     """Fetch all overlays."""
     self.overlays = {}
     for b in (None, self.FAKE, self.MARIO):
         self.overlays[b] = d = {}
         for o in (self.PRIVATE, self.PUBLIC, self.BOTH, None):
             d[o] = portage_utilities.FindOverlays(o, b,
                                                   constants.SOURCE_ROOT)
Exemplo n.º 4
0
def GetToolchainsForBoard(board):
  """Get a list of toolchain tuples for a given board name

  returns the list of toolchain tuples for the given board
  """
  overlays = portage_utilities.FindOverlays(
      constants.BOTH_OVERLAYS, None if board in ('all', 'sdk') else board)
  toolchains = GetTuplesForOverlays(overlays)
  if board == 'sdk':
    toolchains = FilterToolchains(toolchains, 'sdk', True)
  return toolchains
Exemplo n.º 5
0
def GetBoardOverlay(build_path, target):
  """Get the path to the board variant.
   Args:
     build_path: The path to the root of the build directory
     target: The target board as a BuildTarget object.
   Returns:
     The last overlay configured for the given board as a string.
  """
  board = target.board_variant
  overlays = portage_utilities.FindOverlays(constants.BOTH_OVERLAYS, board,
                                            buildroot=build_path)
  # We only care about the last entry.
  return overlays[-1]
Exemplo n.º 6
0
 def testFindWorkonProjects(self):
     """Test if we can find the list of workon projects."""
     power_manager = 'chromeos-base/power_manager'
     power_manager_project = 'chromiumos/platform/power_manager'
     kernel = 'sys-kernel/chromeos-kernel'
     kernel_project = 'chromiumos/third_party/kernel'
     matches = [([power_manager], set([power_manager_project])),
                ([kernel], set([kernel_project])),
                ([power_manager,
                  kernel], set([power_manager_project, kernel_project]))]
     if portage_utilities.FindOverlays(constants.BOTH_OVERLAYS):
         for packages, projects in matches:
             self.assertEquals(
                 projects, portage_utilities.FindWorkonProjects(packages))
def ListWorkonPackagesInfo(board, host):
    """Find the specified workon packages for the specified board.

  Args:
    board: The board to look at. If host is True, this should be set to None.
    host: Whether to look at workon packages for the host.

  Returns a list of unique packages being worked on.
  """
    # Import portage late so that this script can be imported outside the chroot.
    # pylint: disable=W0404
    import portage.const
    packages = ListWorkonPackages(board, host)
    if not packages:
        return []
    results = {}
    install_root = '/' if host else '/build/%s' % board
    vdb_path = os.path.join(install_root, portage.const.VDB_PATH)
    buildroot, both = constants.SOURCE_ROOT, constants.BOTH_OVERLAYS
    for overlay in portage_utilities.FindOverlays(both, board, buildroot):
        for filename, projects in portage_utilities.GetWorkonProjectMap(
                overlay, packages):
            # chromeos-base/power_manager/power_manager-9999
            # cp = chromeos-base/power_manager
            # cpv = chromeos-base/power_manager-9999
            category, pn, p = portage_utilities.SplitEbuildPath(filename)
            cp = '%s/%s' % (category, pn)
            cpv = '%s/%s' % (category, p)

            # Get the time the package finished building. TODO(build): Teach Portage
            # to store the time the package started building and use that here.
            pkg_mtime_file = os.path.join(vdb_path, cpv, 'BUILD_TIME')
            try:
                pkg_mtime = int(osutils.ReadFile(pkg_mtime_file))
            except EnvironmentError as ex:
                if ex.errno != errno.ENOENT:
                    raise
                pkg_mtime = 0

            # Get the modificaton time of the ebuild in the overlay.
            src_ebuild_mtime = os.lstat(os.path.join(overlay,
                                                     filename)).st_mtime

            # Write info into the results dictionary, overwriting any previous
            # values. This ensures that overlays override appropriately.
            results[cp] = WorkonPackageInfo(cp, pkg_mtime, projects,
                                            src_ebuild_mtime)

    return results.values()