Ahoj, Dňa Sat, 13 Sep 2014 21:46:43 +0200 lee <l...@yun.yagibdah.de> napísal:
> Slavko <li...@slavino.sk> writes: > > > BTW, if someone is interested in, while this investigation i > > generated graphs of dependencies on some systemd packages on my > > system, they will be accessible for some time here: > > > > http://anfo.slavino.sk/libpam-systemd.png > > http://anfo.slavino.sk/libsystemd-daemon0.png > > http://anfo.slavino.sk/libsystemd-journal0.png > > http://anfo.slavino.sk/libsystemd-login0.png > > How did you create these? Some recursive call for "aptitude search ?depends(package)" in the python script, with result putting into python's dict and then generate graphviz from this dict. I attach the script, but the starting packages (systemd) and the result's path are hardcoded in it. > Would you mind if I downloaded the images and put them on my web > server, potentially with some explanation? I've been sending some > posts to debian-devel, and these graphs might come in handy sooner or > later. Consider them as public domain, but don't forget, that they displays dependencies of packages installed in my system only, not whole dependency tree. > Especially the last one is rather interesting since it clearly shows > that basically the whole system depends on systemd. > > How would such graphs look for sysvinit? Good question. When i will have some time, i will inspect them or you can try to generate own. -- Slavko http://slavino.sk
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2014 Slavko <li...@slavino.sk> # # This program 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 2 of the License, or # (at your option) any later version. # import subprocess import re import pygraphviz as pgv maincmd = [ 'aptitude', 'search', '-w 60', '-F %p %v %V' ] reparts = re.compile('^ *(\S*) +(\S*) +(\S*)') def getpkglist(pattern): """get main packages list %patern% the aptidude's search apttern %return% list of [ name, version, canditate] """ proces = subprocess.Popen(maincmd + [pattern], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = proces.communicate() # TODO raise exception on stderr retlist = [] for line in stdout.splitlines(): name, version, candidate = reparts.search(line).groups() retlist.append( [name, version, candidate] ) return retlist def getpkgdeps(pkgname): """ recursively get dependencies %pkname% the package name "return" nothing """ pattern = "~i?depends(^%s$) ~ramd64 ?not(-dev$)" % pkgname deplist = getpkglist(pattern) for item in deplist: name = item[0] try: pkgdict[pkgname].add(name) except KeyError: pkgdict[pkgname] = set([name]) if not pkgdict.has_key(name): getpkgdeps(name) baselist = [] for item in getpkglist("~isystemd ?not(systemd-shim) ?not(dh-systemd) ?not(libsystemd-id128) ~ramd64"): name = item[0] baselist += [name] for name in baselist: pkgdict = dict() print name print "*" * 40 try: getpkgdeps(name) # suppress backtrace for not patient except KeyboardInterrupt: print "KeyboardInterrupt" exit(1) # create graphviz digraph from dict G=pgv.AGraph(directed=True) G.node_attr['style'] = "filled" G.node_attr['color']= 'darkgoldenrod1' G.node_attr['fillcolor'] = "moccasin" for key in pkgdict.keys(): for depend in pkgdict[key]: # red nodes for root packages if key in baselist: G.add_node(key, shape="box", peripheries=2, style="filled", color='firebrick', fillcolor="lightpink") if depend in baselist: G.add_node(depend, shape="box", peripheries=2, style="filled", color='firebrick', fillcolor="lightpink") # green nodes for leafs if not pkgdict.has_key(depend): G.add_node(depend, style="filled", color='green4', fillcolor="palegreen") G.add_edge(key, depend, dir="back") # all root packages in the same level G.add_subgraph(baselist,rank='same') G.layout("dot") G.write("/tmp/%s.dot" % name) G.draw("/tmp/%s.png" % name)
signature.asc
Description: PGP signature