summaryrefslogtreecommitdiff
path: root/recipes/yum/files/yum-install-recommends.py
blob: 64716f2c3e013dc5c0fdd491d01cbe7674e58c7a (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
#!/usr/bin/env python
import os, sys

root = sys.argv[1]
installcmd = sys.argv[2]

#
# Take an rpm image and look through for Recommends:. For each recommends 
# found, try and install any matching packages including any Recommends for
# packages installed by us.
#


def get_recommends():
    deps = []
    output = os.popen("rpm --root %s -aq --recommends" % (root))
    lines = output.readlines()
    for line in lines:
        line = line.replace("(none)","")
        if line:
            deps.append(line.split()[0])
    return deps

processed = []

while True:
    toinstall = []
    recommends = set(get_recommends())
    for item in recommends:
        if item not in processed:
            toinstall.append(item)
    if len(toinstall) != 0:
        print "Installing %s" % " ".join(toinstall)
        os.system("%s %s" % (installcmd, " ".join(toinstall)))
    else:
        break
    processed.extend(toinstall)