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.
23 from datetime import datetime
26 from tic.utils import error
27 from tic.utils.file import write, make_dirs
31 def get_default_recipe():
34 Baseline= 'tizen-3.0',
36 Mic2Options= '-f raw --fstab=uuid --copy-kernel --compress-disk-image=bz2 --generate-bmap',
38 Language= 'en_US.UTF-8',
40 Timezone= 'Asia/Seoul',
43 DefaultUserPass= 'tizen',
45 BootloaderAppend= "rw vga=current splash rootwait rootfstype=ext4 plymouth.enable=0",
47 BootloaderOptions= '--ptable=gpt --menus="install:Wipe and Install:systemd.unit=system-installer.service:test"',
51 UserGroups= "audio,video"
53 Emulator64wayland=dict(
55 UserGroups='audio,video',
59 'Mobile Console Tools',
63 'Mobile Applications',
66 'Generic Desktop Applications',
69 'Mobile Enlightenment',
70 'Mobile Input Framework',
71 'Mobile Connectivity Framework',
73 'Mobile Web Framework',
81 Name='mobile-emulator64-wayland',
82 Architecture='x86_64',
85 Platform= 'Emulator64wayland',
86 Part= 'mobile-2parts-emulator',
87 Mic2Options= '-f loop --pack-to=@NAME@.tar.gz,',
88 FileName= 'mobile-emulator64-wayland',
89 Repos=['mobile-emulator64-wayland', 'base_emulator64'],
90 Groups=['Mobile Adaptation Emulator'],
96 dict(Name='mobile-emulator64-wayland',
97 Url='http://download.tizen.org/snapshots/tizen/mobile/latest/repos/emulator64-wayland/packages/',
98 Options='--ssl_verify=no'),
99 dict(Name='base_emulator64',
100 Url='http://download.tizen.org/snapshots/tizen/base/latest/repos/emulator64/packages/',
101 Options='--ssl_verify=no')
104 dict(Name='mobile-mbr',
105 Contents='part / --fstype="ext4" --size=3584 --ondisk=sda --active --label platform --fsoptions=defaults,noatime'),
106 dict(Name= 'mobile-2parts-emulator',
107 Contents='part / --size=2000 --ondisk=sda --fstype=ext4 --label=emulator-rootfs\npart /opt/ --size=2000 --ondisk=sda --fstype=ext4 --label=emulator-sysdata')
114 with file(path) as f:
117 raise error.TICError('cannot read meta file: %s' % path)
119 raise error.TICError('yaml format error of meta file: %s' % path)
122 def convert_recipe_to_yaml(recipe, filepath):
123 logger = logging.getLogger(__name__)
126 config = dict(Default=None, Configurations=[])
127 config['Default'] = recipe.get('Default')
128 # targets (only one target)
129 config['Configurations'].append(recipe.get('Configurations')[0])
130 platform_name = config['Configurations'][0].get('Platform')
131 config[platform_name] = recipe.get(platform_name)
133 dir_path = os.path.join(filepath, datetime.now().strftime('%Y%m%d%H%M%S%f'))
135 logger.info('kickstart cache dir=%s' % dir_path)
137 yamlinfo = YamlInfo(dir_path,
138 os.path.join(dir_path, 'configs.yaml'),
139 os.path.join(dir_path, 'repos.yaml'))
142 with open(yamlinfo.configs, 'w') as outfile:
143 yaml.dump(config, outfile, default_flow_style=False)
146 if 'Repositories' in recipe:
148 repos['Repositories'] = recipe['Repositories']
149 with open(yamlinfo.repos, 'w') as outfile:
150 yaml.dump(repos, outfile, default_flow_style=False)
153 if 'Partitions' in recipe:
154 for partition in recipe.get('Partitions'):
155 partition_path = os.path.join(dir_path, 'partitions')
156 file_name = partition.get('Name')
157 temp = os.path.join(partition_path, file_name)
158 write(temp, partition['Contents'])
161 if 'PostScripts' in recipe:
162 for script in recipe.get('PostScripts'):
163 script_path = os.path.join(dir_path, 'scripts')
164 script_type = script.get('Type')
165 if script_type and script_type == 'nochroot':
166 file_name = '%s.nochroot' % script.get('Name')
168 file_name = '%s.post' % script.get('Name')
169 write(os.path.join(script_path, file_name), script['Contents'])
173 YamlType = collections.namedtuple('YamlInfo', 'cachedir, configs, repos')
174 def YamlInfo(cachedir, configs, repos):
175 return YamlType(cachedir, configs, repos)