summaryrefslogtreecommitdiff
path: root/buildbot
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2014-05-13 16:18:26 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-15 21:05:43 +0000
commit46b44a4818f8e1899265e0965fd45d20210e8f5b (patch)
tree07f8a2cce28b6a458b2f99d2cf6a81a9d7be201e /buildbot
parent3f2c129ee4bd8644cf0365bd03b04418bc356c8c (diff)
downloadchromite-46b44a4818f8e1899265e0965fd45d20210e8f5b.tar.gz
Make GetWorkonProjectMap skip non-cros_workon ebuilds.
It's possible for a 9999 ebuild to not actually be cros_workon-able, ala the chromeos-chrome ebuild. This change factors the code which determines whether an ebuild is cros_workon-able, stable, or blacklisted out of the _ReadEBuild function into a new function called static method called Classify. It can be used on ebuild files without having to construct an EBuild class to represent them. GetWorkonProjectMap now uses that code to determine whether it has a real cros_workon ebuild before calling GetCrosWorkonVars on it. Also, the docstring in _ReadEBuild was incomplete since it didn't mention is_blacklisted. The comment was largely moved to the Classify funciton and was updated in the process. BUG=chromium:357653 TEST=Ran run_tests. Ran cros_workon-nyan chromeos-chrome and then ran cros_list_modified_packages (through the python interpreter) with a CL that makes GetCrosWorkonVars insist that CROS_WORKON_PRJECT is set. Before this change, cros_list_modified_packages would fail that check. After it, it skips the chromeos-chrome ebuild and completes successfully. Change-Id: Iee677aa55178ea2d1fe073e60fab1e7f671af70a Reviewed-on: https://chromium-review.googlesource.com/199643 Reviewed-by: David James <davidjames@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org>
Diffstat (limited to 'buildbot')
-rw-r--r--buildbot/portage_utilities.py42
1 files changed, 30 insertions, 12 deletions
diff --git a/buildbot/portage_utilities.py b/buildbot/portage_utilities.py
index 2221e8f6a..2c282c14d 100644
--- a/buildbot/portage_utilities.py
+++ b/buildbot/portage_utilities.py
@@ -314,26 +314,36 @@ class EBuild(object):
self.is_blacklisted = False
self._ReadEBuild(path)
- def _ReadEBuild(self, path):
- """Determine the settings of `is_workon` and `is_stable`.
-
- `is_workon` is determined by whether the ebuild inherits from
- the 'cros-workon' eclass. `is_stable` is determined by whether
- there's a '~' in the KEYWORDS setting in the ebuild.
+ @staticmethod
+ def Classify(ebuild_path):
+ """Return whether this ebuild is workon, stable, and/or blacklisted
- This function is separate from __init__() to allow unit tests to
- stub it out.
+ workon is determined by whether the ebuild inherits from the
+ 'cros-workon' eclass. stable is determined by whether there's a '~'
+ in the KEYWORDS setting in the ebuild. An ebuild is considered blacklisted
+ if a line in it starts with 'CROS_WORKON_BLACKLIST='
"""
- for line in fileinput.input(path):
+ is_workon = False
+ is_stable = False
+ is_blacklisted = False
+ for line in fileinput.input(ebuild_path):
if line.startswith('inherit ') and 'cros-workon' in line:
- self.is_workon = True
+ is_workon = True
elif line.startswith('KEYWORDS='):
for keyword in line.split('=', 1)[1].strip("\"'").split():
if not keyword.startswith('~') and keyword != '-*':
- self.is_stable = True
+ is_stable = True
elif line.startswith('CROS_WORKON_BLACKLIST='):
- self.is_blacklisted = True
+ is_blacklisted = True
fileinput.close()
+ return is_workon, is_stable, is_blacklisted
+
+ def _ReadEBuild(self, path):
+ """Determine the settings of `is_workon`, `is_stable` and is_blacklisted
+
+ These are determined using the static Classify function.
+ """
+ self.is_workon, self.is_stable, self.is_blacklisted = EBuild.Classify(path)
@staticmethod
def GetCrosWorkonVars(ebuild_path, pkg_name):
@@ -456,6 +466,10 @@ class EBuild(object):
if not os.path.exists(vers_script):
return default
+ if not self.is_workon:
+ raise EbuildFormatIncorrectException(self._ebuild_path_no_version,
+ "Package has a chromeos-version.sh script but is not workon-able.")
+
srcdirs = self.GetSourcePath(srcroot, manifest)[1]
# The chromeos-version script will output a usable raw version number,
@@ -790,11 +804,15 @@ def GetWorkonProjectMap(overlay, subdirectories):
given overlay under the given subdirectories.
"""
# Search ebuilds for project names, ignoring non-existent directories.
+ # Also filter out ebuilds which are not cros_workon.
for subdir in subdirectories:
for root, _dirs, files in os.walk(os.path.join(overlay, subdir)):
for filename in files:
if filename.endswith('-9999.ebuild'):
full_path = os.path.join(root, filename)
+ is_workon = EBuild.Classify(full_path)[0]
+ if not is_workon:
+ continue
pkg_name = os.path.basename(root)
_, projects, _ = EBuild.GetCrosWorkonVars(full_path, pkg_name)
relpath = os.path.relpath(full_path, start=overlay)