From 61a543d901cd03ce2b517c5b69511296bba585c2 Mon Sep 17 00:00:00 2001 From: Scott Zawalski Date: Fri, 14 Jan 2011 15:06:43 -0800 Subject: [PATCH] Start using prebuilt.conf instead of make.conf this is an initial step to eventually moving entirely out of the overlay directory. The reason to do this now is to avoid devs having to remerge there make.conf changes while they are in flight. Add private support to prebuilt.py so we will update private overlays if we are internal and external if we are external. Update prebuilt_unittest to ensure we are returning the proper path if the private overlay exists. Also ensure we are returning the proper host path regardless. BUG=9919 TEST=unittest added for private case --- prebuilt.py | 19 +++++++++++++------ prebuilt_unittest.py | 35 ++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/prebuilt.py b/prebuilt.py index 707362b316..01f3d331ec 100755 --- a/prebuilt.py +++ b/prebuilt.py @@ -78,6 +78,7 @@ class UnknownBoardFormat(Exception): class GitPushFailed(Exception): """Raised when a git push failed after retry.""" + pass def UpdateLocalFile(filename, value, key='PORTAGE_BINHOST'): @@ -321,16 +322,22 @@ def GenerateUploadDict(base_local_path, base_remote_path, pkgs): return upload_files -def DetermineMakeConfFile(target): - """Determine the make.conf file that needs to be updated for prebuilts. +def DeterminePrebuiltConfFile(target): + """Determine the prebuilt.conf file that needs to be updated for prebuilts. Args: target: String representation of the board. This includes host and board targets Returns - A string path to a make.conf file to be updated. + A string path to a prebuilt.conf file to be updated. """ + overlay_base_dir = _BINHOST_BASE_DIR + # If this is a private checkout default to updating + # private overlays over public. + if os.path.exists(_PRIVATE_OVERLAY_DIR): + overlay_base_dir = _PRIVATE_OVERLAY_DIR + if _HOST_TARGET == target: # We are host. # Without more examples of hosts this is a kludge for now. @@ -340,10 +347,10 @@ def DetermineMakeConfFile(target): elif re.match('.*?_.*', target): # We are a board variant overlay_str = 'overlay-variant-%s' % target.replace('_', '-') - make_path = os.path.join(_BINHOST_BASE_DIR, overlay_str, 'make.conf') + make_path = os.path.join(overlay_base_dir, overlay_str, 'prebuilt.conf') elif re.match('.*?-\w+', target): overlay_str = 'overlay-%s' % target - make_path = os.path.join(_BINHOST_BASE_DIR, overlay_str, 'make.conf') + make_path = os.path.join(overlay_base_dir, overlay_str, 'prebuilt.conf') else: raise UnknownBoardFormat('Unknown format: %s' % target) @@ -410,7 +417,7 @@ def UploadPrebuilt(build_path, upload_location, version, binhost_base_url, package_path = os.path.join(board_path, 'packages') package_string = board url_suffix = _REL_BOARD_PATH % {'board': board, 'version': version} - git_file = os.path.join(build_path, DetermineMakeConfFile(board)) + git_file = os.path.join(build_path, DeterminePrebuiltConfFile(board)) binhost_conf = os.path.join(build_path, _BINHOST_CONF_DIR, 'target', '%s.conf' % board) remote_location = '%s/%s' % (upload_location.rstrip('/'), url_suffix) diff --git a/prebuilt_unittest.py b/prebuilt_unittest.py index a39aabcef6..1e0f2ea385 100755 --- a/prebuilt_unittest.py +++ b/prebuilt_unittest.py @@ -180,21 +180,42 @@ class TestPrebuilt(unittest.TestCase): files = {'test': '/uasd'} self.assertEqual(prebuilt.RemoteUpload(files), set([('test', '/uasd')])) - def testDetermineMakeConf(self): + def testDeterminePrebuiltConf(self): """Test the different known variants of boards for proper path discovery.""" targets = {'amd64': os.path.join(prebuilt._PREBUILT_MAKE_CONF['amd64']), 'x86-generic': os.path.join(prebuilt._BINHOST_BASE_DIR, - 'overlay-x86-generic', 'make.conf'), + 'overlay-x86-generic', 'prebuilt.conf'), 'arm-tegra2_vogue': os.path.join( prebuilt._BINHOST_BASE_DIR, - 'overlay-variant-arm-tegra2-vogue', 'make.conf'),} + 'overlay-variant-arm-tegra2-vogue', 'prebuilt.conf'),} for target in targets: - self.assertEqual(prebuilt.DetermineMakeConfFile(target), targets[target]) + self.assertEqual(prebuilt.DeterminePrebuiltConfFile(target), + targets[target]) - def testDetermineMakeConfGarbage(self): + def testPrivatePrebuiltConf(self): + """Test that we get a different path for private prebuilts""" + targets = {'amd64': os.path.join(prebuilt._PREBUILT_MAKE_CONF['amd64']), + 'x86-generic': os.path.join( + prebuilt._PRIVATE_OVERLAY_DIR, 'overlay-x86-generic', + 'prebuilt.conf'), + 'arm-tegra2_vogue': os.path.join( + prebuilt._PRIVATE_OVERLAY_DIR, + 'overlay-variant-arm-tegra2-vogue', 'prebuilt.conf'),} + + self.mox.StubOutWithMock(prebuilt.os.path, 'exists') + # Add mocks for every target we check + for mock_count in range(len(targets)): + prebuilt.os.path.exists(prebuilt._PRIVATE_OVERLAY_DIR).AndReturn(True) + self.mox.ReplayAll() + + for target in targets: + self.assertEqual(prebuilt.DeterminePrebuiltConfFile(target), + targets[target]) + + def testDeterminePrebuiltConfGarbage(self): """Ensure an exception is raised on bad input.""" - self.assertRaises(prebuilt.UnknownBoardFormat, prebuilt.DetermineMakeConfFile, - 'asdfasdf') + self.assertRaises(prebuilt.UnknownBoardFormat, + prebuilt.DeterminePrebuiltConfFile, 'asdfasdf') class TestPackagesFileFiltering(unittest.TestCase):