Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New osc plugin 'cycle': help visualizing build cycles #992

Merged
merged 1 commit into from
Jul 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ("}")