mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 22:51:03 +02:00
Add support to pushing unstable changes for the chrome pfq.
This specifically gets the pfq one step closer to being completely ready to rev. We add --noprebuilts for the chrome pfq as its not ready to host prebuilts and instead we push unstable ebuilds. Anush noticed an Anush today where we are revving even when we don't change, and I've addressed this also in this CL. Specifically: 1) Sort in cbuildbot long options by long format 2) Add --noprebuilts so that the Chrome PFQ can use this for now. 3) Fixed a unittest that had broken in a previous CL for cros_mark_chrome_as_stable. 4) Add ability for chrome to only rev if something really has changed: -- This means, if the new ebuild either: -- doesn't have the exact same chrome_version -- or diff -Bu (actual diff) between last ebuild and new ebuild isn't the same (i.e. detecting a 9999 change or different CROS_SVN_COMMIT) Change-Id: I9b289c2168d6868299573f5d7c7a676380ee497e BUG=chromium-os:8693 TEST=Ran unittests (cbuildbot, cros_mark_*) and ran cbuildbot with new chrome pfq items. Review URL: http://codereview.chromium.org/5783001
This commit is contained in:
parent
c663f209f7
commit
d8a0a57c30
@ -416,7 +416,8 @@ def _Build(buildroot, emptytree):
|
||||
def _BuildChrome(buildroot, board, chrome_atom_to_build):
|
||||
"""Wrapper for emerge call to build Chrome."""
|
||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||
RunCommand(['emerge-%s' % board, '=%s' % chrome_atom_to_build],
|
||||
RunCommand(['ACCEPT_KEYWORDS="* ~*"', 'emerge-%s' % board,
|
||||
'=%s' % chrome_atom_to_build],
|
||||
cwd=cwd, enter_chroot=True)
|
||||
|
||||
|
||||
@ -641,6 +642,8 @@ def main():
|
||||
# Parse options
|
||||
usage = "usage: %prog [options] cbuildbot_config"
|
||||
parser = optparse.OptionParser(usage=usage)
|
||||
parser.add_option('-a', '--acl', default='private',
|
||||
help='ACL to set on GSD archives')
|
||||
parser.add_option('-r', '--buildroot',
|
||||
help='root directory where build occurs', default=".")
|
||||
parser.add_option('-n', '--buildnumber',
|
||||
@ -649,30 +652,30 @@ def main():
|
||||
dest='chrome_rev',
|
||||
help=('Chrome_rev of type [tot|latest_release|'
|
||||
'sticky_release]'))
|
||||
parser.add_option('-f', '--revisionfile',
|
||||
help='file where new revisions are stored')
|
||||
parser.add_option('-g', '--gsutil', default='', help='Location of gsutil')
|
||||
parser.add_option('-c', '--gsutil_archive', default='',
|
||||
help='Datastore archive location')
|
||||
parser.add_option('--clobber', action='store_true', dest='clobber',
|
||||
default=False,
|
||||
help='Clobbers an old checkout before syncing')
|
||||
parser.add_option('--debug', action='store_true', dest='debug',
|
||||
default=False,
|
||||
help='Override some options to run as a developer.')
|
||||
parser.add_option('--noprebuilts', action='store_false', dest='prebuilts',
|
||||
help="Don't upload prebuilts.")
|
||||
parser.add_option('--nosync', action='store_false', dest='sync',
|
||||
default=True,
|
||||
help="Don't sync before building.")
|
||||
parser.add_option('--notests', action='store_false', dest='tests',
|
||||
default=True,
|
||||
help='Override values from buildconfig and run no tests.')
|
||||
parser.add_option('-f', '--revisionfile',
|
||||
help='file where new revisions are stored')
|
||||
parser.add_option('-t', '--tracking-branch', dest='tracking_branch',
|
||||
default='cros/master', help='Run the buildbot on a branch')
|
||||
parser.add_option('-u', '--url', dest='url',
|
||||
default='http://git.chromium.org/git/manifest',
|
||||
help='Run the buildbot on internal manifest')
|
||||
parser.add_option('-g', '--gsutil', default='', help='Location of gsutil')
|
||||
parser.add_option('-c', '--gsutil_archive', default='',
|
||||
help='Datastore archive location')
|
||||
parser.add_option('-a', '--acl', default='private',
|
||||
help='ACL to set on GSD archives')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
@ -731,6 +734,10 @@ def main():
|
||||
if options.chrome_rev:
|
||||
chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch,
|
||||
options.chrome_rev)
|
||||
# If we found nothing to rev, we're done here.
|
||||
if not chrome_atom_to_build:
|
||||
return
|
||||
|
||||
elif buildconfig['uprev']:
|
||||
_UprevPackages(buildroot, tracking_branch, revisionfile,
|
||||
buildconfig['board'], rev_overlays)
|
||||
@ -768,7 +775,7 @@ def main():
|
||||
if buildconfig['master']:
|
||||
# Master bot needs to check if the other slaves completed.
|
||||
if cbuildbot_comm.HaveSlavesCompleted(config):
|
||||
if not options.debug:
|
||||
if not options.debug and options.prebuilts:
|
||||
_UploadPrebuilts(buildroot, board, buildconfig['rev_overlays'],
|
||||
[new_binhost])
|
||||
_UprevPush(buildroot, tracking_branch, buildconfig['board'],
|
||||
|
@ -109,8 +109,8 @@ def _GetLatestRelease(branch=None):
|
||||
return current_version.rstrip('/')
|
||||
|
||||
|
||||
def _GetStickyVersion(stable_ebuilds):
|
||||
"""Discovers the sticky version from the current stable_ebuilds."""
|
||||
def _GetStickyEBuild(stable_ebuilds):
|
||||
"""Returns the sticky ebuild."""
|
||||
sticky_ebuilds = []
|
||||
non_sticky_re = re.compile(_NON_STICKY_REGEX)
|
||||
for ebuild in stable_ebuilds:
|
||||
@ -122,7 +122,7 @@ def _GetStickyVersion(stable_ebuilds):
|
||||
elif len(sticky_ebuilds) > 1:
|
||||
Warning('More than one sticky ebuild found')
|
||||
|
||||
return cros_mark_as_stable.BestEBuild(sticky_ebuilds).chrome_version
|
||||
return cros_mark_as_stable.BestEBuild(sticky_ebuilds)
|
||||
|
||||
|
||||
class ChromeEBuild(cros_mark_as_stable.EBuild):
|
||||
@ -203,7 +203,7 @@ def FindChromeUprevCandidate(stable_ebuilds, chrome_rev, sticky_branch):
|
||||
candidates.append(ebuild)
|
||||
|
||||
elif chrome_rev == STICKY:
|
||||
chrome_branch_re = re.compile('%s\.\d+.*_rc.*' % sticky_branch)
|
||||
chrome_branch_re = re.compile('%s\..*' % sticky_branch)
|
||||
for ebuild in stable_ebuilds:
|
||||
if chrome_branch_re.search(ebuild.version):
|
||||
candidates.append(ebuild)
|
||||
@ -222,7 +222,8 @@ def FindChromeUprevCandidate(stable_ebuilds, chrome_rev, sticky_branch):
|
||||
|
||||
|
||||
def MarkChromeEBuildAsStable(stable_candidate, unstable_ebuild, chrome_rev,
|
||||
chrome_version, commit, overlay_dir):
|
||||
chrome_version, commit, overlay_dir,
|
||||
sticky_ebuild):
|
||||
"""Uprevs the chrome ebuild specified by chrome_rev.
|
||||
|
||||
This is the main function that uprevs the chrome_rev from a stable candidate
|
||||
@ -242,6 +243,7 @@ def MarkChromeEBuildAsStable(stable_candidate, unstable_ebuild, chrome_rev,
|
||||
chrome_version: The \d.\d.\d.\d version of Chrome.
|
||||
commit: Used with TIP_OF_TRUNK. The svn revision of chrome.
|
||||
overlay_dir: Path to the chromeos-chrome package dir.
|
||||
sticky_ebuild: EBuild class for the sticky ebuild.
|
||||
Returns:
|
||||
Full portage version atom (including rc's, etc) that was revved.
|
||||
"""
|
||||
@ -260,9 +262,21 @@ def MarkChromeEBuildAsStable(stable_candidate, unstable_ebuild, chrome_rev,
|
||||
new_ebuild_path = base_path + ('%s-r1.ebuild' % portage_suffix)
|
||||
|
||||
cros_mark_as_stable.EBuildStableMarker.MarkAsStable(
|
||||
unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit)
|
||||
unstable_ebuild.ebuild_path, new_ebuild_path, 'CROS_SVN_COMMIT', commit,
|
||||
make_stable=False)
|
||||
new_ebuild = ChromeEBuild(new_ebuild_path)
|
||||
if stable_candidate and (
|
||||
stable_candidate.chrome_version == new_ebuild.chrome_version):
|
||||
if 0 == RunCommand(['diff', '-Bu', stable_candidate.ebuild_path,
|
||||
new_ebuild_path],
|
||||
redirect_stderr=True,
|
||||
redirect_stdout=True,
|
||||
exit_code=True):
|
||||
os.unlink(new_ebuild_path)
|
||||
return None
|
||||
|
||||
RunCommand(['git', 'add', new_ebuild_path])
|
||||
if stable_candidate:
|
||||
if stable_candidate and stable_candidate != sticky_ebuild:
|
||||
RunCommand(['git', 'rm', stable_candidate.ebuild_path])
|
||||
|
||||
cros_mark_as_stable.EBuildStableMarker.CommitChange(
|
||||
@ -293,10 +307,10 @@ def main():
|
||||
commit_to_use = None
|
||||
|
||||
(unstable_ebuild, stable_ebuilds) = FindChromeCandidates(overlay_dir)
|
||||
sticky_version = _GetStickyVersion(stable_ebuilds)
|
||||
sticky_ebuild = _GetStickyEBuild(stable_ebuilds)
|
||||
sticky_version = sticky_ebuild.chrome_version
|
||||
sticky_branch = sticky_version.rpartition('.')[0]
|
||||
|
||||
|
||||
if chrome_rev == TIP_OF_TRUNK:
|
||||
version_to_uprev = _GetTipOfTrunkVersion()
|
||||
commit_to_use = _GetTipOfTrunkSvnRevision()
|
||||
@ -307,25 +321,23 @@ def main():
|
||||
|
||||
stable_candidate = FindChromeUprevCandidate(stable_ebuilds, chrome_rev,
|
||||
sticky_branch)
|
||||
# There are some cases we don't need to do anything. Check for them.
|
||||
if stable_candidate and (version_to_uprev == stable_candidate.chrome_version
|
||||
and not commit_to_use):
|
||||
Info('Found nothing to do for chrome_rev %s with version %s.' % (
|
||||
chrome_rev, version_to_uprev))
|
||||
else:
|
||||
os.chdir(overlay_dir)
|
||||
work_branch = cros_mark_as_stable.GitBranch(
|
||||
cros_mark_as_stable.STABLE_BRANCH_NAME, options.tracking_branch)
|
||||
work_branch.CreateBranch()
|
||||
try:
|
||||
chrome_version_atom = MarkChromeEBuildAsStable(
|
||||
stable_candidate, unstable_ebuild, chrome_rev, version_to_uprev,
|
||||
commit_to_use, overlay_dir)
|
||||
# Explicit print to communicate to caller.
|
||||
|
||||
os.chdir(overlay_dir)
|
||||
work_branch = cros_mark_as_stable.GitBranch(
|
||||
cros_mark_as_stable.STABLE_BRANCH_NAME, options.tracking_branch)
|
||||
work_branch.CreateBranch()
|
||||
try:
|
||||
chrome_version_atom = MarkChromeEBuildAsStable(
|
||||
stable_candidate, unstable_ebuild, chrome_rev, version_to_uprev,
|
||||
commit_to_use, overlay_dir, sticky_ebuild)
|
||||
# Explicit print to communicate to caller.
|
||||
if chrome_version_atom:
|
||||
print 'CHROME_VERSION_ATOM=%s' % chrome_version_atom
|
||||
except:
|
||||
else:
|
||||
work_branch.Delete()
|
||||
raise
|
||||
except:
|
||||
work_branch.Delete()
|
||||
raise
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -200,12 +200,12 @@ class CrosMarkChromeAsStable(mox.MoxTestBase):
|
||||
self.mox.VerifyAll()
|
||||
self.assertEqual('8.0.224.2', release)
|
||||
|
||||
def testStickyVersion(self):
|
||||
"""Tests if we can find the sticky version from our mock directories."""
|
||||
def testStickyEBuild(self):
|
||||
"""Tests if we can find the sticky ebuild from our mock directories."""
|
||||
stable_ebuilds = self._GetStableEBuilds()
|
||||
sticky_version = cros_mark_chrome_as_stable._GetStickyVersion(
|
||||
sticky_ebuild = cros_mark_chrome_as_stable._GetStickyEBuild(
|
||||
stable_ebuilds)
|
||||
self.assertEqual(sticky_version, self.sticky_version)
|
||||
self.assertEqual(sticky_ebuild.chrome_version, self.sticky_version)
|
||||
|
||||
def testChromeEBuildInit(self):
|
||||
"""Tests if the chrome_version is set correctly in a ChromeEBuild."""
|
||||
@ -231,6 +231,7 @@ class CrosMarkChromeAsStable(mox.MoxTestBase):
|
||||
'CommitChange')
|
||||
stable_candidate = cros_mark_chrome_as_stable.ChromeEBuild(old_ebuild_path)
|
||||
unstable_ebuild = cros_mark_chrome_as_stable.ChromeEBuild(self.unstable)
|
||||
sticky_ebuild = cros_mark_chrome_as_stable.ChromeEBuild(self.sticky)
|
||||
chrome_version = new_version
|
||||
commit = None
|
||||
overlay_dir = self.mock_chrome_dir
|
||||
@ -243,14 +244,14 @@ class CrosMarkChromeAsStable(mox.MoxTestBase):
|
||||
self.mox.ReplayAll()
|
||||
cros_mark_chrome_as_stable.MarkChromeEBuildAsStable(
|
||||
stable_candidate, unstable_ebuild, chrome_rev, chrome_version, commit,
|
||||
overlay_dir)
|
||||
overlay_dir, sticky_ebuild)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def testStickyMarkAsStable(self):
|
||||
"""Tests to see if we can mark chrome as stable for a new sticky release."""
|
||||
self._CommonMarkAsStableTest(cros_mark_chrome_as_stable.STICKY,
|
||||
self.sticky_new_rc_version, self.sticky_rc,
|
||||
self.sticky_new_rc, 'sticky_release')
|
||||
self.sticky_new_rc, 'stable_release')
|
||||
|
||||
def testLatestMarkAsStable(self):
|
||||
"""Tests to see if we can mark chrome for a latest release."""
|
||||
|
@ -396,7 +396,8 @@ class EBuildStableMarker(object):
|
||||
|
||||
@classmethod
|
||||
def MarkAsStable(cls, unstable_ebuild_path, new_stable_ebuild_path,
|
||||
commit_keyword, commit_value, redirect_file=None):
|
||||
commit_keyword, commit_value, redirect_file=None,
|
||||
make_stable=True):
|
||||
"""Static function that creates a revved stable ebuild.
|
||||
|
||||
This function assumes you have already figured out the name of the new
|
||||
@ -412,6 +413,7 @@ class EBuildStableMarker(object):
|
||||
stable.
|
||||
commit_value: Value to set the above keyword to.
|
||||
redirect_file: Optionally redirect output of new ebuild somewhere else.
|
||||
make_stable: Actually make the ebuild stable.
|
||||
"""
|
||||
shutil.copyfile(unstable_ebuild_path, new_stable_ebuild_path)
|
||||
for line in fileinput.input(new_stable_ebuild_path, inplace=1):
|
||||
@ -420,7 +422,10 @@ class EBuildStableMarker(object):
|
||||
redirect_file = sys.stdout
|
||||
if line.startswith('KEYWORDS'):
|
||||
# Actually mark this file as stable by removing ~'s.
|
||||
redirect_file.write(line.replace('~', ''))
|
||||
if make_stable:
|
||||
redirect_file.write(line.replace('~', ''))
|
||||
else:
|
||||
redirect_file.write(line)
|
||||
elif line.startswith('EAPI'):
|
||||
# Always add new commit_id after EAPI definition.
|
||||
redirect_file.write(line)
|
||||
|
Loading…
x
Reference in New Issue
Block a user