App.is_installed(): Add method
The installed state of a project is judged by the proofs of installation, which differ per subpackage: make/project.conf in the dev tree or /opt proves the -devel package or a buildable checkout, a VERSION file in the project directory or /usr/share/doc/packages the -run package. Add is_installed(), which answers the proof question for a given subpackage by searching the per-subpackage locations. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
This commit is contained in:
parent
a269631e92
commit
433fe695db
1 changed files with 35 additions and 0 deletions
|
|
@ -98,6 +98,29 @@ class App(Base):
|
|||
return None
|
||||
raise Exception('No project path found for module "{}"'.format(name))
|
||||
|
||||
@cache
|
||||
def __is_installed(self, name: str, devel: bool) -> bool:
|
||||
# devel: the project is in the dev tree or the -devel
|
||||
# package is installed: make/project.conf is present.
|
||||
# run: the -run package is installed: a VERSION file is
|
||||
# present in the project directory or
|
||||
# /usr/share/doc/packages.
|
||||
if devel and name == self.__top_name:
|
||||
# the topdir is the project's own buildable checkout
|
||||
if os.path.exists(f'{self.__topdir}/make/project.conf'):
|
||||
return True
|
||||
search, file = (
|
||||
(self.__projs_root, self.___opt_root),
|
||||
'/make/project.conf'
|
||||
) if devel else (
|
||||
(self.__projs_root, '/usr/share/doc/packages'),
|
||||
'/VERSION'
|
||||
)
|
||||
for root in search:
|
||||
if root is not None and os.path.exists(f'{root}/{name}{file}'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __find_dir(
|
||||
self,
|
||||
name: str,
|
||||
|
|
@ -404,6 +427,18 @@ class App(Base):
|
|||
raise Exception('No distro object')
|
||||
return self.__distro
|
||||
|
||||
def is_installed(
|
||||
self,
|
||||
name: str,
|
||||
devel: bool = False,
|
||||
) -> bool:
|
||||
"""True if the project is installed: for devel,
|
||||
make/project.conf is present in the dev tree or /opt; for
|
||||
run, a VERSION file is present in the project directory
|
||||
or /usr/share/doc/packages.
|
||||
"""
|
||||
return self.__is_installed(name, devel)
|
||||
|
||||
def find_dir(
|
||||
self,
|
||||
name: str,
|
||||
|
|
|
|||
Loading…
Reference in a new issue