Skip to content

Instantly share code, notes, and snippets.

@Chocimier
Last active July 30, 2022 03:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chocimier/de76441493ec7775c201dac0bb03ced5 to your computer and use it in GitHub Desktop.
Save Chocimier/de76441493ec7775c201dac0bb03ced5 to your computer and use it in GitHub Desktop.
cycles in xbps-packages templates
# usage:
# cd $XBPS_DISTDIR
# ./deps.sh
# ./loops.py builddeps $XBPS_DISTDIR/srcpkgs
mkdir -p builddeps
find srcpkgs -mindepth 1 -maxdepth 1 | cut -d/ -f2 | while read pkg; do echo ' '$pkg; ./xbps-src show-build-deps $pkg > builddeps/$pkg; done
#!/usr/bin/env python3
import os
import sys
import networkx as nx
G = nx.DiGraph()
for i in os.listdir(sys.argv[1]):
ii = os.path.realpath(sys.argv[2] + '/' + i).rpartition('/')[2]
with open(sys.argv[1] + '/' + i) as deps:
for j in deps:
j = j.strip()
jj = os.path.realpath(sys.argv[2] + '/' + j).rpartition('/')[2]
G.add_edge(ii, jj)
for c in nx.strongly_connected_components(G):
if len(c) > 1:
print(c)
print(nx.to_dict_of_lists(G.subgraph(c).copy()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment