Miscellaneous minor fixes #47
7 changed files with 56 additions and 39 deletions
|
|
@ -53,7 +53,7 @@ dir=`dirname $0`
|
|||
inifile="$1"
|
||||
. $dir/ini-tools.sh
|
||||
|
||||
subpackages=`cfg_value global.subpackages`
|
||||
subpackages=`cfg_value global.subpackages | sed 's/,/ /g'`
|
||||
license=`cfg_value global.license`
|
||||
[ "$license" ] || license="janware GmbH proprietary license"
|
||||
vendor=`cfg_value global.vendor`
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class CmdPlatform(Cmd): # export
|
|||
|
||||
def __init__(self, parent: Parent) -> None:
|
||||
super().__init__(
|
||||
parent, 'platform', help = 'Miscellaneous platform-related comamnds'
|
||||
parent, 'platform', help = 'Miscellaneous platform-related commands'
|
||||
)
|
||||
self.load_subcommands()
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ from .Cmd import Cmd, Parent
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from argparse import ArgumentParser, Namespace
|
||||
from typing import Iterable, TypeAlias
|
||||
DepNode: TypeAlias = dict[str, set[str]]
|
||||
|
||||
class CmdBuild(Cmd): # export
|
||||
|
||||
|
|
@ -83,55 +85,64 @@ class CmdBuild(Cmd): # export
|
|||
async def _run(self, args: Namespace) -> None:
|
||||
|
||||
@lru_cache(maxsize = None)
|
||||
def read_deps(cur, prereq_type: str) -> list[str]:
|
||||
def read_deps(cur: str, dep_flavour: str) -> list[str]:
|
||||
# dep cache doesn't make a difference at all
|
||||
if prereq_type in dep_cache:
|
||||
if cur in dep_cache[prereq_type]:
|
||||
return dep_cache[prereq_type][cur]
|
||||
if dep_flavour in dep_cache:
|
||||
if cur in dep_cache[dep_flavour]:
|
||||
return dep_cache[dep_flavour][cur]
|
||||
else:
|
||||
dep_cache[prereq_type] = {}
|
||||
dep_cache[dep_flavour] = {}
|
||||
|
||||
ret = self.app.get_project_refs(
|
||||
[cur],
|
||||
['pkg.requires.jw'],
|
||||
prereq_type,
|
||||
dep_flavour,
|
||||
scope = Scope.Subtree,
|
||||
add_self = False,
|
||||
names_only = True,
|
||||
)
|
||||
log(DEBUG, 'prerequisites = ' + ' '.join(ret))
|
||||
log(DEBUG, f'Prerequisites: {" ".join(ret)}')
|
||||
if cur in ret:
|
||||
ret.remove(cur)
|
||||
|
||||
log(
|
||||
DEBUG,
|
||||
(f'Inserting {prereq_type}, prerequisites of {cur}: {" ".join(ret)}'),
|
||||
(f'Inserting {dep_flavour}, prerequisites of {cur}: {" ".join(ret)}'),
|
||||
)
|
||||
|
||||
dep_cache[prereq_type][cur] = ret
|
||||
dep_cache[dep_flavour][cur] = ret
|
||||
return ret
|
||||
|
||||
def add_dep_tree(cur, prereq_types, tree, all_deps):
|
||||
log(DEBUG, f'Adding deps "{" ".join(prereq_types)}" of module {cur}')
|
||||
def add_dep_tree(
|
||||
cur: str,
|
||||
dep_flavours: Iterable[str],
|
||||
tree: DepNode,
|
||||
all_deps: set[str],
|
||||
) -> int:
|
||||
log(DEBUG, f'Adding deps "{" ".join(dep_flavours)}" of module {cur}')
|
||||
if cur in all_deps:
|
||||
log(DEBUG, 'Already handled module "{cur}"')
|
||||
log(DEBUG, f'Already handled module "{cur}"')
|
||||
return 0
|
||||
deps = set()
|
||||
deps: set[str] = set()
|
||||
all_deps.add(cur)
|
||||
for t in prereq_types:
|
||||
log(DEBUG, 'Checking deps of type "{t}"')
|
||||
for t in dep_flavours:
|
||||
log(DEBUG, f'Checking deps of type "{t}"')
|
||||
deps.update(read_deps(cur, t))
|
||||
for d in deps:
|
||||
add_dep_tree(d, prereq_types, tree, all_deps)
|
||||
add_dep_tree(d, dep_flavours, tree, all_deps)
|
||||
tree[cur] = deps
|
||||
return len(deps)
|
||||
|
||||
def calculate_order(order, modules, prereq_types):
|
||||
all_deps = set()
|
||||
dep_tree = {}
|
||||
def calculate_order(
|
||||
order: list[str],
|
||||
modules: set[str],
|
||||
dep_flavours: Iterable[str],
|
||||
) -> int:
|
||||
all_deps: set[str] = set()
|
||||
dep_tree: DepNode = {}
|
||||
for m in modules:
|
||||
log(DEBUG, '--- Adding dependency tree of module "{m}"')
|
||||
add_dep_tree(m, prereq_types, dep_tree, all_deps)
|
||||
log(DEBUG, f'--- Adding dependency tree of module "{m}"')
|
||||
add_dep_tree(m, dep_flavours, dep_tree, all_deps)
|
||||
while len(all_deps):
|
||||
# Find any leaf
|
||||
for d in all_deps:
|
||||
|
|
@ -139,9 +150,9 @@ class CmdBuild(Cmd): # export
|
|||
if not len(dep_tree[d]):
|
||||
break # found
|
||||
else: # no Leaf found
|
||||
print(all_deps)
|
||||
raise Exception(
|
||||
'Fatal: the dependencies between these modules are unresolvable'
|
||||
'Fatal: Dependencies between these modules are unresolvable: '
|
||||
', '.join(all_deps)
|
||||
)
|
||||
order.append(d) # do it
|
||||
# bookkeep it
|
||||
|
|
@ -220,9 +231,9 @@ class CmdBuild(Cmd): # export
|
|||
if not len(modules):
|
||||
log(NOTICE, 'All modules cleaned')
|
||||
|
||||
async def run(args) -> None:
|
||||
async def run(args: Namespace) -> None:
|
||||
|
||||
log(DEBUG, f'-------------------------------------- running {pretty_cmd()}')
|
||||
log(DEBUG, f'-------------------------------------- Running {pretty_cmd()}')
|
||||
|
||||
modules = set(args.modules)
|
||||
exclude = set(args.exclude.split())
|
||||
|
|
@ -236,15 +247,15 @@ class CmdBuild(Cmd): # export
|
|||
# -- build
|
||||
order: list[str] = []
|
||||
|
||||
glob_prereq_types = ['build']
|
||||
dep_flavours = ['build']
|
||||
if re.match('pkg-.*', target) is not None:
|
||||
glob_prereq_types = ['build', 'run', 'release', 'devel']
|
||||
dep_flavours = ['build', 'run', 'release', 'devel']
|
||||
|
||||
if target != 'order' and not args.build_order:
|
||||
log(NOTICE, 'Using prerequisite types ' + ' '.join(glob_prereq_types))
|
||||
log(NOTICE, 'Using prerequisite flavours ' + ' '.join(dep_flavours))
|
||||
log(NOTICE, 'Calculating order for modules ... ')
|
||||
|
||||
calculate_order(order, modules, glob_prereq_types)
|
||||
calculate_order(order, modules, dep_flavours)
|
||||
if args.ignore_deps:
|
||||
order = [m for m in order if m in args.modules]
|
||||
order = [m for m in order if m not in exclude]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import sys
|
|||
|
||||
from typing import TYPE_CHECKING, Generic, Iterable, TypeVar
|
||||
|
||||
from .log import OFF, log, parse_log_level
|
||||
from .log import ERR, OFF, log, parse_log_level
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
|
|
@ -43,7 +43,7 @@ class LoadTypes(Types[T]): # export
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
mod_names: list[str],
|
||||
mod_names: Iterable[str],
|
||||
type_name_filter: str | None = None,
|
||||
type_filter: Sequence[type[Any]] | None = None,
|
||||
debug_level = None,
|
||||
|
|
@ -99,8 +99,15 @@ class LoadTypes(Types[T]): # export
|
|||
continue
|
||||
if self.__type_filter:
|
||||
for tp in self.__type_filter:
|
||||
if issubclass(c, tp):
|
||||
break
|
||||
try:
|
||||
if issubclass(c, tp):
|
||||
break
|
||||
except Exception as e:
|
||||
log(
|
||||
ERR,
|
||||
f'Failed to check if {c} inherits from {tp} ({e})'
|
||||
)
|
||||
raise
|
||||
self._debug(f'o "{name}" is not of type {tp}')
|
||||
else:
|
||||
self._debug(f'o "{name}" doesn\'t match type filter')
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Distro(Base):
|
|||
await self.zypper(['refresh'])
|
||||
|
||||
async def _dup(self, download_only: bool) -> None:
|
||||
args = ['dup', '--force-resolution', '--auto-agree-with-licenses']
|
||||
args = ['dup']
|
||||
if download_only:
|
||||
args.append('--download-only')
|
||||
args += self.__update_extra_opts
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ options:
|
|||
Available subcommands:
|
||||
|
||||
packages (pkg) System package manager wrapper
|
||||
platform Miscellaneous platform-related comamnds
|
||||
platform Miscellaneous platform-related commands
|
||||
posix Perform various operations on a distro through its
|
||||
POSIX utility interface
|
||||
projects Project metadata evaluation for building packages
|
||||
|
|
@ -144,7 +144,7 @@ options:
|
|||
============= Running: jw-pkg.py --log-level info platform --help
|
||||
usage: jw-pkg.py platform [-h] ...
|
||||
|
||||
Miscellaneous platform-related comamnds
|
||||
Miscellaneous platform-related commands
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ def _load(text: str) -> ProjectConf:
|
|||
_tmpfiles.append(f.name)
|
||||
return ProjectConf.read(f.name)
|
||||
|
||||
|
||||
def _cleanup():
|
||||
for _p in _tmpfiles:
|
||||
os.unlink(_p)
|
||||
|
|
|
|||
Loading…
Reference in a new issue