Skip to content

Commit

Permalink
Merge pull request #992 from DimStar77/visualize-cycles
Browse files Browse the repository at this point in the history
New osc plugin 'cycle': help visualizing build cycles
  • Loading branch information
DimStar77 committed Jul 10, 2017
2 parents 17098f7 + 2d8122f commit 5800bb9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions osc-cycle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2017 SUSE Linux Products GmbH
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import osc.core

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:
print ("\"%s\"" % pkgname)
deps = ET.fromstring(get_dependson(apiurl, "openSUSE:Factory", "standard", "x86_64", [pkgname]))

pkg = deps.find('package')
for deps in pkg.findall('pkgdep'):
if deps.text in args:
print ("\"%s\" -> \"%s\"" % (deps.text, pkgname))
print ("}")

0 comments on commit 5800bb9

Please sign in to comment.