slpkg/slpkg/binary/dependency.py

61 lines
2 KiB
Python
Raw Normal View History

2014-11-01 06:28:40 +02:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
# dependency.py file is part of slpkg.
2016-01-03 01:00:00 +02:00
# Copyright 2014-2016 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
2014-11-01 06:28:40 +02:00
# All rights reserved.
2014-12-19 06:57:56 +02:00
# Slpkg is a user-friendly package manager for Slackware installations
2014-11-01 06:28:40 +02:00
# https://github.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/>.
2015-05-28 06:07:13 +03:00
2014-11-01 06:28:40 +02:00
import sys
2014-11-22 11:16:39 +02:00
from slpkg.toolbar import status
2015-06-08 06:28:49 +03:00
from slpkg.__metadata__ import MetaData as _meta_
2014-11-01 06:28:40 +02:00
2015-08-21 02:15:43 +03:00
from slpkg.binary.greps import Requires
2014-11-01 06:28:40 +02:00
2015-01-14 16:31:10 +02:00
class Dependencies(object):
2015-08-05 06:58:28 +03:00
"""Resolving binary dependencies
"""
2016-02-24 10:08:15 +02:00
def __init__(self, repo, black):
self.repo = repo
2015-06-18 14:42:33 +03:00
self.black = black
2015-01-14 16:31:10 +02:00
self.dep_results = []
2015-06-08 06:28:49 +03:00
self.meta = _meta_
2015-01-14 16:31:10 +02:00
2015-06-13 08:30:37 +03:00
def binary(self, name, flag):
2015-09-27 12:11:01 +03:00
"""Build all dependencies of a package
2015-06-05 14:42:52 +03:00
"""
2015-09-08 02:29:07 +03:00
if self.meta.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
2015-09-15 16:01:06 +03:00
sys.setrecursionlimit(10000)
dependencies = []
requires = Requires(name, self.repo).get_deps()
if requires:
for req in requires:
status(0)
if req and req not in self.black:
dependencies.append(req)
if dependencies:
self.dep_results.append(dependencies)
for dep in dependencies:
self.binary(dep, flag)
return self.dep_results
else:
return []