diff options
author | Ari Hausman-Cohen <arihc@google.com> | 2016-05-09 13:24:12 -0700 |
---|---|---|
committer | Ari Hausman-Cohen <arihc@google.com> | 2016-05-09 17:17:04 -0700 |
commit | 8d656f43fd2d2ff5f76edb41a21c52e70424e2fa (patch) | |
tree | 6d45d7fa479d6a4876576bd4138ca781a495ec6b | |
parent | 6655c6a4c1faa4730313197fa5e2dc5828d3a6a3 (diff) | |
download | bdk-8d656f43fd2d2ff5f76edb41a21c52e70424e2fa.tar.gz |
Replacing platform os & version with an OS object.
BUG: 28637861
Change-Id: I73fc9d7f32956f0b6b7c43d33ed62c4c435fafbb
TEST: unit tests pass, commands work.
-rw-r--r-- | cli/lib/bsp/manifest.py | 5 | ||||
-rw-r--r-- | cli/lib/bsp/manifest_stub.py | 11 | ||||
-rw-r--r-- | cli/lib/bsp/operating_system.py | 2 | ||||
-rw-r--r-- | cli/lib/bsp/operating_system_stub.py | 2 | ||||
-rw-r--r-- | cli/lib/commands/v2/environment/setup.py | 2 | ||||
-rw-r--r-- | cli/lib/core/build.py | 2 | ||||
-rw-r--r-- | cli/lib/core/image_build.py | 2 | ||||
-rw-r--r-- | cli/lib/core/image_build_unittest.py | 6 | ||||
-rw-r--r-- | cli/lib/core/provision_unittest.py | 6 | ||||
-rw-r--r-- | cli/lib/core/tool.py | 4 | ||||
-rw-r--r-- | cli/lib/core/tool_unittest.py | 2 | ||||
-rw-r--r-- | cli/lib/environment/sysroot_util.py | 4 | ||||
-rw-r--r-- | cli/lib/environment/sysroot_util_unittest.py | 8 | ||||
-rw-r--r-- | cli/lib/environment/toolchain_util.py | 2 | ||||
-rw-r--r-- | cli/lib/environment/toolchain_util_unittest.py | 2 | ||||
-rw-r--r-- | cli/lib/project/platform.py | 74 | ||||
-rw-r--r-- | cli/lib/project/platform_stub.py | 22 | ||||
-rw-r--r-- | cli/lib/project/platform_unittest.py | 33 | ||||
-rw-r--r-- | cli/lib/project/project_spec_unittest.py | 4 | ||||
-rw-r--r-- | cli/lib/project/target.py | 2 | ||||
-rw-r--r-- | cli/lib/selinux/policy.py | 6 |
21 files changed, 95 insertions, 106 deletions
diff --git a/cli/lib/bsp/manifest.py b/cli/lib/bsp/manifest.py index 66178cd..8910f6b 100644 --- a/cli/lib/bsp/manifest.py +++ b/cli/lib/bsp/manifest.py @@ -55,9 +55,8 @@ class Manifest(object): def __init__(self, packages, devices): self.packages = packages self.devices = devices - self.operating_systems = { - 'brillo': operating_system.init_default_operating_system() - } + default_os = operating_system.init_default_operating_system() + self.operating_systems = {default_os.name: default_os} @classmethod def from_dict(cls, dic): diff --git a/cli/lib/bsp/manifest_stub.py b/cli/lib/bsp/manifest_stub.py index b533b24..c474469 100644 --- a/cli/lib/bsp/manifest_stub.py +++ b/cli/lib/bsp/manifest_stub.py @@ -20,14 +20,19 @@ import error +from bsp import operating_system_stub + class StubManifest(object): from_json_devices = {} + operating_system = operating_system_stub.StubOperatingSystemModule() def __init__(self, devices): """devices should be {name: device}.""" self.devices = devices + default_os = self.operating_system.init_default_operating_system() + self.operating_systems = {default_os.name: default_os} def is_bsp_available(self, device): if not device in self.devices: @@ -50,5 +55,9 @@ class StubManifestModule(object): class UnknownBspError(Error): pass - def __init__(self): + def __init__(self, operating_system_module): self.Manifest = StubManifest + self.Manifest.operating_system = operating_system_module + + def Manifest(self, *args, **kwargs): + return StubManifest(*args, **kwargs) diff --git a/cli/lib/bsp/operating_system.py b/cli/lib/bsp/operating_system.py index 92b0f19..d672211 100644 --- a/cli/lib/bsp/operating_system.py +++ b/cli/lib/bsp/operating_system.py @@ -62,7 +62,7 @@ class OperatingSystem(object): version_path = self.path('tools', 'bdk', 'VERSION') try: with open(version_path) as f: - self._version = f.read() + self._version = f.read().strip() except IOError as e: raise VersionError(e) if not re.match(VERSION_RE, self._version): diff --git a/cli/lib/bsp/operating_system_stub.py b/cli/lib/bsp/operating_system_stub.py index 9a91ccb..2411291 100644 --- a/cli/lib/bsp/operating_system_stub.py +++ b/cli/lib/bsp/operating_system_stub.py @@ -22,7 +22,7 @@ import os class StubOperatingSystem(object): - def __init__(self, name, root, version='', available=False): + def __init__(self, name='', root='', version='', available=False): self.name = name self.root = root self.version = version diff --git a/cli/lib/commands/v2/environment/setup.py b/cli/lib/commands/v2/environment/setup.py index 0dece94..956916f 100644 --- a/cli/lib/commands/v2/environment/setup.py +++ b/cli/lib/commands/v2/environment/setup.py @@ -111,7 +111,7 @@ class Setup(clicommand.Command): 'STATIC_LIBRARIES') # TODO(b/27458309): determine an actual location for this. - board_packages = platform.os_path('device', + board_packages = platform.os.path('device', platform.device.vendor, platform.device.name, 'developer', diff --git a/cli/lib/core/build.py b/cli/lib/core/build.py index a05c881..561e195 100644 --- a/cli/lib/core/build.py +++ b/cli/lib/core/build.py @@ -52,7 +52,7 @@ def _GetBuildScript(platform, extra_make_args=None): if extra_make_args: make_args.extend(extra_make_args) - cmds = ['cd "{}"'.format(platform.os_path()), + cmds = ['cd "{}"'.format(platform.os.root), 'export OUT_DIR="{}"'.format(platform.build_cache), '. build/envsetup.sh', 'lunch "{}-{}"'.format(platform.device.name, platform.build_type), diff --git a/cli/lib/core/image_build.py b/cli/lib/core/image_build.py index 03e5c7c..ed18d81 100644 --- a/cli/lib/core/image_build.py +++ b/cli/lib/core/image_build.py @@ -366,7 +366,7 @@ def BuildImage(image_type, target, config): IMAGE_TYPES, image_type)) # Set some useful variables. platform = target.platform - build_tools = platform.os_path('build', 'tools', 'releasetools') + build_tools = platform.os.path('build', 'tools', 'releasetools') product_out = platform.product_out_cache host_arch = util.GetHostArch() host_tools = os.path.join(platform.build_cache, 'host', host_arch, 'bin') diff --git a/cli/lib/core/image_build_unittest.py b/cli/lib/core/image_build_unittest.py index 1807520..f5c8e6b 100644 --- a/cli/lib/core/image_build_unittest.py +++ b/cli/lib/core/image_build_unittest.py @@ -43,7 +43,7 @@ class TestData(object): _BRILLO_VERSION = '9.9' _ARTIFACT_CACHE_DIR = '/product/artifacts' _METADATA_CACHE_DIR = '/product/metadata' - _OS_DIR = '/bing/bong' + _OS_ROOT = '/bing/bong' _PLATFORM_DIR = '/foo/bar' _PRODUCT_DIR = '/bip/boop' _IMAGE_OUT_DIR = '/baz/pop' @@ -80,7 +80,7 @@ class BuildImageBase(TestData): os_version=self._BRILLO_VERSION, device=self.device, build_cache=self._PLATFORM_DIR, product_out_cache=self._PRODUCT_DIR, - os_dir=self._OS_DIR) + os_root=self._OS_ROOT) self.target = target_stub.StubTarget(platform=self.platform) self.config = config_stub.StubConfig( artifact_cache=self._ARTIFACT_CACHE_DIR, @@ -112,7 +112,7 @@ class BuildImageBase(TestData): self.stub_os.path.join(platform_dir, 'host', self.stub_util.GetHostArch(), 'bin'), - self.platform.os_path('build', 'tools', 'releasetools')] + self.platform.os.path('build', 'tools', 'releasetools')] self.stub_os.path.should_exist += copy.deepcopy( self.stub_os.path.should_be_dir) diff --git a/cli/lib/core/provision_unittest.py b/cli/lib/core/provision_unittest.py index fc2e3b6..ccc8a0e 100644 --- a/cli/lib/core/provision_unittest.py +++ b/cli/lib/core/provision_unittest.py @@ -37,7 +37,7 @@ class ProvisionDeviceTest(unittest.TestCase): _CUSTOM_SYSTEM_IMAGE_PATH = os.path.join(_CUSTOM_SYSTEM_IMAGE_DIR, 'system.img') _HOST_ARCH = 'foo_arch' - _OS_DIR = '/os/tree' + _OS_ROOT = '/os/tree' _OS_VERSION = '55.55' _BUILD_TYPE = 'userdebug' @@ -74,7 +74,7 @@ class ProvisionDeviceTest(unittest.TestCase): board=self._BSP, os_version=self._OS_VERSION, build_cache=self._PLATFORM_BUILD_OUT, product_out_cache=self._PRODUCT_BUILD_OUT, - build_type=self._BUILD_TYPE, os_dir=self._OS_DIR) + build_type=self._BUILD_TYPE, os_root=self._OS_ROOT) # Give more obvious names to some commonly used variables. self.provision_temp_dir = self.stub_tempfile.temp_dir @@ -114,7 +114,7 @@ class ProvisionDeviceTest(unittest.TestCase): shell=False, cwd=None, stdout=None, stderr=None, env={'PATH': self.stub_os.path.dirname(self._FASTBOOT_PATH), - 'ANDROID_BUILD_TOP': self._OS_DIR, + 'ANDROID_BUILD_TOP': self._OS_ROOT, 'ANDROID_HOST_OUT': self._HOST_BUILD_OUT, 'ANDROID_PRODUCT_OUT': self.provision_temp_dir}) diff --git a/cli/lib/core/tool.py b/cli/lib/core/tool.py index 47a9aaa..cbab9ff 100644 --- a/cli/lib/core/tool.py +++ b/cli/lib/core/tool.py @@ -193,7 +193,7 @@ class HostToolWrapper(ToolWrapper): """ # Initialize path to '' at first so we can use ANDROID_HOST_OUT. super(HostToolWrapper, self).__init__('', env=env) - self.set_android_environment(source_top=platform.os_path(), + self.set_android_environment(source_top=platform.os.root, build_out=platform.build_cache, bsp=platform.device.name) self._tool_path = os.path.join(self.environment['ANDROID_HOST_OUT'], @@ -255,7 +255,7 @@ class ProvisionDeviceTool(ToolWrapper): super(ProvisionDeviceTool, self).__init__( os.path.join(provision_dir, 'provision-device'), env=env) self.set_android_environment( - source_top=platform.os_path(), + source_top=platform.os.root, build_out=platform.build_cache, bsp=platform.device.name) # Adjust ANDROID_PRODUCT_OUT to use the provision dir instead of diff --git a/cli/lib/core/tool_unittest.py b/cli/lib/core/tool_unittest.py index 1144dec..a2acb89 100644 --- a/cli/lib/core/tool_unittest.py +++ b/cli/lib/core/tool_unittest.py @@ -40,7 +40,7 @@ class ToolWrapperTest(unittest.TestCase): tool.subprocess = self.stub_subprocess self.platform = platform_stub.StubPlatform( - os_version='12.34', os_dir='/source', board='board_name', + os_version='12.34', os_root='/source', board='board_name', device=device_stub.StubDevice(should_link_version='12.34'), build_cache='/build/out') diff --git a/cli/lib/environment/sysroot_util.py b/cli/lib/environment/sysroot_util.py index 9178a8a..1fd3dbc 100644 --- a/cli/lib/environment/sysroot_util.py +++ b/cli/lib/environment/sysroot_util.py @@ -121,7 +121,7 @@ class SysrootUtil(object): (result_src, result_dest), src and dest transformed and ready to be passed into sysroot.AddDir. """ - result_src = self.platform.os_path(src) + result_src = self.platform.os.path(src) result_dest = dest if src.endswith('/..'): basename = os.path.basename(src[:-3]) @@ -201,7 +201,7 @@ class SysrootUtil(object): # Write the .pc file. try: self._AddPkgConfigFile(suffixed_name, deps, - self.platform.os_version) + self.platform.os.version) except IOError as e: errors.append('.pc file: {}'.format(e)) diff --git a/cli/lib/environment/sysroot_util_unittest.py b/cli/lib/environment/sysroot_util_unittest.py index 46ebd15..c1b10e4 100644 --- a/cli/lib/environment/sysroot_util_unittest.py +++ b/cli/lib/environment/sysroot_util_unittest.py @@ -66,8 +66,8 @@ class SysrootUtilTest(unittest.TestCase): (self.stub_os.path.join('libsrc', 'libtest.so'), self.stub_os.path.join(lib_dir, 'libtest-suffix.so'))] self.sysroot.should_add_dir = [ - (self.platform.os_path('headers/1'), include_dir, True), - (self.platform.os_path('headers/deeper/2/../2'), + (self.platform.os.path('headers/1'), include_dir, True), + (self.platform.os.path('headers/deeper/2/../2'), self.stub_os.path.join(include_dir, '2'), True)] self.sysroot.should_pass_filter = ['file.h', 'h.h', '.h.h', 'longer/path/to/thing.h'] @@ -101,8 +101,8 @@ class SysrootUtilTest(unittest.TestCase): (self.stub_os.path.join('libsrc', 'libtest2.so'), self.stub_os.path.join(lib_dir, 'libtest2-suffix.so'))] self.sysroot.should_add_dir = [ - (self.platform.os_path('headers/1'), include_dir, True), - (self.platform.os_path('headers/2'), include_dir, True)] + (self.platform.os.path('headers/1'), include_dir, True), + (self.platform.os.path('headers/2'), include_dir, True)] self.sysroot.should_pass_filter = ['file.h', 'h.h', '.h.h', 'longer/path/to/thing.h'] self.sysroot.should_fail_filter = ['h.cpp', 'h', 'file.h.tar'] diff --git a/cli/lib/environment/toolchain_util.py b/cli/lib/environment/toolchain_util.py index 0d22154..79cd98d 100644 --- a/cli/lib/environment/toolchain_util.py +++ b/cli/lib/environment/toolchain_util.py @@ -115,7 +115,7 @@ def GenerateToolchain(platform, host, output_dir): os.makedirs(output_dir) # Put together some variables based on host and target. - existing_tools = platform.os_path( + existing_tools = platform.os.path( EXISTING_TOOLS_FORMAT.format(host_arch=host)) tool_prefix = os.path.join( existing_tools, ARCH_TOOL_PREFIX[platform.device.arch]) diff --git a/cli/lib/environment/toolchain_util_unittest.py b/cli/lib/environment/toolchain_util_unittest.py index db6609d..2f36401 100644 --- a/cli/lib/environment/toolchain_util_unittest.py +++ b/cli/lib/environment/toolchain_util_unittest.py @@ -54,7 +54,7 @@ class ToolchainUtilTest(unittest.TestCase): tool_paths = {} tool_dests = {} for tool in stub_tools: - tool_paths[tool] = self.platform.os_path( + tool_paths[tool] = self.platform.os.path( toolchain_util.EXISTING_TOOLS_FORMAT.format( host_arch=self.HOST_ARCH), toolchain_util.ARCH_TOOL_PREFIX[self.TARGET_ARCH] + tool) diff --git a/cli/lib/project/platform.py b/cli/lib/project/platform.py index 05df895..698b089 100644 --- a/cli/lib/project/platform.py +++ b/cli/lib/project/platform.py @@ -86,25 +86,31 @@ class Platform(object): BoardError: If the board requested is invalid. BuildTypeError: If the build type requested is invalid. """ + bsp_manifest = manifest.Manifest.from_json() + # OS. - if os_name != 'brillo': - raise OsError('"{}" ("brillo" is the only supported ' - 'operating system).'.format(os_name)) - if os_version != util.GetOSVersion(): - # Eventually we will support multiple OS versions, - # at which point this check should just confirm that - # the requested version exists, and an additional check - # should be added to verify_downloaded(). - raise OsError('version {} ({} is the only supported ' - 'OS version).'.format( - util.GetOSVersion(), os_version)) - self._os = os_name - self._os_version = os_version + os_ = bsp_manifest.operating_systems.get(os_name) + if not os_: + raise OsError('unrecognized name "{}" ' + '(available OSes: {}).'.format( + os_name, bsp_manifest.operating_systems.keys())) + if os_.version != os_version: + raise OsError('version {} ({} is the only available ' + 'version for {}).'.format( + os_version, os_.version, os_name)) + self._os = os_ # Device. - self._device = None - # Init device raises a BoardError if it can't get the device. - self._init_device(board, board_version) + device = bsp_manifest.devices.get(board) + if not device: + raise BoardError('unrecognized name "{}". Run `bdk bsp list` ' + 'to see available boards.'.format( + board)) + if device.version != board_version: + raise BoardError('version {} ({} is the only available ' + 'version for {}).'.format( + board_version, device.version, board)) + self._device = device # TODO(b/27654613): Check OS and board compatibility. @@ -121,35 +127,13 @@ class Platform(object): os_namespace=self.os_namespace, board_namespace=self.board_namespace) - def _init_device(self, name, version): - """Initialize the bsp.Device associated with this Target. - - Raises: - BoardError: If the target board and version is not in the manifest. - """ - bsp_manifest = manifest.Manifest.from_json() - device = bsp_manifest.devices.get(name) - if not device: - raise BoardError('unrecognized name "{}". Run `bdk bsp list` ' - 'to see available boards.'.format( - name)) - if device.version != version: - raise BoardError('version {} ({} is the only available ' - 'version for {}).'.format( - version, device.version, name)) - self._device = device - @property def os(self): return self._os @property - def os_version(self): - return self._os_version - - @property def os_namespace(self): - return '{}.{}'.format(self.os, self.os_version) + return '{}.{}'.format(self.os.name, self.os.version) @property def board_namespace(self): @@ -182,12 +166,8 @@ class Platform(object): def cache_path(self, *relpath): return os.path.join(self._cache_path, *relpath) - def os_path(self, *relpath): - # TODO(b/28527859): implemented here instead of wrapping. - return util.GetOSPath(self.os_version, *relpath) - def linked(self): - return self.device.linked(self.os_version) + return self.device.linked(self.os.version) def verify_downloaded(self): """Checks that a platform is downloaded. @@ -195,8 +175,10 @@ class Platform(object): Raises: NotDownloadedError: If the platform isn't downloaded. """ - # TODO - # Check that the known OS version matches the desired version. + # Check that the OS is downloaded. + if not self.os.is_available(): + raise NotDownloadedError( + 'OS "{}".'.format(self.os.name)) # Check that the BSP is downloaded. if not self.device.is_available(): diff --git a/cli/lib/project/platform_stub.py b/cli/lib/project/platform_stub.py index aeaa272..9f96c3e 100644 --- a/cli/lib/project/platform_stub.py +++ b/cli/lib/project/platform_stub.py @@ -20,18 +20,22 @@ import os from bsp import device_stub +from bsp import operating_system_stub class StubPlatform(object): """A Stub for the Platform class.""" def __init__(self, os_name='', os_version='', board='', board_version='', - build_type='', device=None, build_cache='', - product_out_cache='', sysroot='', toolchain='', - cache_dir='', os_dir='', verify_raises=Exception): + build_type='', operating_system=None, device=None, os_root='', + build_cache='', product_out_cache='', sysroot='', toolchain='', + cache_dir='', verify_raises=Exception): # Properties. - self.os = os_name - self.os_version = os_version + self.os = (operating_system or + operating_system_stub.StubOperatingSystem()) + self.os.name = os_name + self.os.version = os_version + self.os.root = os_root self.device = device or device_stub.StubDevice() self.device.name = board self.device.version = board_version @@ -43,12 +47,11 @@ class StubPlatform(object): # Helpers. self.cache_dir = cache_dir - self.os_dir = os_dir self.verify_raises = verify_raises @property def os_namespace(self): - return '{}.{}'.format(self.os, self.os_version) + return '{}.{}'.format(self.os.name, self.os.version) @property def board_namespace(self): @@ -57,11 +60,8 @@ class StubPlatform(object): def cache_path(self, *relpath): return os.path.join(self.cache_dir, *relpath) - def os_path(self, *relpath): - return os.path.join(self.os_dir, *relpath) - def linked(self): - return self.device.linked(self.os_version) + return self.device.linked(self.os.version) def verify_downloaded(self): if self.verify_raises: diff --git a/cli/lib/project/platform_unittest.py b/cli/lib/project/platform_unittest.py index 0bf37ee..7c021f5 100644 --- a/cli/lib/project/platform_unittest.py +++ b/cli/lib/project/platform_unittest.py @@ -22,6 +22,7 @@ import unittest from bsp import device_stub from bsp import manifest_stub +from bsp import operating_system_stub from core import user_config_stub from core import util_stub from project import platform @@ -31,7 +32,7 @@ from test import stubs class PlatformTest(unittest.TestCase): _OS = 'brillo' - _OS_VERSION = '99.11' + _OS_VERSION = '99.11.00' _BSP = 'this_is_a_board' _BSP_VERSION = '80.80' _BUILD_TYPE = 'userdebug' @@ -39,7 +40,9 @@ class PlatformTest(unittest.TestCase): _BAD_VERSION = '0.0' def setUp(self): - self.stub_manifest = manifest_stub.StubManifestModule() + self.stub_op_sys = operating_system_stub.StubOperatingSystemModule( + os_name=self._OS, os_version=self._OS_VERSION, os_available=True) + self.stub_manifest = manifest_stub.StubManifestModule(self.stub_op_sys) self.stub_os = stubs.StubOs() self.stub_user_config = user_config_stub.StubUserConfig() self.stub_util = util_stub.StubUtil(os_version=self._OS_VERSION) @@ -59,20 +62,17 @@ class PlatformTest(unittest.TestCase): def test_init_valid(self): # Check all the properties of our correctly initialized platform. - # Boring ones. - self.assertEqual(self.platform.os, self._OS) - self.assertEqual(self.platform.os_version, self._OS_VERSION) + self.assertEqual(self.platform.os.name, self._OS) + self.assertEqual(self.platform.os.version, self._OS_VERSION) self.assertEqual(self.platform.build_type, self._BUILD_TYPE) - - # Generated ones. + self.assertEqual(self.platform.device, self.dev) + self.assertEqual(self.platform.device.name, self._BSP) + self.assertEqual(self.platform.device.version, self._BSP_VERSION) # Namespaces should somehow be related to names & versions. self.assertIn(self._OS, self.platform.os_namespace) self.assertIn(self._OS_VERSION, self.platform.os_namespace) self.assertIn(self._BSP, self.platform.board_namespace) self.assertIn(self._BSP_VERSION, self.platform.board_namespace) - self.assertEqual(self.platform.device, self.dev) - self.assertEqual(self.platform.device.name, self._BSP) - self.assertEqual(self.platform.device.version, self._BSP_VERSION) cache_root = self.stub_os.path.join( self.stub_user_config.USER_CONFIG.platform_cache, self.platform.os_namespace, @@ -139,12 +139,6 @@ class PlatformTest(unittest.TestCase): self.platform.cache_path('a', 'nother', 'path'), self.stub_os.path.join(cache_root, 'a', 'nother', 'path')) - def test_os_path(self): - self.assertEqual( - self.platform.os_path('going', 'down', 'into', 'files'), - self.stub_util.GetOSPath(self._OS_VERSION, - 'going', 'down', 'into', 'files')) - def test_link(self): self.dev.should_link_version = self._OS_VERSION with self.platform.linked(): @@ -159,7 +153,12 @@ class PlatformTest(unittest.TestCase): def test_verify_downloaded(self): self.platform.verify_downloaded() - def test_verify_not_downloaded(self): + def test_verify_board_not_downloaded(self): self.dev.downloaded = False with self.assertRaises(platform.NotDownloadedError): self.platform.verify_downloaded() + + def test_verify_os_not_downloaded(self): + self.platform.os.available = False + with self.assertRaises(platform.NotDownloadedError): + self.platform.verify_downloaded() diff --git a/cli/lib/project/project_spec_unittest.py b/cli/lib/project/project_spec_unittest.py index 24ec224..cb1cef7 100644 --- a/cli/lib/project/project_spec_unittest.py +++ b/cli/lib/project/project_spec_unittest.py @@ -213,8 +213,8 @@ class ParseTest(ProjectSpecTest): with self.assertRaises(dependency.UnsatisfiedVirtualPackError) as uvpe: for tgt in b.targets.values(): # Test all targets we didnt load an os for. - if (tgt.platform.os != 'brillo' or - tgt.platform.os_version != '12'): + if (tgt.platform.os.name != 'brillo' or + tgt.platform.os.version != '12'): tgt.create_submap(b.packmap) for line in str(uvpe.exception).split('\n'): diff --git a/cli/lib/project/target.py b/cli/lib/project/target.py index dc60195..ba24c12 100644 --- a/cli/lib/project/target.py +++ b/cli/lib/project/target.py @@ -47,7 +47,7 @@ class Target(object): def __repr__(self): return ('<target name="{}" os="{}" os-version="{}" ' 'board="{}" board-version="{}" build="{}" pack="{}"/>').format( - self._name, self.platform.os, self.platform.os_version, + self._name, self.platform.os.name, self.platform.os.version, self.platform.device.name, self.platform.device.version, self.platform.build_type, self._pack_name) diff --git a/cli/lib/selinux/policy.py b/cli/lib/selinux/policy.py index 7d1177a..5c29c67 100644 --- a/cli/lib/selinux/policy.py +++ b/cli/lib/selinux/policy.py @@ -96,7 +96,7 @@ def _RunSepolicyAnalyze(build_out, _input_file, _output_file): def GetBoardComboSepolicyDirs(platform): """Gets the BOARD_SEPOLICY_DIRS variable from the build.""" - cmds = ['cd "{}"'.format(platform.os_path()), + cmds = ['cd "{}"'.format(platform.os.root), '. build/envsetup.sh', 'lunch "{}-{}"'.format(platform.device.name, platform.build_type), 'get_build_var BOARD_SEPOLICY_DIRS'] @@ -162,7 +162,7 @@ def BuildSepolicy(platform, output_path): runner = tool.HostToolRunner(platform) # TODO: platformify try: - os_path = platform.os_path() + os_path = platform.os.root main_sepolicy_dir = os.path.join(os_path, 'system', 'sepolicy') all_paths = [main_sepolicy_dir] @@ -190,7 +190,7 @@ def BuildFileContexts(platform, sepolicy_path, output_path, interm_dir = tempfile.mkdtemp() runner = tool.HostToolRunner(platform) try: - os_path = platform.os_path() + os_path = platform.os.root fc_local = os.path.join(interm_dir, 'file_contexts.local.tmp') fc_device = os.path.join(interm_dir, 'file_contexts.device.tmp') |