blob: 47bcbd62effe903de8f706a744c603bd3ca5cd03 [file] [log] [blame]
Sergio Slobodrian86843702017-09-05 23:22:39 -04001#!/usr/bin/env python
2
3# Load the deb_info.txt file into a dictionary for further processing.
4deps = dict()
5pkgList = list()
6sort_list = list()
7
8with open("deb_info.txt") as f:
9 for line in f:
10 line = line.rstrip("\n")
11 linfo=line.split(":")
12 pkgList.append(linfo[0])
13 deps[linfo[0]]={}
14 deps[linfo[0]]["deb_file"] = linfo[1]
15 deps[linfo[0]]["deps"] = linfo[2].split(",")
16
17
18# First extract all packages that don't have any dependencies
19# at all with the current set of packages
20for key in deps:
21 hasDep=False
22 #print(key, " has dependencies ", deps[key]["deps"])
23 for dep in deps[key]["deps"]:
24 if dep in pkgList:
25 hasDep=True
26 if hasDep == False:
27 #print(key, " has no dependencies")
28 sort_list.append(key)
29 pkgList.remove(key)
30
31for pkg in sort_list:
32 print(deps[pkg]["deb_file"])
33
34exit(0)
35
36# The rest is for future layering of updates and
37# isn't currently used.
38
39# Now scan iterate over the remaining items and
40# add them to the sort_list if they have their
41# dependencies satisfied in the sort list.
42# Continue until the pkgList is empty
43lastLen = 0
44while len(pkgList) > 0:
45 p = pkgList
46 curLen = len(pkgList)
47 if lastLen == curLen:
48 for pkg in p:
49 sort_list.append(pkg)
50 pkgList.remove(pkg)
51 else:
52 lastLen = curLen
53 for pkg in p:
54 missingDep=False
55 for dep in deps[pkg]["deps"]:
56 if dep not in sort_list and dep in pkgList:
57 missingDep=True
58 if missingDep == False:
59 sort_list.append(pkg)
60 pkgList.remove(pkg)
61
62# Now write the packages out in the sorted order
63# this should ensure that dependent packages are
64# installed first.
65for pkg in sort_list:
66 print(deps[pkg]["deb_file"])