Skip to content
Snippets Groups Projects
Commit 7e204c18 authored by Chih-Hsuan Yen's avatar Chih-Hsuan Yen
Browse files

Don't take transitive dependencies into consideration

Fixes https://bugs.archlinux.org/task/64022
parent dfa46abb
Branches dvzrv/revoke_dvzrv
No related tags found
No related merge requests found
......@@ -31,31 +31,6 @@ implicit_provides = {
'java-environment': ['java-runtime'],
}
def single_covered(depend):
"Returns full coverage tree of one package, with loops broken"
covered = set()
todo = set([depend])
while todo:
i = todo.pop()
covered.add(i)
pac = package.load_from_db(i)
if pac is None:
continue
todo |= set(pac["depends"]) - covered
return covered - set([depend])
def getcovered(dependlist):
"""
Returns full coverage tree set, without packages
from self-loops (iterable of package names)
"""
covered = set()
for d in dependlist:
covered |= single_covered(d)
return covered
def getcustom(pkginfo):
custom_name = {'^mingw-': ['mingw-w64-crt'],}
custom_depend = set()
......@@ -83,28 +58,20 @@ def analyze_depends(pkginfo):
# compute needed dependencies + recursive
dependlist = set(pkginfo.detected_deps.keys())
indirectdependlist = getcovered(dependlist)
customlist = getcustom(pkginfo)
for i in indirectdependlist:
infos.append(("dependency-covered-by-link-dependence %s", i))
needed_depend = dependlist | indirectdependlist | customlist
# the minimal set of needed dependencies
smartdepend = set(dependlist) - indirectdependlist
needed_depend = dependlist | customlist
# Find all the covered dependencies from the PKGBUILD
pkginfo.setdefault("depends", [])
explicitdepend = set(pkginfo["depends"])
implicitdepend = getcovered(explicitdepend)
pkgbuild_depend = explicitdepend | implicitdepend
pkgbuild_depend = set(pkginfo["depends"])
# Include the optdepends from the PKGBUILD
pkginfo.setdefault("optdepends", [])
optdepend = set(pkginfo["optdepends"])
optdepend |= getcovered(optdepend)
# Get the provides so we can reference them later
# smartprovides : depend => (packages provided by depend)
smartprovides = getprovides(smartdepend | explicitdepend)
smartprovides = getprovides(dependlist | pkgbuild_depend)
# The set of all provides for detected dependencies
allprovides = set()
......@@ -112,7 +79,7 @@ def analyze_depends(pkginfo):
allprovides |= plist
# Do the actual message outputting stuff
for i in smartdepend:
for i in dependlist:
# if the needed package is itself:
if i == pkginfo["name"]:
continue
......@@ -145,17 +112,14 @@ def analyze_depends(pkginfo):
if pkginfo["name"].startswith('lib32-') and i == pkginfo["name"].partition('-')[2]:
continue
# the package provides an important dependency
if i in smartprovides and (smartprovides[i] & smartdepend):
if i in smartprovides and (smartprovides[i] & dependlist):
continue
# a needed dependency is superfluous it is implicitly satisfied
if i in implicitdepend and (i in smartdepend or i in indirectdependlist):
warnings.append(("dependency-already-satisfied %s", i))
# a dependency is unneeded if:
# it is not in the depends as we see them
# it does not pull some needed dependency which provides it
elif i not in needed_depend and i not in allprovides:
warnings.append(("dependency-not-needed %s", i))
infos.append(("depends-by-namcap-sight depends=(%s)", ' '.join(smartdepend) ))
infos.append(("depends-by-namcap-sight depends=(%s)", ' '.join(dependlist) ))
return errors, warnings, infos
......
......@@ -61,8 +61,6 @@ class SplitPkgMakedepsRule(PkgbuildRule):
if "makedepends" in pkginfo:
global_deps.update(pkginfo["makedepends"])
global_deps |= Namcap.depends.getcovered(global_deps)
# Read dependencies specified in subpackages
local_deps = set()
for s in pkginfo.subpackages:
......
......@@ -116,7 +116,7 @@ epoch=2
arch=('i686' 'x86_64')
url="http://www.example.com/"
license=('GPL')
makedepends=('make' 'python')
makedepends=('make' 'python' 'zlib')
checkdepends=('perl')
options=('!libtool')
source=(ftp://ftp.example.com/pub/mypackage-0.1.tar.gz)
......
......@@ -50,8 +50,8 @@ class DependsTests(unittest.TestCase):
self.pkginfo["depends"] = {"readline": []}
self.pkginfo.detected_deps = {"glibc": [], "readline": []}
e, w, i = Namcap.depends.analyze_depends(self.pkginfo)
unexpected_w = [('dependency-already-satisfied %s', 'readline')]
self.assertEqual(e, [])
expected_e = [('dependency-detected-not-included %s (%s)', ('glibc', ''))]
self.assertEqual(e, expected_e)
self.assertEqual(w, [])
# info is verbose and beyond scope, skip it
......@@ -60,9 +60,8 @@ class DependsTests(unittest.TestCase):
self.pkginfo["depends"] = {"pyalpm": [], "python": []}
self.pkginfo.detected_deps = {"pyalpm": [], "python": []}
e, w, i = Namcap.depends.analyze_depends(self.pkginfo)
expected_w = [('dependency-already-satisfied %s', 'python')]
self.assertEqual(e, [])
self.assertEqual(w, expected_w)
self.assertEqual(w, [])
# info is verbose and beyond scope, skip it
# vim: set ts=4 sw=4 noet:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment