import re, os
import string
-import StringIO
+import sys
+if sys.version_info[0] == 2:
+ import StringIO
+else:
+ from io import StringIO
import chroot
import util
'dev',
'poldek',
'rpm-build',
- 'pdksh',
'mksh',
- 'coreutils'
+ 'coreutils',
+ 'util-linux'
]
def close_killset(killset):
f = chroot.popen("poldek --noask --test --test --erase %s" % p, user = "root")
crucial = 0
e = []
- for l in f.xreadlines():
+ for l in f:
m = rx.search(l)
if m:
pkg = m.group('name')
f = chroot.popen("rpm --test -F %s 2>&1" % string.join(b.files), user = "root")
killset = {}
rx = re.compile(r' \(installed\) (?P<name>[^\s]+)-[^-]+-[^-]+$')
- for l in f.xreadlines():
+ for l in f:
m = rx.search(l)
if m: killset[m.group('name')] = 1
f.close()
b.log_line("package %s removal failed" % k)
return True
+def is_rpmorg():
+ f = chroot.popen("rpm --version 2>&1")
+ v = re.compile(r'(RPM version|rpm \(RPM\)) (?P<major>\d)\.(?P<minor>\d+)(\.\d+)?')
+ for l in f:
+ m = v.search(l)
+ if m:
+ major = int(m.group('major'))
+ minor = int(m.group('minor'))
+ if major == 4 and minor > 5:
+ f.close()
+ return True
+ f.close()
+ return False
+
def uninstall_self_conflict(b):
b.log_line("checking BuildConflict-ing packages")
- f = chroot.popen("set -e; TMPDIR=%(tmpdir)s " \
- "rpmbuild -bp --nobuild --short-circuit --define 'prep exit 0' %(rpmdefs)s %(topdir)s/%(spec)s 2>&1" % {
+ if is_rpmorg():
+ rpmcommand = "rpmbuild --nobuild -br"
+ else:
+ rpmcommand = "rpmbuild -bp --nobuild --short-circuit --define 'prep exit 0'"
+ f = chroot.popen("set -e; TMPDIR=%(tmpdir)s %(rpmcommand)s %(rpmdefs)s %(topdir)s/%(spec)s 2>&1" % {
+ 'rpmcommand': rpmcommand,
'tmpdir': b.tmpdir(),
'rpmdefs' : b.rpmbuild_opts(),
'topdir' : b.get_topdir(),
# java-sun conflicts with soprano-2.1.67-1.src
rx = re.compile(r"\s+(?P<name>[\w-]+)\s+.*conflicts with [^\s]+-[^-]+-[^-]+\.src($| .*)")
conflicting = {}
- for l in f.xreadlines():
+ for l in f:
m = rx.search(l)
if m:
b.log_line("rpmbuild: %s" % l.rstrip())
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)\(.*')
tmpdir = b.tmpdir()
- cmd = "set -e; TMPDIR=%(tmpdir)s rpmbuild --nobuild %(rpmdefs)s %(topdir)s/%(spec)s 2>&1" % {
+ if is_rpmorg():
+ rpmcommand = "rpmbuild --nobuild -br"
+ else:
+ rpmcommand = "rpmbuild --nobuild"
+ cmd = "set -e; TMPDIR=%(tmpdir)s %(rpmcommand)s %(rpmdefs)s %(topdir)s/%(spec)s 2>&1" % {
+ 'rpmcommand': rpmcommand,
'tmpdir': tmpdir,
'topdir' : b.get_topdir(),
'rpmdefs' : b.rpmbuild_opts(),
rx = re.compile(r"^\s*(?P<name>[^\s]+) .*is needed by")
needed = {}
b.log_line("checking BR")
- for l in f.xreadlines():
+ for l in f:
b.log_line("rpm: %s" % l.rstrip())
m = rx.search(l)
if m and not ignore_br.match(l):
# jmx is needed by (installed) java-commons-modeler-2.0-1.noarch
rx = re.compile(r".*(conflicts with|is required by|is needed by)( installed| \(installed\)|) (?P<name>[^\s]+)-[^-]+-[^-]+($| .*)")
conflicting = {}
- for l in f.xreadlines():
+ for l in f:
b.log_line("poldek: %s" % l.rstrip())
m = rx.search(l)
if m: conflicting[m.group('name')] = 1