mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Updated resolving dependencies
This commit is contained in:
parent
ec4582b482
commit
6a01f0c9be
5 changed files with 64 additions and 110 deletions
45
slpkg/sbo/dependencies.py
Normal file
45
slpkg/sbo/dependencies.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# dependencies.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014-2022 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Slpkg is a user-friendly package manager for Slackware installations
|
||||
|
||||
# https://gitlab.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from slpkg.utils import Utils
|
||||
from slpkg.sbo.queries import SboQuery
|
||||
|
||||
|
||||
class Requires(Utils):
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def sbo(self):
|
||||
requires = SboQuery(self.name).requires()
|
||||
|
||||
for r in requires:
|
||||
sub = SboQuery(r).requires()
|
||||
for s in sub:
|
||||
requires.append(s)
|
||||
|
||||
requires.reverse()
|
||||
requires = self.remove_dbs(requires)
|
||||
|
||||
return requires
|
|
@ -1,77 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# dependency.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014-2022 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Slpkg is a user-friendly package manager for Slackware installations
|
||||
|
||||
# https://gitlab.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import sys
|
||||
from functools import lru_cache
|
||||
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
|
||||
from slpkg.sbo.queries import SboQuery
|
||||
|
||||
|
||||
class Requires(BlackList):
|
||||
"""Resolving SBo dependencies
|
||||
"""
|
||||
def __init__(self, flag):
|
||||
super().__init__()
|
||||
self.flag = flag
|
||||
self.meta = _meta_
|
||||
self.SLACKBUILDS_TXT = SboQuery(name="").names()
|
||||
self.blacklist = list(self.get_black())
|
||||
self.dep_results = []
|
||||
|
||||
@lru_cache
|
||||
def sbo(self, name):
|
||||
"""Builds all dependencies of a package
|
||||
"""
|
||||
if (self.meta.rsl_deps in ["on", "ON"] and
|
||||
"--resolve-off" not in self.flag):
|
||||
sys.setrecursionlimit(10000)
|
||||
dependencies = []
|
||||
requires = SboQuery(name).requires()
|
||||
|
||||
if requires:
|
||||
|
||||
for req in requires:
|
||||
|
||||
# avoids adding %README% as dependency and if
|
||||
# requires in the blacklist
|
||||
if "%README%" not in req and req not in self.blacklist:
|
||||
dependencies.append(req)
|
||||
|
||||
self.deep_check(tuple(dependencies))
|
||||
|
||||
return self.dep_results
|
||||
|
||||
else:
|
||||
return []
|
||||
|
||||
@lru_cache
|
||||
def deep_check(self, dependencies):
|
||||
"""Checking if dependencies are finished
|
||||
"""
|
||||
if dependencies:
|
||||
self.dep_results.append(dependencies)
|
||||
[self.sbo(dep) for dep in dependencies]
|
|
@ -42,8 +42,8 @@ from slpkg.pkg.installed import GetFromInstalled
|
|||
from slpkg.sbo.queries import SboQuery
|
||||
from slpkg.sbo.sbo_arch import SBoArch
|
||||
from slpkg.sbo.compressed import SBoLink
|
||||
from slpkg.sbo.dependency import Requires
|
||||
from slpkg.sbo.search import sbo_search_pkg
|
||||
from slpkg.sbo.dependencies import Requires
|
||||
from slpkg.sbo.slack_find import slack_package
|
||||
|
||||
|
||||
|
@ -103,33 +103,37 @@ class SBoInstall(BlackList, Utils):
|
|||
for _sbo in self.slackbuilds:
|
||||
|
||||
if _sbo in self.data and _sbo not in self.blacklist:
|
||||
sbo_deps = Requires(self.flag).sbo(_sbo)
|
||||
# sbo_deps = Requires(self.flag).sbo(_sbo)
|
||||
sbo_deps = Requires(_sbo).sbo()
|
||||
self.deps += sbo_deps
|
||||
self.deps_dict[_sbo] = self.one_for_all(sbo_deps)
|
||||
# self.deps_dict[_sbo] = self.one_for_all(sbo_deps)
|
||||
|
||||
self.deps_dict[_sbo] = sbo_deps
|
||||
|
||||
self.package_found.append(_sbo)
|
||||
|
||||
else:
|
||||
self.package_not_found.append(_sbo)
|
||||
|
||||
self.update_deps()
|
||||
|
||||
if not self.package_found:
|
||||
self.match = True
|
||||
self.matching()
|
||||
|
||||
self.master_packages, mas_src = self.sbo_version_source(
|
||||
self.package_found)
|
||||
|
||||
self.msg.done()
|
||||
|
||||
if (self.meta.rsl_deps in ["on", "ON"] and
|
||||
self.flag != "--resolve-off" and not self.match):
|
||||
self.msg.resolving()
|
||||
self.dependencies, dep_src = self.sbo_version_source(
|
||||
self.one_for_all(self.deps))
|
||||
|
||||
self.dependencies, dep_src = self.sbo_version_source(self.deps)
|
||||
|
||||
if (self.meta.rsl_deps in ["on", "ON"] and
|
||||
self.flag != "--resolve-off" and not self.match):
|
||||
self.msg.done()
|
||||
|
||||
self.clear_masters()
|
||||
|
||||
if self.package_found:
|
||||
|
@ -198,17 +202,6 @@ class SBoInstall(BlackList, Utils):
|
|||
if key == name.lower():
|
||||
self.slackbuilds[index] = value
|
||||
|
||||
def update_deps(self):
|
||||
"""Update dependencies dictionary with all package
|
||||
"""
|
||||
onelist, dependencies = [], []
|
||||
onelist = self.dimensional_list(self.deps)
|
||||
dependencies = self.remove_dbs(onelist)
|
||||
|
||||
for dep in dependencies:
|
||||
deps = Requires(self.flag).sbo(dep)
|
||||
self.deps_dict[dep] = self.one_for_all(deps)
|
||||
|
||||
def continue_to_install(self):
|
||||
"""Continue to install ?
|
||||
"""
|
||||
|
@ -235,7 +228,7 @@ class SBoInstall(BlackList, Utils):
|
|||
"""Clear master slackbuilds if already exist in dependencies
|
||||
or if added to install two or more times
|
||||
"""
|
||||
self.master_packages = self.remove_dbs(self.master_packages)
|
||||
# self.master_packages = self.remove_dbs(self.master_packages)
|
||||
for mas in self.master_packages:
|
||||
|
||||
if mas in self.dependencies:
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from slpkg.utils import Utils
|
||||
from slpkg.graph import Graph
|
||||
from slpkg.messages import Msg
|
||||
from slpkg.blacklist import BlackList
|
||||
|
@ -31,14 +30,14 @@ from slpkg.__metadata__ import MetaData as _meta_
|
|||
from slpkg.pkg.find import find_package
|
||||
|
||||
from slpkg.sbo.queries import SboQuery
|
||||
from slpkg.sbo.dependency import Requires
|
||||
from slpkg.sbo.dependencies import Requires
|
||||
from slpkg.sbo.search import sbo_search_pkg
|
||||
|
||||
from slpkg.binary.search import search_pkg
|
||||
from slpkg.binary.dependency import Dependencies
|
||||
|
||||
|
||||
class TrackingDeps(BlackList, Utils):
|
||||
class TrackingDeps(BlackList):
|
||||
"""Views tree of dependencies and also
|
||||
highlights packages with the colour green
|
||||
if already installed and the colour red
|
||||
|
@ -57,8 +56,6 @@ class TrackingDeps(BlackList, Utils):
|
|||
self.red = self.meta.color["RED"]
|
||||
self.endc = self.meta.color["ENDC"]
|
||||
self.requires = []
|
||||
self.dependencies = []
|
||||
self.dependencies_list = []
|
||||
self.deps_dict = {}
|
||||
self.init_flags()
|
||||
|
||||
|
@ -78,9 +75,6 @@ class TrackingDeps(BlackList, Utils):
|
|||
self.repositories()
|
||||
|
||||
if self.find_pkg:
|
||||
self.dependencies_list.reverse()
|
||||
self.requires = self.dimensional_list(self.dependencies_list)
|
||||
self.dependencies = self.remove_dbs(self.requires)
|
||||
|
||||
if self.dependencies == []:
|
||||
self.dependencies = ["No dependencies"]
|
||||
|
@ -152,7 +146,7 @@ class TrackingDeps(BlackList, Utils):
|
|||
self.find_pkg = sbo_search_pkg(self.name)
|
||||
|
||||
if self.find_pkg:
|
||||
self.dependencies_list = Requires(self.flag).sbo(self.name)
|
||||
self.dependencies = Requires(self.name).sbo()
|
||||
|
||||
else:
|
||||
PACKAGES_TXT = self.read_file(
|
||||
|
@ -163,7 +157,7 @@ class TrackingDeps(BlackList, Utils):
|
|||
|
||||
if self.find_pkg:
|
||||
self.black = list(self.get_black())
|
||||
self.dependencies_list = Dependencies(
|
||||
self.dependencies = Dependencies(
|
||||
self.repo, self.black).binary(self.name, self.flag)
|
||||
|
||||
def sbo_case_insensitive(self):
|
||||
|
@ -219,7 +213,7 @@ class TrackingDeps(BlackList, Utils):
|
|||
if self.repo == "sbo":
|
||||
|
||||
for dep in dependencies:
|
||||
deps = Requires(flag="").sbo(dep)
|
||||
deps = Requires(dep).sbo()
|
||||
|
||||
if dep not in self.deps_dict.values():
|
||||
self.deps_dict[dep] = self.dimensional_list(deps)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
|
||||
from slpkg.splitting import split_package
|
||||
|
||||
|
@ -51,9 +50,9 @@ class Utils:
|
|||
return one_list
|
||||
|
||||
def remove_dbs(self, double):
|
||||
"""Removes double item from list
|
||||
"""Removes double items from list
|
||||
"""
|
||||
return list(OrderedDict.fromkeys(double))
|
||||
return list(dict.fromkeys(double))
|
||||
|
||||
def read_file(self, registry):
|
||||
"""Returns reading file
|
||||
|
|
Loading…
Reference in a new issue