MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / D_dependencies_handler

Function D_dependencies_handler

src/packagedcode/alpine.py:962–1052  ·  view source on GitHub ↗

Return a list of dependent packages from a dependency string and from previous dependencies. Dependencies can be either: - a package name with or without a version constraint - a path to something that is provided by some package(similar to RPMs) such as /bin/sh - a shared objec

(value, dependencies=None, **kwargs)

Source from the content-addressed store, hash-verified

960
961
962def D_dependencies_handler(value, dependencies=None, **kwargs):
963 """
964 Return a list of dependent packages from a dependency string and from previous dependencies.
965 Dependencies can be either:
966 - a package name with or without a version constraint
967 - a path to something that is provided by some package(similar to RPMs) such as /bin/sh
968 - a shared object (prefixed with so:)
969 - a pkgconfig dependency where pkgconfig is typically also part of the deps
970 and these are prefixed with pc:
971 - a command prefixed with cmd:
972
973 Note that these exist the same way in the p: provides field.
974
975 An exclamation prefix negates the dependency.
976 The operators can be ><=~
977
978 For example:
979 D:aaudit a52dec=0.7.4-r7 acf-alpine-baselayout>=0.5.7 /bin/sh
980 D:so:libc.musl-x86_64.so.1 so:libmilter.so.1.0.2
981 D:freeradius>3
982 D:lua5.1-bit32<26
983 D:!bison so:libc.musl-x86_64.so.1
984 D:python3 pc:atk>=2.15.1 pc:cairo pc:xkbcommon>=0.2.0 pkgconfig
985 D:bash colordiff cmd:ssh cmd:ssh-keygen cmd:ssh-keyscan cmd:column
986 D:cmd:nginx nginx-mod-devel-kit so:libc.musl-aarch64.so.1
987 D:mu=1.4.12-r0 cmd:emacs
988 """
989 # operate on a copy for safety and create an empty list on first use
990 dependencies = dependencies[:] if dependencies else []
991 for dep in value.split():
992 if dep.startswith('!'):
993 # ignore the "negative" deps, we cannot do much with it
994 # they are more of a hints for the dep solver than something
995 # actionable for origin reporting
996 continue
997 if dep.startswith('/'):
998 # ignore paths to a command for now as we cannot do
999 # much with them yet until we can have a Package URL for them.
1000 continue
1001 if dep.startswith('cmd:'):
1002 # ignore commands for now as we cannot do much with them yet until
1003 # we can have a Package URL for them.
1004 continue
1005 if dep.startswith('so:'):
1006 # ignore the shared object with an so: prexi for now as we cannot do
1007 # much with them yet until we can have a Package URL for them.
1008 # TODO: see how we could handle these and similar used elsewhere
1009 continue
1010 is_pc = False
1011 if dep.startswith('pc:'):
1012 is_pc = True
1013 # we strip the 'pc:' prefix and treat a pc: dependency the same as
1014 # other depends
1015 dep = dep[3:]
1016
1017 requirement = None
1018 version = None
1019 is_pinned = False

Callers

nothing calls this directly

Calls 5

to_stringMethod · 0.80
splitMethod · 0.45
joinMethod · 0.45
appendMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected