[TIC-CORE] support local repository
[archive/20170607/tools/tic-core.git] / tic / parser / recipe_parser.py
index a2fc3c6..a830cb3 100644 (file)
@@ -26,6 +26,7 @@ import os
 from tic.utils import error
 from tic.utils.file import write, make_dirs
 import yaml
+from tic.config import configmgr
 
 
 def get_default_recipe():
@@ -34,7 +35,7 @@ def get_default_recipe():
             Baseline= 'tizen-3.0',
             Active= True,
             Mic2Options= '-f raw --fstab=uuid --copy-kernel --compress-disk-image=bz2 --generate-bmap',
-            Part='mobile-mbr',
+            Part='headless',
             Language= 'en_US.UTF-8',
             Keyboard= 'us',
             Timezone= 'Asia/Seoul',
@@ -50,73 +51,60 @@ def get_default_recipe():
             SaveRepos= False,
             UserGroups= "audio,video"
         ),
-        Emulator64wayland=dict(
-            Part='mobile-mbr',
+        Wayland=dict(
+            Part='headless',
             UserGroups='audio,video',
-            Groups=[
-                'Generic Base',
-                'Mobile Base',
-                'Mobile Console Tools',
-                'Mobile Adaptation',
-                'Mobile Wayland',
-                'Mobile Middleware',
-                'Mobile Applications',
-                'Generic Multimedia',
-                'Mobile Multimedia',
-                'Generic Desktop Applications',
-                'Mobile Dali',
-                'Mobile EFL',
-                'Mobile Enlightenment',
-                'Mobile Input Framework',
-                'Mobile Connectivity Framework',
-                'Mobile Bluetooth',
-                'Mobile Web Framework',
-                'Mobile Telephony'],
+            Groups=[],
             PostScripts=[],
             Repos= [],
             NoChrootScripts=[]
         ),
         Configurations=[
             dict(
-                Name='mobile-emulator64-wayland',
-                Architecture='x86_64',
+                Name='tizen-headless',
+                Architecture='armv7l',
                 Schedule= "*",
                 Active= True,
-                Platform= 'Emulator64wayland',
-                Part= 'mobile-2parts-emulator',
-                Mic2Options= '-f loop --pack-to=@NAME@.tar.gz,',
-                FileName= 'mobile-emulator64-wayland',
-                Repos=['mobile-emulator64-wayland', 'base_emulator64'],
-                Groups=['Mobile Adaptation Emulator'],
+                Platform= 'Wayland',
+                Part= 'headless',
+                Mic2Options= '-f loop --pack-to=@NAME@.tar.gz',
+                FileName= 'tizen-headless-tm1',
+                Repos=['tizen-unified', 'tizen-base'],
+                Groups=[],
                 ExtraPackages= [],
                 RemovePackages=[]
             )
         ],
         Repositories=[
-            dict(Name='mobile-emulator64-wayland',
-                 Url='http://download.tizen.org/snapshots/tizen/mobile/latest/repos/emulator64-wayland/packages/',
+            dict(Name='tizen-unified',
+                 Url='http://download.tizen.org/live/devel:/Tizen:/Unified/standard/',
+                 #Url='file://home/shinchulwoo/Repo/Unified',
                  Options='--ssl_verify=no'),
-            dict(Name='base_emulator64',
-                 Url='http://download.tizen.org/snapshots/tizen/base/latest/repos/emulator64/packages/',
+            dict(Name='tizen-base',
+                 Url='http://download.tizen.org/snapshots/tizen/base/latest/repos/arm/packages/',
+                 #Url='file://home/shinchulwoo/Repo/Base',
                  Options='--ssl_verify=no')
         ],
         Partitions=[
-            dict(Name='mobile-mbr',
-                 Contents='part / --fstype="ext4" --size=3584 --ondisk=sda --active --label platform --fsoptions=defaults,noatime'),
-            dict(Name= 'mobile-2parts-emulator',
-                 Contents='part / --size=2000 --ondisk=sda --fstype=ext4 --label=emulator-rootfs\npart /opt/ --size=2000 --ondisk=sda --fstype=ext4 --label=emulator-sysdata')
+            dict(Name='headless',
+                 Contents='part / --size=2000 --ondisk mmcblk0p --fstype=ext4 --label=rootfs --extoptions=\"-J size=16\" \n\
+part /opt/ --size=1000 --ondisk mmcblk0p --fstype=ext4 --label=system-data --extoptions="-m 0" \n\
+part /boot/kernel/mod_tizen_tm1/lib/modules --size=12 --ondisk mmcblk0p --fstype=ext4 --label=modules \n')
         ]
     )
     return recipe
 
 def load_yaml(path):
+    logger = logging.getLogger(__name__)
     try:
         with file(path) as f:
             return yaml.load(f)
-    except IOError:
-        raise error.TICError('cannot read meta file: %s' % path)
-    except:
-        raise error.TICError('yaml format error of meta file: %s' % path)
+    except IOError as err:
+        logger(err)
+        raise error.TICError(configmgr.message['server_error'])
+    except yaml.YAMLError as err:
+        logger(err)
+        raise error.TICError(configmgr.message['recipe_parse_error'] % os.path.basename(path))
     
 
 def convert_recipe_to_yaml(recipe, filepath):
@@ -140,14 +128,14 @@ def convert_recipe_to_yaml(recipe, filepath):
     
     # configs.yaml
     with open(yamlinfo.configs, 'w') as outfile:
-        yaml.dump(config, outfile, default_flow_style=False)
+        yaml.safe_dump(config, outfile, default_flow_style=False)
 
     # repo.yaml
     if 'Repositories' in recipe:
         repos = {}
         repos['Repositories'] = recipe['Repositories']
         with open(yamlinfo.repos, 'w') as outfile:
-            yaml.dump(repos, outfile, default_flow_style=False)
+            yaml.safe_dump(repos, outfile, default_flow_style=False)
     
     # partition info
     if 'Partitions' in recipe: