diff options
author | Yu-Ju Hong <yjhong@chromium.org> | 2013-11-20 11:44:23 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-11-21 09:09:29 +0000 |
commit | 6e9335f9575319b1835f3b1d5ad94c8b567b2e08 (patch) | |
tree | 422dcda40deec47c229dc9e3e949e1756dd40982 /licensing | |
parent | 66059ed0c74f119295451cfae89394fd94045a06 (diff) | |
download | chromite-6e9335f9575319b1835f3b1d5ad94c8b567b2e08.tar.gz |
licensing: check whether a license exists from inside and outside chroot
Allow calling of FindLicenseType() from inside and outside chroot. An
example usage is to add presubmission check of license-existence,
which is run from outside chroot.
BUG=chromium:318364
TEST=Invoke the class methods from inside and outside chroot.
Change-Id: Ia88e66571e29749d85f69b604ab83d5054b51a8d
Reviewed-on: https://chromium-review.googlesource.com/177398
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Yu-Ju Hong <yjhong@chromium.org>
Tested-by: Yu-Ju Hong <yjhong@chromium.org>
Diffstat (limited to 'licensing')
-rw-r--r-- | licensing/licenses.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/licensing/licenses.py b/licensing/licenses.py index 16a72188e..23d0e47a6 100644 --- a/licensing/licenses.py +++ b/licensing/licenses.py @@ -72,6 +72,7 @@ import logging import os import re +from chromite.buildbot import constants from chromite.buildbot import portage_utilities from chromite.lib import commandline from chromite.lib import cros_build_lib @@ -81,19 +82,22 @@ from chromite.lib import osutils debug = False STOCK_LICENSE_DIRS = [ - os.path.expanduser('~/trunk/src/third_party/portage/licenses'), - os.path.expanduser('~/trunk/src/third_party/portage-stable/licenses'), + os.path.join(constants.SOURCE_ROOT, 'src/third_party/portage/licenses'), + os.path.join(constants.SOURCE_ROOT, + 'src/third_party/portage-stable/licenses'), ] # There are licenses for custom software we got and isn't part of # upstream gentoo. CUSTOM_LICENSE_DIRS = [ - os.path.expanduser('~/trunk/src/third_party/chromiumos-overlay/licenses'), + os.path.join(constants.SOURCE_ROOT, + 'src/third_party/chromiumos-overlay/licenses'), ] -COPYRIGHT_ATTRIBUTION_DIR = \ - os.path.expanduser( - '~/trunk/src/third_party/chromiumos-overlay/licenses/copyright-attribution') +COPYRIGHT_ATTRIBUTION_DIR = ( + os.path.join( + constants.SOURCE_ROOT, + 'src/third_party/chromiumos-overlay/licenses/copyright-attribution')) # Virtual packages don't need to have a license and often don't, so we skip them # chromeos-base contains google platform packages that are covered by the @@ -841,7 +845,7 @@ class Licensing(object): self.packages[pkg.fullnamerev] = pkg @staticmethod - def _FindLicenseType(license_name): + def FindLicenseType(license_name): """Says if a license is stock Gentoo, custom, or doesn't exist.""" for directory in STOCK_LICENSE_DIRS: @@ -870,7 +874,7 @@ to third_party/chromiumos-overlay/licenses/""" % ) @staticmethod - def _ReadSharedLicense(license_name): + def ReadSharedLicense(license_name): """Read and return stock or cust license file specified in an ebuild.""" license_path = None @@ -919,7 +923,7 @@ to third_party/chromiumos-overlay/licenses/""" % # sln: shared license name. for sln in package.license_names: # Says whether it's a stock gentoo or custom license. - license_type = self._FindLicenseType(sln) + license_type = self.FindLicenseType(sln) license_pointers.append( "<li><a href='#%s'>%s License %s</a></li>" % ( sln, license_type, sln)) @@ -961,8 +965,8 @@ to third_party/chromiumos-overlay/licenses/""" % pkg_fullnamerev = self.licenses[sln][0] logging.info("Collapsing shared license %s into single use license " "(only used by %s)", sln, pkg_fullnamerev) - license_type = self._FindLicenseType(sln) - license_txt = self._ReadSharedLicense(sln) + license_type = self.FindLicenseType(sln) + license_txt = self.ReadSharedLicense(sln) single_license = "%s License %s:\n\n%s" % (license_type, sln, license_txt) pkg = self.packages[pkg_fullnamerev] @@ -983,8 +987,8 @@ to third_party/chromiumos-overlay/licenses/""" % for license_name in self.sorted_licenses: env = { 'license_name': license_name, - 'license': cgi.escape(self._ReadSharedLicense(license_name)), - 'license_type': self._FindLicenseType(license_name), + 'license': cgi.escape(self.ReadSharedLicense(license_name)), + 'license_type': self.FindLicenseType(license_name), 'license_packages': ' '.join(self.LicensedPackages(license_name)), } licenses_txt += [self.EvaluateTemplate(license_template, env)] |