]>
Commit | Line | Data |
---|---|---|
1 | # vi: encoding=utf-8 ts=8 sts=4 sw=4 et | |
2 | ||
3 | import re | |
4 | import string | |
5 | ||
6 | import chroot | |
7 | import util | |
8 | import upgrade | |
9 | ||
10 | def install_br(r, b): | |
11 | # ignore internal rpm dependencies, see lib/rpmns.c for list | |
12 | ignore_br = re.compile(r'^\s*(rpmlib|cpuinfo|getconf|uname|soname|user|group|mounted|diskspace|digest|gnupg|macro|envvar|running|sanitycheck|vcheck|signature|verify|exists|executable|readable|writable)\(.*') | |
13 | ||
14 | tmpdir = "/tmp/BR." + b.b_id[0:6] | |
15 | chroot.run("install -m 700 -d %s" % tmpdir) | |
16 | cmd = "cd rpm/SPECS; TMPDIR=%s rpmbuild --nobuild %s %s 2>&1" \ | |
17 | % (tmpdir, b.bconds_string(), b.spec) | |
18 | f = chroot.popen(cmd) | |
19 | rx = re.compile(r"^\s*([^\s]+) .*is needed by") | |
20 | needed = {} | |
21 | b.log_line("checking BR") | |
22 | for l in f.xreadlines(): | |
23 | b.log_line("rpm: %s" % l.rstrip()) | |
24 | m = rx.search(l) | |
25 | if m and not ignore_br.match(l): | |
26 | needed[m.group(1)] = 1 | |
27 | f.close() | |
28 | chroot.run("rm -rf %s" % tmpdir) | |
29 | if len(needed) == 0: | |
30 | b.log_line("no BR needed") | |
31 | return | |
32 | nbr = "" | |
33 | for bre in needed.keys(): | |
34 | nbr = nbr + " " + re.escape(bre) | |
35 | br = string.strip(nbr) | |
36 | b.log_line("updating poldek cache...") | |
37 | chroot.run("poldek --up --upa", user = "root", logfile = b.logfile) | |
38 | # check conflicts in BRed packages | |
39 | b.log_line("checking conflicting packages in BRed packages") | |
40 | f = chroot.popen("poldek --test --noask --caplookup -Q -v --upgrade %s" % br, user = "root") | |
41 | rx = re.compile(r".*conflicts with installed ([^\s]+)-[^-]+-[^-]+$") | |
42 | conflicting = {} | |
43 | for l in f.xreadlines(): | |
44 | b.log_line("poldek: %s" % l.rstrip()) | |
45 | m = rx.search(l) | |
46 | if m: conflicting[m.group(1)] = 1 | |
47 | f.close() | |
48 | if len(conflicting) == 0: | |
49 | b.log_line("no conflicts found") | |
50 | else: | |
51 | b.log_line("uninstalling conflicting packages") | |
52 | err = upgrade.close_killset(conflicting) | |
53 | if err != "": | |
54 | util.append_to(b.logfile, err) | |
55 | b.log_line("error: conflicting packages uninstallation failed") | |
56 | else: | |
57 | k = string.join(conflicting.keys()) | |
58 | b.log_line("removing %s" % k) | |
59 | res = chroot.run("poldek --noask --erase %s" % k, logfile = b.logfile, user = "root") | |
60 | if res != 0: | |
61 | b.log_line("package removal failed") | |
62 | return res | |
63 | b.log_line("installing BR: %s" % br) | |
64 | res = chroot.run("poldek --noask --caplookup -Q -v --upgrade %s" % br, | |
65 | user = "root", | |
66 | logfile = b.logfile) | |
67 | if res != 0: | |
68 | b.log_line("error: BR installation failed") | |
69 | return res |