2 # Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
5 # @author Chulwoo Shin <cw1.shin@samsung.com>
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
24 from tic.utils import error
25 from tic.utils.file import write
27 def get_default_recipe():
30 Baseline= 'tizen-3.0',
32 Mic2Options= '-f raw --fstab=uuid --copy-kernel --compress-disk-image=bz2 --generate-bmap',
34 Language= 'en_US.UTF-8',
36 Timezone= 'Asia/Seoul',
39 DefaultUserPass= 'tizen',
41 BootloaderAppend= "rw vga=current splash rootwait rootfstype=ext4 plymouth.enable=0",
43 BootloaderOptions= '--ptable=gpt --menus="install:Wipe and Install:systemd.unit=system-installer.service:test"',
47 UserGroups= "audio,video"
49 Emulator64wayland=dict(
51 UserGroups='audio,video',
55 'Mobile Console Tools',
59 'Mobile Applications',
62 'Generic Desktop Applications',
65 'Mobile Enlightenment',
66 'Mobile Input Framework',
67 'Mobile Connectivity Framework',
69 'Mobile Web Framework',
77 Name='mobile-emulator64-wayland',
78 Architecture='x86_64',
81 Platform= 'Emulator64wayland',
82 Mic2Options= '-f loop --pack-to=@NAME@.tar.gz,',
83 FileName= 'mobile-emulator64-wayland',
84 Repos=['mobile-emulator64-wayland', 'base_emulator64'],
85 Groups=['Mobile Adaptation Emulator'],
91 dict(Name='mobile-emulator64-wayland',
92 Url='http://download.tizen.org/snapshots/tizen/mobile/latest/repos/emulator64-wayland/packages/',
93 Options='--ssl_verify=no'),
94 dict(Name='base_emulator64',
95 Url='http://download.tizen.org/snapshots/tizen/base/latest/repos/emulator64/packages/',
96 Options='--ssl_verify=no')
99 dict(Name='mobile-mbr',
100 Contents='part / --fstype="ext4" --size=3584 --ondisk=sda --active --label platform --fsoptions=defaults,noatime')
107 with file(path) as f:
110 raise error.TICError('cannot read meta file: %s' % path)
112 raise error.TICError('yaml format error of meta file: %s' % path)
115 def separate_recipe_file_for_ks(recipe):
116 path = '/home/shinchulwoo/recipe/test'
119 config = dict(Default=None, Configurations=[])
120 config['Default'] = recipe.get('Default')
121 # targets (only one target)
122 config['Configurations'].append(recipe.get('Configurations')[0])
123 platform_name = config['Configurations'][0].get('Platform')
124 config[platform_name] = recipe.get(platform_name)
125 with open(os.path.join(path, 'config.yaml'), 'w') as outfile:
126 yaml.dump(config, outfile, default_flow_style=False)
129 if 'Repositories' in recipe:
131 repos['Repositories'] = recipe['Repositories']
132 with open(os.path.join(path, 'repos.yaml'), 'w') as outfile:
133 yaml.dump(repos, outfile, default_flow_style=False)
136 if 'Partitions' in recipe:
137 for partition in recipe.get('Partitions'):
138 partition_path = os.path.join(path, 'partitions')
139 file_name = partition.get('Name')
140 temp = os.path.join(partition_path, file_name)
141 write(temp, partition['Contents'])
144 if 'PostScripts' in recipe:
145 for script in recipe.get('PostScripts'):
146 script_path = os.path.join(path, 'scripts')
147 script_type = script.get('Type')
148 if script_type and script_type == 'nochroot':
149 file_name = '%s.nochroot' % script.get('Name')
151 file_name = '%s.post' % script.get('Name')
152 write(os.path.join(script_path, file_name), script['Contents'])
154 if __name__ == "__main__":
156 recipe = load_yaml('/home/shinchulwoo/recipe/test/test.yaml')
157 separate_recipe_file_for_ks(recipe)