diff options
author | Steve Fung <stevefung@chromium.org> | 2015-05-31 23:25:33 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-02 20:48:54 +0000 |
commit | 977460a22db370cbfc5808e81732297e8bf1acd5 (patch) | |
tree | 0ec2bbc868316b6fd0c25d10eac78f1e7c1732ca /cli | |
parent | 46c2b3520a3ac373ae039eba2cce6de47c30d943 (diff) | |
download | chromite-977460a22db370cbfc5808e81732297e8bf1acd5.tar.gz |
image: Add APP_ID from blueprints' buildTargetId
Set the APP_ID fields in the /etc/lsb-release file from the
buildTargetId field of a blueprint.
BUG=brillo:1010
TEST=`brillo image --blueprint=//blueprints/helloworld_danger`
Checked image's /etc/lsb-release file, contained APP_ID fields.
TEST=unittests
CQ-DEPEND=CL:*217827
CQ-DEPEND=I128349192db35a32fe73608517158572f72a5c66
Change-Id: Ida0e1542dc7301051bffc91e79b3333d9da26a32
Reviewed-on: https://chromium-review.googlesource.com/274147
Tested-by: Steve Fung <stevefung@chromium.org>
Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org>
Commit-Queue: Steve Fung <stevefung@chromium.org>
Trybot-Ready: Steve Fung <stevefung@chromium.org>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/cros/cros_image.py | 3 | ||||
-rw-r--r-- | cli/cros/cros_image_unittest.py | 35 |
2 files changed, 38 insertions, 0 deletions
diff --git a/cli/cros/cros_image.py b/cli/cros/cros_image.py index 559d29260..9c065af81 100644 --- a/cli/cros/cros_image.py +++ b/cli/cros/cros_image.py @@ -72,12 +72,14 @@ class ImageCommand(command.CliCommand): board = None packages = None + app_id = None if self.options.blueprint: blueprint = blueprint_lib.Blueprint(self.options.blueprint) packages = blueprint.GetPackages(with_implicit=False) #TODO(stevefung): Support multiple sysroots (brbug.com/676) board = blueprint.FriendlyName() + app_id = blueprint.GetAppId() elif self.options.brick: brick = brick_lib.Brick(self.options.brick) packages = brick.MainPackages() @@ -88,6 +90,7 @@ class ImageCommand(command.CliCommand): image_lib.BuildImage( board, adjust_part=self.options.adjust_part, + app_id=app_id, boot_args=self.options.boot_args, enable_bootcache=self.options.enable_bootcache, enable_rootfs_verification=self.options.enable_rootfs_verification, diff --git a/cli/cros/cros_image_unittest.py b/cli/cros/cros_image_unittest.py index cdbef6287..05222672a 100644 --- a/cli/cros/cros_image_unittest.py +++ b/cli/cros/cros_image_unittest.py @@ -70,6 +70,41 @@ class ImageCommandTest(cros_test_lib.WorkspaceTestCase): '--loglevel=7'] self.rc_mock.assertCommandContains(expected_args) + def testBlueprintWithBuildTargetId(self): + """Tests running the full image command with a valid BuildTargetId.""" + self.CreateBrick(name='brick1', main_package='brick/foo') + self.CreateBrick(name='brick2', main_package='brick/bar') + self.CreateBrick(name='bsp1', main_package='bsp/baz') + self.CreateBlueprint(name='foo.json', bricks=['//brick1', '//brick2'], + bsp='//bsp1', + buildTargetId='{01234567-89AB-CDEF-0123-456789ABCDEF}') + + args = ['--blueprint=//foo.json'] + self.SetupCommandMock(args) + self.cmd_mock.inst.Run() + + expected_args = [os.path.join(constants.CROSUTILS_DIR, 'build_image'), + '--app_id={01234567-89AB-CDEF-0123-456789ABCDEF}', + '--board=foo.json', + '--extra_packages=brick/foo brick/bar bsp/baz', + '--noenable_bootcache', '--enable_rootfs_verification', + '--loglevel=7'] + self.rc_mock.assertCommandContains(expected_args) + + def testBlueprintWithInvalidBuildTargetId(self): + """Tests running the full image command with invalid BuildTargetId.""" + self.CreateBrick(name='brick1', main_package='brick/foo') + self.CreateBrick(name='brick2', main_package='brick/bar') + self.CreateBrick(name='bsp1', main_package='bsp/baz') + self.CreateBlueprint(name='foo.json', bricks=['//brick1', '//brick2'], + bsp='//bsp1', + buildTargetId='{01234567-89AB-CDEF-0123-45678}') + + args = ['--blueprint=//foo.json'] + self.SetupCommandMock(args) + with self.assertRaises(image_lib.AppIdError): + self.cmd_mock.inst.Run() + def testOutputRootInWorkspace(self): """Tests running the image command with an output root in the workspace.""" self.CreateWorkspace() |