openSUSE-release-tools/osc-cycle.py
Jimmy Berry 6069245350 Remove SUSE copyright, warranty, and license headers.
Distinct copyrights were left as I do not wish to track down commit
history to ensure it properly documents the copyright holders. Also left
non-GPLv2 licenses and left bs_copy untouched as a mirror from OBS.

Already have a mix of with and without headers and even OBS does not place
on majority of files. If SUSE lawyers have an issue it will come up in
legal review for Factory.
2018-08-23 19:18:06 -05:00

36 lines
1.1 KiB
Python

import osc.core
from osc.core import get_dependson
from xml.etree import cElementTree as ET
def do_cycle(self, subcmd, opts, *args):
"""${cmd_name}: Try to visualize build dependencies between the package list specified
Examples:
osc cycle <pkg1> <pkg2> <pkg3> # outputs a dot file showing the relation between the listed packages
"""
if len(args) == 0:
print ("No packages were specified, no chain to draw")
apiurl = self.get_api_url()
print ("digraph depgraph {")
for pkgname in args:
pkgname = pkgname.strip(',')
if len(pkgname) == 0: continue
try:
deps = ET.fromstring(get_dependson(apiurl, "openSUSE:Factory", "standard", "x86_64", [pkgname]))
pkg = deps.find('package')
print ("\"%s\"" % pkgname)
for deps in pkg.findall('pkgdep'):
if deps.text in args:
print ("\"%s\" -> \"%s\"" % (deps.text, pkgname))
except:
# Ignore packages that do not exist
print ("[color=red]")
continue
print ("}")