mirror of
https://github.com/flatcar/scripts.git
synced 2026-02-10 02:02:22 +01:00
Merge branch 'prebuilt'
This commit is contained in:
commit
11bc4c7213
19
prebuilt.py
19
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)
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user