def testWriteLsbRelease(self): """Tests writing out the lsb_release file using WriteLsbRelease(..).""" rc_mock = self.PatchObject(cros_build_lib, 'sudo_run') fields = collections.OrderedDict(( ('x', '1'), ('y', '2'), ('foo', 'bar'), )) image_lib.WriteLsbRelease(self.tempdir, fields) lsb_release_file = os.path.join(self.tempdir, 'etc', 'lsb-release') expected_content = 'x=1\ny=2\nfoo=bar\n' self.assertFileContents(lsb_release_file, expected_content) rc_mock.assert_called_once_with([ 'setfattr', '-n', 'security.selinux', '-v', 'u:object_r:cros_conf_file:s0', os.path.join(self.tempdir, 'etc/lsb-release')]) # Test that WriteLsbRelease(..) correctly handles an existing file. rc_mock = self.PatchObject(cros_build_lib, 'sudo_run') fields = collections.OrderedDict(( ('newkey1', 'value1'), ('newkey2', 'value2'), ('a', '3'), ('b', '4'), )) image_lib.WriteLsbRelease(self.tempdir, fields) expected_content = ('x=1\ny=2\nfoo=bar\nnewkey1=value1\nnewkey2=value2\n' 'a=3\nb=4\n') self.assertFileContents(lsb_release_file, expected_content) rc_mock.assert_called_once_with([ 'setfattr', '-n', 'security.selinux', '-v', 'u:object_r:cros_conf_file:s0', os.path.join(self.tempdir, 'etc/lsb-release')])
def testWriteLsbRelease(self): """Tests writing out the lsb_release file using WriteLsbRelease(..).""" fields = {'x': '1', 'y': '2', 'foo': 'bar'} image_lib.WriteLsbRelease(self.tempdir, fields) lsb_release_file = os.path.join(self.tempdir, 'etc', 'lsb-release') expected_content = 'y=2\nx=1\nfoo=bar\n' self.assertFileContents(lsb_release_file, expected_content) # Test that WriteLsbRelease(..) correctly handles an existing file. fields = {'newkey1': 'value1', 'newkey2': 'value2', 'a': '3', 'b': '4'} image_lib.WriteLsbRelease(self.tempdir, fields) expected_content = ('y=2\nx=1\nfoo=bar\nnewkey2=value2\na=3\n' 'newkey1=value1\nb=4\n') self.assertFileContents(lsb_release_file, expected_content)
def main(argv): opts = _ParseArguments(argv) fields = { LSB_KEY_NAME: 'Chromium OS', LSB_KEY_AUSERVER: opts.auserver, LSB_KEY_DEVSERVER: opts.devserver, } if opts.app_id is not None: fields.update({ LSB_KEY_APPID_RELEASE: opts.app_id, LSB_KEY_APPID_BOARD: opts.app_id, LSB_KEY_APPID_CANARY: CANARY_APP_ID, }) if opts.arc_version is not None: fields.update({ LSB_KEY_ARC_VERSION: opts.arc_version, }) if opts.arc_android_sdk_version is not None: fields.update({ LSB_KEY_ARC_ANDROID_SDK_VERSION: opts.arc_android_sdk_version, }) if opts.builder_path is not None: fields.update({ LSB_KEY_BUILDER_PATH: opts.builder_path, }) board_and_models = opts.board if opts.models: board_and_models += '-unibuild (%s)' % opts.models if opts.official: # Official builds (i.e. buildbot). track = 'dev-channel' build_type = 'Official Build' fields.update({ LSB_KEY_TRACK: track, LSB_KEY_NAME: 'Chrome OS', LSB_KEY_BUILD_TYPE: build_type, LSB_KEY_DESCRIPTION: ('%s (%s) %s %s test' % (opts.version_string, build_type, track, board_and_models)), LSB_KEY_AUSERVER: 'https://tools.google.com/service/update2', LSB_KEY_DEVSERVER: '', }) elif getpass.getuser() == 'chrome-bot': # Continuous builder. build_type = 'Continuous Builder - Builder: %s' % opts.buildbot_build fields.update({ LSB_KEY_TRACK: 'buildbot-build', LSB_KEY_BUILD_TYPE: build_type, LSB_KEY_DESCRIPTION: '%s (%s) %s' % (opts.version_string, build_type, board_and_models), }) else: # Developer manual builds. build_type = 'Developer Build - %s' % getpass.getuser() fields.update({ LSB_KEY_TRACK: opts.track, LSB_KEY_BUILD_TYPE: build_type, LSB_KEY_DESCRIPTION: '%s (%s) %s %s' % (opts.version_string, build_type, opts.track, board_and_models), }) fields.update({ LSB_KEY_BOARD: opts.board, LSB_KEY_BRANCH_NUMBER: opts.branch_number, LSB_KEY_BUILD_NUMBER: opts.build_number, LSB_KEY_CHROME_MILESTONE: opts.chrome_milestone, LSB_KEY_PATCH_NUMBER: opts.patch_number, LSB_KEY_VERSION: opts.version_string, LSB_KEY_GOOGLE_RELEASE: opts.version_string, }) if opts.models: fields[LSB_KEY_UNIBUILD] = '1' fields[LSB_KEY_MODELS] = opts.models image_lib.WriteLsbRelease(opts.sysroot, fields)