mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 20:13:32 +01:00
62 lines
1.2 KiB
Python
62 lines
1.2 KiB
Python
|
|
#!/usr/bin/python
|
||
|
|
# -*- coding: iso-8859-15 -*-
|
||
|
|
|
||
|
|
import os
|
||
|
|
import dircache
|
||
|
|
import linecache
|
||
|
|
import fileinput
|
||
|
|
import glob
|
||
|
|
import subprocess
|
||
|
|
from sets import Set
|
||
|
|
|
||
|
|
all_deps = Set()
|
||
|
|
dep_tree = {}
|
||
|
|
order = []
|
||
|
|
|
||
|
|
def find_proj_path(name):
|
||
|
|
return "/home/jan/local/src/cvs.stable/proj/" + name
|
||
|
|
|
||
|
|
def read_deps(cur):
|
||
|
|
path = find_proj_path(cur)
|
||
|
|
os.chdir(path)
|
||
|
|
p = subprocess.Popen("LD_LIBRARY_PATH= make echo-prereq | sed '/PREREQ_BUILD *=/ !d; s/.*=//'", shell=True, stdout=subprocess.PIPE)
|
||
|
|
r = Set()
|
||
|
|
for d in p.stdout.read().split():
|
||
|
|
r.add(d)
|
||
|
|
if cur in r:
|
||
|
|
r.remove(cur)
|
||
|
|
return r
|
||
|
|
|
||
|
|
def build_tree(cur):
|
||
|
|
if cur in all_deps:
|
||
|
|
return 0
|
||
|
|
all_deps.add(cur)
|
||
|
|
deps = read_deps(cur)
|
||
|
|
for d in deps:
|
||
|
|
build_tree(d)
|
||
|
|
dep_tree[cur] = deps
|
||
|
|
return len(deps)
|
||
|
|
|
||
|
|
def create_bottom_up_order(cur):
|
||
|
|
build_tree(cur)
|
||
|
|
while len(all_deps):
|
||
|
|
for d in all_deps:
|
||
|
|
if not len(dep_tree[d]):
|
||
|
|
break
|
||
|
|
else:
|
||
|
|
print "none of the following modules has no dependencies:"
|
||
|
|
print all_deps
|
||
|
|
return -1
|
||
|
|
order.append(d)
|
||
|
|
all_deps.remove(d)
|
||
|
|
for k in dep_tree.keys():
|
||
|
|
if d in dep_tree[k]:
|
||
|
|
dep_tree[k].remove(d)
|
||
|
|
return 1
|
||
|
|
|
||
|
|
def build(cur):
|
||
|
|
create_bottom_up_order(cur)
|
||
|
|
|
||
|
|
build("jux2")
|
||
|
|
print dep_tree
|
||
|
|
print order
|