summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Barker <paul@paulbarker.me.uk>2014-11-15 16:00:44 +0000
committerPaul Barker <paul@paulbarker.me.uk>2014-11-15 16:00:44 +0000
commit127b371319974b0c585969c234f85b2d5c860e34 (patch)
tree559fc2e6316051c46022da623bf3fb5855866f59
parent335fb1de6768d51811a4c90dfa122dc9a5161717 (diff)
downloadopkg-utils-127b371319974b0c585969c234f85b2d5c860e34.tar.gz
opkg-utils-127b371319974b0c585969c234f85b2d5c860e34.tar.bz2
opkg-utils-127b371319974b0c585969c234f85b2d5c860e34.zip
opkg-show-deps: Add comments to explain code
There was some confusion discussed on the mailing list about what the various loops in this script were doing. Comments are added to explain the behaviour, hopefully preventing any confusion in the future. Thanks to Pavel Zubarev for bringing this up and helping me to clarify what the current code is doing. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
-rwxr-xr-xopkg-show-deps9
1 files changed, 9 insertions, 0 deletions
diff --git a/opkg-show-deps b/opkg-show-deps
index 93465f3..3c3be6a 100755
--- a/opkg-show-deps
+++ b/opkg-show-deps
@@ -53,23 +53,32 @@ for i in list(packages.packages.keys()):
provider_hash[prov].append(p)
def find_package(name):
+ # Return all providers of the named package
if name in provider_hash:
return provider_hash[name]
return None
def process_dep(dep):
+ # Add a provider of the given dependency to the list of required packages
+ # unless a provider is already present in this list.
dep = re.sub("\s*\(.*\)", "", dep)
dep = re.sub("\*$", "", dep)
newpkgs = find_package(dep)
if newpkgs:
+ # Loop over all providers of the dependency and return early if any
+ # provider is already in the list of required pacakges - we only need
+ # one provider of this dependency.
for newpkg in newpkgs:
if newpkg.package in required:
return
+ # Select the first provider, add it to the required packages list and
+ # process its dependencies
recurse(newpkgs[0])
else:
sys.stderr.write("unsatisfied dependency of %s on '%s'\n" % (pkg.package, dep))
def recurse(pkg):
+ # Add a package to the required list and process its dependencies
required[pkg.package] = 1
if pkg.depends:
deps = split_list(pkg.depends)