blob: 8d7989b4872be6d82442f8e9ab9e21c3e9bcc1a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#!/usr/bin/python
import sys
#sys.path.append('/usr/lib/anaconda')
import os
import os.path
import rpm
import string
import comps
depcheck = None
def cmpHeaderByName(h1, h2):
n1 = string.lower(h1['name'])
n2 = string.lower(h2['name'])
if n1 < n2:
return -1
elif n1 == n2:
return 0;
return 1
if len(sys.argv) != 3:
print "pkgorder <toppath> <arch>"
sys.exit(1)
arch = sys.argv[2]
distDir = os.path.normpath(sys.argv[1])
if not os.path.isdir(distDir):
print "error: %s is not a directory" % distDir
sys.exit(1)
hdlist = comps.HeaderListFromFile(distDir + "/RedHat/base/hdlist", noscore = 1)
comps = comps.ComponentSet(distDir + "/RedHat/base/comps", hdlist,
arch = arch, matchAllLang = 1)
pkgOrder = []
pkgHash = {}
# add kernels
for p in hdlist.keys():
if ((len(p) >= 7 and p[:7] == "kernel-")
and not (len(p) >= 10 and p[:10] == "kernel-doc")
and not (len(p) >= 13 and p[:13] == "kernel-source")
and not (len(p) >= 11 and p[:11] == "kernel-BOOT")):
hdlist[p].selected = 1
pkgOrder.append(hdlist[p].h)
pkgHash[hdlist[p].h] = None
# for each comp, starting with base, list the packages
# in alphabetical order.
for comp in comps:
list = []
if comp.name != 'Everything':
comp.select(1)
for p in hdlist.selected():
if not pkgHash.has_key (p.h):
list.append(p.h)
list.sort(cmpHeaderByName)
for p in list:
pkgOrder.append(p)
pkgHash[p] = None
comp.unselect(1)
# add all rpms not in the comps file at the end
list = []
for p in hdlist.packages.values():
if not pkgHash.has_key(p.h):
list.append(p.h)
list.sort(cmpHeaderByName)
for p in list:
pkgOrder.append(p)
# not needed anymore
pkgHash = {}
testpath = '/tmp/splitdistro-' + str(os.getpid())
os.system ("mkdir -p " + testpath + "/var/lib/rpm")
db = rpm.opendb(1, testpath)
ts = rpm.TransactionSet(testpath, db)
for h in pkgOrder:
ts.add(h, h, 'i')
ts.order()
if depcheck:
deps = ts.depcheck()
if deps:
print "unresolved dependencies:"
for dep in deps:
print dep
for p in ts.getKeys():
print p[1000000]
os.system ("rm -rf " + testpath)
|