mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
projects.py: Add cmd_required_pkg()
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
5b6ee5ef6d
commit
b27e0166c4
1 changed files with 42 additions and 6 deletions
|
|
@ -4,11 +4,14 @@ from __future__ import print_function
|
|||
import sys
|
||||
import argparse
|
||||
from sets import Set
|
||||
from os.path import isfile
|
||||
from os.path import isdir
|
||||
from os.path import expanduser
|
||||
from os.path import basename
|
||||
from os.path import realpath
|
||||
import subprocess
|
||||
import re
|
||||
import platform
|
||||
|
||||
# meaning of pkg.required.xxx variables
|
||||
# build: needs to be built and installed before this can be built
|
||||
|
|
@ -33,11 +36,18 @@ def re_section(name):
|
|||
'(?=[)',
|
||||
re.DOTALL)
|
||||
|
||||
def get_os():
|
||||
def remove_duplicates(seq):
|
||||
seen = set()
|
||||
seen_add = seen.add
|
||||
return [x for x in seq if not (x in seen or seen_add(x))]
|
||||
|
||||
def get_os(args = ""):
|
||||
for d in [ projs_root + 'ytools/devutil/scripts', '/opt/ytools/bin' ]:
|
||||
script=d + '/get_os.sh'
|
||||
if os.path.isfile(script):
|
||||
script = d + '/get_os.sh'
|
||||
if isfile(script):
|
||||
cmd = '/bin/bash ' + script
|
||||
if args:
|
||||
cmd = cmd + ' ' + args
|
||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
|
||||
(out, rr) = p.communicate()
|
||||
if rr:
|
||||
|
|
@ -57,9 +67,9 @@ def htdocs_dir(name):
|
|||
|
||||
def pkg_required_os_cascade():
|
||||
os = get_os()
|
||||
# TODO: implement this
|
||||
#return [ 'os', 'os.linux', 'os.linux.suse', 'os.linux.suse.tumbleweed' ] ?
|
||||
return [ 'os', 'linux', 'suse', 'suse-tumbleweed' ]
|
||||
name = re.sub('-.*', '', os)
|
||||
# e.g. os, linux, suse, suse-tumbleweed
|
||||
return [ 'os', platform.system().lower(), name, os ]
|
||||
|
||||
def strip_module_from_spec(mod):
|
||||
return re.sub(r'-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip())
|
||||
|
|
@ -131,6 +141,14 @@ def get_value(name, section, key):
|
|||
#print('path = ', path, 'top_name = ', top_name, 'name = ', name)
|
||||
return read_value(path, section, key)
|
||||
|
||||
def collect_values(names, section, key):
|
||||
r = ""
|
||||
for n in names:
|
||||
val = get_value(n, section, key)
|
||||
if val:
|
||||
r = r + " " + val
|
||||
return remove_duplicates([x.strip() for x in r.split(",")])
|
||||
|
||||
# scope 0: no children
|
||||
# scope 1: children
|
||||
# scope 2: recursive
|
||||
|
|
@ -240,6 +258,24 @@ def cmd_test(args_):
|
|||
args=parser.parse_args(args_)
|
||||
print("blah = " + args.blah)
|
||||
|
||||
def cmd_required_pkg(args_):
|
||||
parser = argparse.ArgumentParser(description='required-pkg')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
deps = get_modules_from_project_txt(args.module, 'pkg.required.jw', [ 'build' ],
|
||||
scope = 2, add_self=True, names_only=True)
|
||||
subsecs = pkg_required_os_cascade()
|
||||
required = []
|
||||
for s in subsecs:
|
||||
vals = collect_values(deps, 'pkg.required.' + s, 'build')
|
||||
if vals:
|
||||
required = required + vals
|
||||
# TODO: add all not in build tree as -devel
|
||||
r = ''
|
||||
for m in required:
|
||||
r = r + ' ' + m
|
||||
print(r[1:])
|
||||
|
||||
def cmd_ldlibpath(args_):
|
||||
parser = argparse.ArgumentParser(description='ldlibpath')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue