mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 20:13:32 +01:00
projects.py: Add command pkg-requires
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
754a4c59e6
commit
feba0e57dc
1 changed files with 40 additions and 8 deletions
|
|
@ -6,7 +6,7 @@ from sets import Set
|
|||
from os.path import expanduser
|
||||
import re
|
||||
|
||||
proj_root = expanduser("~") + '/local/src/cvs.stable/proj'
|
||||
projs_root = expanduser("~") + '/local/src/cvs.stable/proj'
|
||||
|
||||
def re_section(name):
|
||||
return re.compile('[' + name + ']'
|
||||
|
|
@ -32,12 +32,20 @@ def get_section(path, section):
|
|||
file.close()
|
||||
return r.rstrip()
|
||||
|
||||
def get_value(path, section, key):
|
||||
def get_value(name, section, key):
|
||||
proj_root = projs_root + '/' + name
|
||||
if section == 'version':
|
||||
with open(proj_root + '/VERSION', 'r') as file:
|
||||
r=file.read().replace('\n', '').replace('-dev', '')
|
||||
file.close()
|
||||
return r
|
||||
|
||||
path = proj_root + '/doc/share/project.txt'
|
||||
r = ()
|
||||
file = open(path)
|
||||
if not len(section):
|
||||
for line in file:
|
||||
r = re.findall(key + ' *= *(.*)', line)
|
||||
r = re.findall('^ *' + key + ' *= *(.*)', line)
|
||||
if (len(r) > 0):
|
||||
break
|
||||
else:
|
||||
|
|
@ -50,7 +58,7 @@ def get_value(path, section, key):
|
|||
if in_section:
|
||||
if len(line) and line[0] == '[':
|
||||
break
|
||||
r = re.findall(key + ' *= *(.*)', line)
|
||||
r = re.findall('^ *' + key + ' *= *(.*)', line)
|
||||
if (len(r) > 0):
|
||||
break
|
||||
file.close()
|
||||
|
|
@ -63,7 +71,7 @@ def add_modules_from_project_txt(buf, name, section, key, add_self, recursive):
|
|||
return
|
||||
if add_self:
|
||||
buf.add(name)
|
||||
deps = get_value(proj_root + '/' + name + '/doc/share/project.txt', section, key).split()
|
||||
deps = get_value(name, section, key).split()
|
||||
for dep in deps:
|
||||
buf.add(dep)
|
||||
if recursive:
|
||||
|
|
@ -91,7 +99,7 @@ def cmd_ldlibpath(args_):
|
|||
True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
r = r + ':' + proj_root + '/' + m + '/lib'
|
||||
r = r + ':' + projs_root + '/' + m + '/lib'
|
||||
print r[1:]
|
||||
|
||||
def cmd_path(args_):
|
||||
|
|
@ -102,9 +110,33 @@ def cmd_path(args_):
|
|||
True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
r = r + ':' + proj_root + '/' + m + '/bin'
|
||||
r = r + ':' + projs_root + '/' + m + '/bin'
|
||||
print r[1:]
|
||||
|
||||
def cmd_pkg_requires(args_):
|
||||
parser = argparse.ArgumentParser(description='pkg-requires')
|
||||
parser.add_argument('flavour', help='Flavour')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
r = []
|
||||
for m in args.module:
|
||||
deps = get_value(m, 'pkg.required', args.flavour).split(',')
|
||||
for spec in deps:
|
||||
dep = re.split('([=><]+)', spec)
|
||||
for i, item in enumerate(dep):
|
||||
dep[i] = item.strip()
|
||||
if len(dep) == 3:
|
||||
dep_project = re.sub(r'-devel$|-run$', '', dep[0])
|
||||
version = get_value(dep_project, 'version', '')
|
||||
if dep[2] == 'VERSION':
|
||||
dep[2] = version.split('-')[0]
|
||||
elif dep[2] == 'VERSION-REVISION':
|
||||
dep[2] = version
|
||||
else:
|
||||
raise Exception("Unknown version specifier in " + spec)
|
||||
r.append(' '.join(dep))
|
||||
print ', '.join(r)
|
||||
|
||||
global_args = []
|
||||
for a in sys.argv[1::]:
|
||||
global_args.append(a)
|
||||
|
|
@ -117,6 +149,6 @@ parser = argparse.ArgumentParser(description='Project metadata evaluation')
|
|||
parser.add_argument('cmd', default='', help='Command')
|
||||
parser.add_argument('arg', nargs='*', help='Command arguments')
|
||||
args=parser.parse_args(global_args)
|
||||
cmd = getattr(sys.modules[__name__], 'cmd_' + args.cmd);
|
||||
cmd = getattr(sys.modules[__name__], 'cmd_' + args.cmd.replace('-', '_'))
|
||||
cmd(sys.argv[(len(global_args) + 1)::])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue