From 56ce9e67e9d4ab820a28878af54ac0d097435bc9 Mon Sep 17 00:00:00 2001 From: Chulwoo Shin Date: Mon, 20 Mar 2017 11:16:45 +0900 Subject: [PATCH] [TIC-CORE] support local repository - support local repository - modify view name of meta-package in tic-web Change-Id: I29002cabb41f440bc027fd7ed20daa92ada9c712 Signed-off-by: Chulwoo Shin --- tic/parser/recipe_parser.py | 2 ++ tic/parser/repo_parser.py | 15 ++++++++------- tic/parser/view_parser.py | 38 +++++++++++++++++++------------------- tic/utils/grabber.py | 5 ++--- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/tic/parser/recipe_parser.py b/tic/parser/recipe_parser.py index 3236b1f..a830cb3 100644 --- a/tic/parser/recipe_parser.py +++ b/tic/parser/recipe_parser.py @@ -78,9 +78,11 @@ def get_default_recipe(): Repositories=[ 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='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=[ diff --git a/tic/parser/repo_parser.py b/tic/parser/repo_parser.py index 95c6b86..69104e1 100644 --- a/tic/parser/repo_parser.py +++ b/tic/parser/repo_parser.py @@ -73,25 +73,27 @@ class RepodataParser(object): pkg_info['id'] = pkg_id pkg_info['name'] = pkg_name pkg_info['arch'] = pkg.findtext(tag_dic['arch']) + pkg_info['summary'] = pkg.findtext(tag_dic['summary']) pkg_info['selfChecked'] = False # for web-ui tree # Parsing meta-pkg using meta naming rule meta_match = META_PATTERN.search(pkg_info['name']) if meta_match is not None: - #print(meta_match.group(0), ', ', meta_match.group('meta'), ', ', meta_match.group('pkgname')) if meta_match.group('meta') == 'root': - meta_info['root'].append([pkg_info['name']]) + meta_info['root'].append([pkg_info['name'], pkg_info['summary']]) pkg_info['meta'] = 'root' elif meta_match.group('meta') == 'sub1': sub1_match = META_SUB1_PATTERN.search(meta_match.group('pkgname')) - meta_info['sub1'].append([pkg_info['name'], - ''.join([META_PREFIX_ROOT, sub1_match.group('root')])]) + meta_info['sub1'].append([pkg_info['name'], + ''.join([META_PREFIX_ROOT, sub1_match.group('root')]), + pkg_info['summary']]) pkg_info['meta'] = 'sub1' elif meta_match.group('meta') == 'sub2': sub2_match = META_SUB2_PATTERN.search(meta_match.group('pkgname')) meta_info['sub2'].append([pkg_info['name'], ''.join([META_PREFIX_ROOT, sub2_match.group('root')]), - ''.join([META_PREFIX_SUB1, sub2_match.group('root'),'-', sub2_match.group('sub1')])]) + ''.join([META_PREFIX_SUB1, sub2_match.group('root'),'-', sub2_match.group('sub1')]), + pkg_info['summary']]) pkg_info['meta'] = 'sub2' # check profile pkg @@ -106,7 +108,6 @@ class RepodataParser(object): 'ver':ver_tag.attrib['ver'], 'rel':ver_tag.attrib['rel']} pkg_info['checksum'] = pkg.findtext(tag_dic['checksum']) - pkg_info['summary'] = pkg.findtext(tag_dic['summary']) pkg_info['description'] = pkg.findtext(tag_dic['description']) pkg_info['location'] = pkg.find(tag_dic['location']).attrib['href'] size_tag = pkg.find(tag_dic['size']) @@ -255,7 +256,7 @@ class RepodataParser(object): tag_dic = self._get_tagname(xml_list[0]) # TODO: temporary code (should be deleted) - # meta_string='building-blocks-root-chooseonlyone_Kernelarmv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfLinux KernelInclude Linux Kernel in the Platform Imagehttp://tizen.org' + # meta_string='building-blocks-root-metapkgarmv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfSimple DirectMedia LayerThis is the Simple DirectMedia Layer, a generic API that provides low level access to audio, keyboard, mouse, and display framebuffer across multiple platforms.http://www.libsdl.org/building-blocks-sub1-metapkg-extsub1armv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfsub1-extensionThis is the Simple DirectMedia Layer, a generic API that provides low level access to audio, keyboard, mouse, and display framebuffer across multiple platforms.http://www.libsdl.org/building-blocks-sub2-metapkg-extsub1-exts1sub1armv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfsub2-extensionThis is the Simple DirectMedia Layer, a generic API that provides low level access to audio, keyboard, mouse, and display framebuffer across multiple platforms.http://www.libsdl.org/building-blocks-sub2-metapkg-extsub1-exts1sub2armv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfsub2-extensionThis is the Simple DirectMedia Layer, a generic API that provides low level access to audio, keyboard, mouse, and display framebuffer across multiple platforms.http://www.libsdl.org/building-blocks-sub1-metapkg-extsub2armv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfsub1-extensionThis is the Simple DirectMedia Layer, a generic API that provides low level access to audio, keyboard, mouse, and display framebuffer across multiple platforms.http://www.libsdl.org/building-blocks-sub2-metapkg-extsub2-exts2sub1armv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfsub2-extensionThis is the Simple DirectMedia Layer, a generic API that provides low level access to audio, keyboard, mouse, and display framebuffer across multiple platforms.http://www.libsdl.org/building-blocks-sub2-metapkg-extsub2-exts2sub2armv7l6f74666eb89e1addc4ce75e25f3e639bbfdd8798fc848a6b7027501070567dcfsub2-extensionThis is the Simple DirectMedia Layer, a generic API that provides low level access to audio, keyboard, mouse, and display framebuffer across multiple platforms.http://www.libsdl.org/' # xml_list.append(etree.fromstring(meta_string)) filter_data = self._filtering_data_based_arch(xml_list, tag_dic) diff --git a/tic/parser/view_parser.py b/tic/parser/view_parser.py index 30cd3aa..4b45756 100644 --- a/tic/parser/view_parser.py +++ b/tic/parser/view_parser.py @@ -1,4 +1,5 @@ import logging +from tic.utils import misc from operator import itemgetter from tic.utils.rpmmisc import meetRequireVersion @@ -27,10 +28,9 @@ def make_view_data(pkg_group): def set_meta_require(meta_info): meta_nodes = meta_info.get('nodes') for child_meta in meta_nodes: - refer_count[child_meta['id']] += 1 set_meta_require(child_meta) - pkg_info = pkg_dict[meta_info['text']] + pkg_info = pkg_dict[meta_info['metaname']] for dep_tag in ['requires', 'recommends']: if pkg_info.get(dep_tag): for req in pkg_info.get(dep_tag): @@ -38,7 +38,8 @@ def make_view_data(pkg_group): if req['name'] in provides: targets = _select_provide_rpm(provides[req['name']], req) elif req['name'] in files: - targets.append(pkg_dict.get(files[req['name']][0])) + for fname in files[req['name']]: + targets.append(pkg_dict.get(fname)) elif req['name'] in pkg_dict: targets.append(pkg_dict.get(req['name'])) else: @@ -52,8 +53,11 @@ def make_view_data(pkg_group): meta_nodes.append(make_node(pkg)) def make_node(pkg_info): - return dict(id=pkg_info['id'], text=pkg_info['name'], nodes=[]) - + #return dict(id=pkg_info['id'], text=pkg_info['name'], nodes=[]) + return dict(text=pkg_info['name'], nodes=[]) + def make_meta_node(pkgname, viewtext): + return dict(text=viewtext, metaname=pkgname, nodes=[]) + # view_data for tree view on web-ui view_data = [] # temporary dictionary for referencing meta @@ -67,20 +71,20 @@ def make_view_data(pkg_group): files = pkg_group['files'] refer_count = [0] * len(pkg_dict) - # sort by pkg_name ([0]:name, [1]:root, [2]:sub1) + # sort by summary meta_info = pkg_group.get('meta_info') - meta_info['root'] = sorted(meta_info['root'], key=itemgetter(0)) - meta_info['sub1'] = sorted(meta_info['sub1'], key=itemgetter(0)) - meta_info['sub2'] = sorted(meta_info['sub2'], key=itemgetter(0)) + meta_info['root'] = sorted(meta_info['root'], key=itemgetter(1)) + meta_info['sub1'] = sorted(meta_info['sub1'], key=itemgetter(2)) + meta_info['sub2'] = sorted(meta_info['sub2'], key=itemgetter(3)) # make tree of meta for root in meta_info['root']: - root_node = make_node(pkg_dict[root[0]]) + root_node = make_meta_node(root[0], root[1]) view_ref[root[0]] = root_node view_data.append(root_node) for sub1 in meta_info['sub1']: - sub1_node = make_node(pkg_dict[sub1[0]]) + sub1_node = make_meta_node(sub1[0], sub1[2]) view_ref[sub1[0]] = sub1_node # search root if sub1[1] in view_ref: @@ -91,7 +95,7 @@ def make_view_data(pkg_group): view_data.append(sub1_node) for sub2 in meta_info['sub2']: - sub2_node = make_node(pkg_dict[sub2[0]]) + sub2_node = make_meta_node(sub2[0], sub2[3]) view_ref[sub2[0]] = sub2_node # search sub1 if sub2[2] in view_ref: @@ -106,7 +110,6 @@ def make_view_data(pkg_group): # configure meta dependency tree (requires) for meta_pkg in view_data: - refer_count[meta_pkg['id']] += 1 set_meta_require(meta_pkg) #The remaining rpms are grouped into a MISC tree @@ -115,12 +118,9 @@ def make_view_data(pkg_group): misc_info['nodes'] = [] for k, v in pkg_dict.iteritems(): # Pkg is not referenced from Meta-pkg - if refer_count[v['id']] == 0: + if not v.get('meta') and refer_count[v['id']] == 0: misc_info['nodes'].append(make_node(v)) - + logger.info('meta: %d, misc: %d', len(view_ref), len(misc_info['nodes'])) - view_data.append(misc_info) - - return view_data - + return view_data \ No newline at end of file diff --git a/tic/utils/grabber.py b/tic/utils/grabber.py index 037f95d..d0af5e8 100644 --- a/tic/utils/grabber.py +++ b/tic/utils/grabber.py @@ -34,12 +34,11 @@ def myurlgrab2(url, filename): if url.startswith("file:/"): filepath = "/%s" % url.replace("file:", "").lstrip('/') if not os.path.exists(filepath): - logger.info('URLGrabber error: cannot find file %s' % url) - raise TICError("URLGrabber error: can't find file %s" % url) + raise TICError(configmgr.message['repo_not_found'] % url) if url.endswith('.rpm'): return filepath else: - copyfile(filepath, filename) + copyfile(filepath, os.path.dirname(filename)) logger.info('copy file ' + filepath) else: try: -- 2.7.4