mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-28 11:35:25 +02:00
App, .cmds.Cmd: Add .distro property
DistroBase's option --id is now redundant to the new global option --distro-id in the App class, so remove --id. The only added value DistroBase then brings to the table is its .distro property, which can be provided by App just fine at this point, given that App has all it needs to construct a Distro object, so add .distro to App and remove the entire DistroBase class. For convenience, also make App.distro available as a newly added cmds.Cmd.distro property. This also obviates the need for the distro-related properties in the .distro.Cmd class, remove all that. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
bd38700f67
commit
18c16917b2
5 changed files with 27 additions and 60 deletions
|
|
@ -5,7 +5,11 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TypeAlias
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeAlias
|
||||
import os, sys, pwd, re
|
||||
|
||||
import os, sys, argparse, pwd, re
|
||||
from functools import lru_cache
|
||||
|
|
@ -13,6 +17,7 @@ from enum import Enum, auto
|
|||
|
||||
from .lib.App import App as Base
|
||||
from .lib.log import *
|
||||
from .lib.Distro import Distro
|
||||
|
||||
# Meaning of pkg.requires.xxx variables
|
||||
# build: needs to be built and installed before this can be built
|
||||
|
|
@ -218,6 +223,7 @@ class App(Base):
|
|||
self.__distro_id: str|None = None
|
||||
self.__distro_name: str|None = None
|
||||
self.__distro_codename: str|None = None
|
||||
self.__distro: Distro|None = None
|
||||
self.__os_cascade: list[str]|None = None
|
||||
self.__res_cache = ResultCache()
|
||||
self.__topdir: str|None = None
|
||||
|
|
@ -380,6 +386,13 @@ class App(Base):
|
|||
|
||||
raise RuntimeError('Failed to get GNU triplet from running machine')
|
||||
|
||||
@property
|
||||
def distro(self) -> Distro:
|
||||
if self.__distro is None:
|
||||
ret = Distro.instantiate(self.distro_id, ec=self.exec_context)
|
||||
self.__distro = ret
|
||||
return self.__distro
|
||||
|
||||
def find_dir(self, name: str, search_subdirs: list[str]=[], search_absdirs: list[str]=[], pretty: bool=True):
|
||||
return self.__find_dir(name, search_subdirs, search_absdirs, pretty)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue