mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-26 08:01:14 +02:00
Undo all the manifest logic from cbuildbot.
We also print to /dev/stderr directly to avoid flushing issues which have been occassionally given us broken manifests printed out Change-Id: I97819bbc31142432aa5ef926f99f2c4f90fd50ef BUG=chromium-os:9714 TEST=Ran cbuildbot through sync Review URL: http://codereview.chromium.org/5888003
This commit is contained in:
parent
9b0127c6f5
commit
d75d3b43c8
@ -87,6 +87,8 @@ def RepoSync(buildroot, retries=_DEFAULT_RETRIES):
|
|||||||
Warning('CBUILDBOT -- Retries exhausted')
|
Warning('CBUILDBOT -- Retries exhausted')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
RunCommand(['repo', 'manifest', '-r', '-o', '/dev/stderr'], cwd=buildroot)
|
||||||
|
|
||||||
# =========================== Command Helpers =================================
|
# =========================== Command Helpers =================================
|
||||||
|
|
||||||
def _GetAllGitRepos(buildroot, debug=False):
|
def _GetAllGitRepos(buildroot, debug=False):
|
||||||
@ -291,32 +293,6 @@ def _WipeOldOutput(buildroot):
|
|||||||
RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
|
RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
|
||||||
|
|
||||||
|
|
||||||
def _GetChromeOSVersion(buildroot):
|
|
||||||
"""Returns the tuple version of the Chrome OS version of the buildroot."""
|
|
||||||
cwd = os.path.join(buildroot, 'src', 'third_party', 'chromiumos-overlay',
|
|
||||||
'chromeos', 'config')
|
|
||||||
version_cmd = './chromeos_version.sh'
|
|
||||||
output = RunCommand(version_cmd, cwd=cwd, redirect_stdout=True,
|
|
||||||
redirect_stderr=True)
|
|
||||||
version_re = re.compile('\s+CHROMEOS_VERSION_STRING='
|
|
||||||
'(\d+)\.(\d+)\.(\d+)\.(\w+)')
|
|
||||||
for line in output.splitlines():
|
|
||||||
match = version_re.match(line)
|
|
||||||
if match:
|
|
||||||
return match.group(1), match.group(2), match.group(3), match.group(4)
|
|
||||||
|
|
||||||
raise Exception('Chrome OS version not found.')
|
|
||||||
|
|
||||||
|
|
||||||
def _GetManifestPath(buildroot):
|
|
||||||
"""Returns the relative path that a manifest should be saved into."""
|
|
||||||
version_tuple = _GetChromeOSVersion(buildroot)
|
|
||||||
(major, minor, branch, patch) = version_tuple
|
|
||||||
relative_path = os.path.join('.'.join([major, minor]),
|
|
||||||
'%s.xml' % '.'.join(version_tuple))
|
|
||||||
return relative_path
|
|
||||||
|
|
||||||
|
|
||||||
# =========================== Main Commands ===================================
|
# =========================== Main Commands ===================================
|
||||||
|
|
||||||
|
|
||||||
@ -345,36 +321,6 @@ def _IncrementalCheckout(buildroot, retries=_DEFAULT_RETRIES):
|
|||||||
RepoSync(buildroot, retries)
|
RepoSync(buildroot, retries)
|
||||||
|
|
||||||
|
|
||||||
def _DumpManifest(buildroot, url):
|
|
||||||
"""Stores the manifest in the public | private overlay depending on url."""
|
|
||||||
public_overlay = PUBLIC_OVERLAY % {'buildroot': buildroot}
|
|
||||||
private_overlay = PRIVATE_OVERLAY % {'buildroot': buildroot}
|
|
||||||
if url.endswith('manifest-internal'):
|
|
||||||
overlay = PRIVATE_OVERLAY % {'buildroot': buildroot}
|
|
||||||
else:
|
|
||||||
overlay = PUBLIC_OVERLAY % {'buildroot': buildroot}
|
|
||||||
|
|
||||||
# Generate paths for manifests.
|
|
||||||
relative_path = _GetManifestPath(buildroot)
|
|
||||||
manifest_path = os.path.join(overlay, 'manifests', relative_path)
|
|
||||||
symlink_path = os.path.join(overlay, 'manifests', 'LATEST')
|
|
||||||
if not os.path.isdir(os.path.dirname(manifest_path)):
|
|
||||||
os.makedirs(os.path.dirname(manifest_path))
|
|
||||||
|
|
||||||
# Dump the manifest and create a symlink to it.
|
|
||||||
RunCommand(['repo', 'manifest', '-r', '-o', manifest_path], cwd=buildroot)
|
|
||||||
if os.path.exists(symlink_path):
|
|
||||||
os.unlink(symlink_path)
|
|
||||||
|
|
||||||
os.symlink(relative_path, symlink_path)
|
|
||||||
|
|
||||||
# Add it to git and print it to stderr.
|
|
||||||
RunCommand(['git', 'add', os.path.join('manifests', relative_path)],
|
|
||||||
cwd=overlay)
|
|
||||||
RunCommand(['git', 'add', os.path.join('manifests', 'LATEST')], cwd=overlay)
|
|
||||||
_PrintFile(manifest_path)
|
|
||||||
|
|
||||||
|
|
||||||
def _MakeChroot(buildroot):
|
def _MakeChroot(buildroot):
|
||||||
"""Wrapper around make_chroot."""
|
"""Wrapper around make_chroot."""
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
@ -730,9 +676,6 @@ def main():
|
|||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
Die('Missing overlay: %s' % path)
|
Die('Missing overlay: %s' % path)
|
||||||
|
|
||||||
if not options.chrome_rev:
|
|
||||||
_DumpManifest(buildroot, options.url)
|
|
||||||
|
|
||||||
if not os.path.isdir(chroot_path):
|
if not os.path.isdir(chroot_path):
|
||||||
_MakeChroot(buildroot)
|
_MakeChroot(buildroot)
|
||||||
|
|
||||||
|
@ -232,68 +232,6 @@ class CBuildBotTest(mox.MoxTestBase):
|
|||||||
binhosts)
|
binhosts)
|
||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def testGetChromeOSVersion(self):
|
|
||||||
"""Tests that we can parse the correct chromeos version using method."""
|
|
||||||
fake_data = '\n'.join(['ChromeOS version information:',
|
|
||||||
' SOME_OTHER_DATA=blah',
|
|
||||||
' CHROMEOS_VERSION_STRING=9.0.232.1',
|
|
||||||
' CHROMEOS_VERSION_CODENAME=test-bot',
|
|
||||||
])
|
|
||||||
cbuildbot.RunCommand('./chromeos_version.sh',
|
|
||||||
cwd='src/scripts',
|
|
||||||
redirect_stderr=True,
|
|
||||||
redirect_stdout=True).AndReturn(fake_data)
|
|
||||||
self.mox.ReplayAll()
|
|
||||||
return_tuple = cbuildbot._GetChromeOSVersion('')
|
|
||||||
self.assertEquals('.'.join(return_tuple), '9.0.232.1')
|
|
||||||
self.mox.VerifyAll()
|
|
||||||
|
|
||||||
def testGetManifestPath(self):
|
|
||||||
"""Tests whether our logic to get the manifest path is correct."""
|
|
||||||
self.mox.StubOutWithMock(cbuildbot, '_GetChromeOSVersion')
|
|
||||||
return_tuple = cbuildbot._GetChromeOSVersion('').AndReturn(
|
|
||||||
('9', '0', '232', '1'))
|
|
||||||
self.mox.ReplayAll()
|
|
||||||
relative_path = cbuildbot._GetManifestPath('')
|
|
||||||
self.assertEquals(relative_path, '9.0/9.0.232.1.xml')
|
|
||||||
self.mox.VerifyAll()
|
|
||||||
|
|
||||||
def _CommonManifestTest(self, url, overlay_no_buildroot):
|
|
||||||
"""Common method for dump manifest tests."""
|
|
||||||
self.mox.StubOutWithMock(cbuildbot, '_GetManifestPath')
|
|
||||||
self.mox.StubOutWithMock(shutil, 'copy')
|
|
||||||
self.mox.StubOutWithMock(os, 'symlink')
|
|
||||||
temp_root = tempfile.mkdtemp('_unittest')
|
|
||||||
|
|
||||||
overlay = overlay_no_buildroot % {'buildroot': temp_root}
|
|
||||||
relative_path = 'fake/manifest/path.xml'
|
|
||||||
full_path = os.path.join(overlay, 'manifests', relative_path)
|
|
||||||
|
|
||||||
cbuildbot._GetManifestPath(temp_root).AndReturn(relative_path)
|
|
||||||
cbuildbot.RunCommand(['repo', 'manifest', '-r', '-o', full_path],
|
|
||||||
cwd=temp_root)
|
|
||||||
os.symlink(relative_path, os.path.join(overlay, 'manifests', 'LATEST'))
|
|
||||||
cbuildbot.RunCommand(['git', 'add', 'manifests/' + relative_path],
|
|
||||||
cwd=overlay)
|
|
||||||
cbuildbot.RunCommand(['git', 'add', 'manifests/LATEST'], cwd=overlay)
|
|
||||||
shutil.copy(full_path, '/dev/stderr')
|
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
|
||||||
cbuildbot._DumpManifest(temp_root, url)
|
|
||||||
self.mox.VerifyAll()
|
|
||||||
|
|
||||||
shutil.rmtree(temp_root)
|
|
||||||
|
|
||||||
def testDumpManifestPublic(self):
|
|
||||||
"""Tests whether we push the manifest to the public overlay correctly."""
|
|
||||||
self._CommonManifestTest('http://some_url/manifest',
|
|
||||||
cbuildbot.PUBLIC_OVERLAY)
|
|
||||||
|
|
||||||
def testDumpManifestPrivate(self):
|
|
||||||
"""Tests whether we push the manifest to the private overlay correctly."""
|
|
||||||
self._CommonManifestTest('http://some_url/manifest-internal',
|
|
||||||
cbuildbot.PRIVATE_OVERLAY)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user