]> git.pld-linux.org Git - projects/pld-builder.new.git/blobdiff - PLD_Builder/install.py
Fix outdated syntax
[projects/pld-builder.new.git] / PLD_Builder / install.py
index b7ab3f6b0a6ce9ff14f57505ce64c9271c320078..a688a48d1c65d4236591b061d07c63d6e468f501 100644 (file)
@@ -2,7 +2,11 @@
 
 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
@@ -12,9 +16,9 @@ hold = [
     'dev',
     'poldek',
     'rpm-build',
-    'pdksh',
     'mksh',
-    'coreutils'
+    'coreutils',
+    'util-linux'
 ]
 
 def close_killset(killset):
@@ -31,7 +35,7 @@ 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')
@@ -52,7 +56,7 @@ def upgrade_from_batch(r, b):
     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()
@@ -105,14 +109,14 @@ def uninstall_self_conflict(b):
         "rpmbuild -bp --nobuild --short-circuit --define 'prep exit 0' %(rpmdefs)s %(topdir)s/%(spec)s 2>&1" % {
         'tmpdir': b.tmpdir(),
         'rpmdefs' : b.rpmbuild_opts(),
-        'topdir' : b._topdir,
+        'topdir' : b.get_topdir(),
         'spec': b.spec,
     })
     # java-sun >= 1.5 conflicts with soprano-2.1.67-1.src
     # 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())
@@ -124,14 +128,33 @@ def uninstall_self_conflict(b):
     return True
 
 def install_br(r, b):
+    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 get_missing_br(r, b):
         # ignore internal rpm dependencies, see lib/rpmns.c for list
         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._topdir,
+            'topdir' : b.get_topdir(),
             'rpmdefs' : b.rpmbuild_opts(),
             'spec': b.spec,
         }
@@ -139,7 +162,7 @@ def install_br(r, b):
         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):
@@ -161,13 +184,13 @@ def install_br(r, b):
     chroot.run("poldek --up --upa", user = "root", logfile = b.logfile)
     # check conflicts in BRed packages
     b.log_line("checking conflicting packages in BRed packages")
-    f = chroot.popen("poldek --test --test --noask --caplookup -Q -v --upgrade %s %s" % (b.ignores(), br), user = "root")
+    f = chroot.popen("poldek --test --test --noask --caplookup -Q -v %s --upgrade %s" % (b.ignores(), br), user = "root")
     # phonon-devel-4.3.1-1.i686 conflicts with qt4-phonon-devel-4.5.0-6.i686
     # jdbc-stdext >= 2.0 is required by installed java-struts-1.3.10-1.noarch
     # 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
@@ -191,9 +214,7 @@ def install_br(r, b):
     br = string.strip(nbr)
 
     b.log_line("installing BR: %s" % br)
-    ignores = b.ignores()
-    b.log_line("ignores: %s" % ignores)
-    res = chroot.run("set -x; poldek --noask --caplookup -Q -v --upgrade %s %s" % (ignores, br),
+    res = chroot.run("set -x; poldek --noask --caplookup -Q -v %s --upgrade %s" % (b.ignores(), br),
             user = "root",
             logfile = b.logfile)
     if res != 0:
This page took 0.420273 seconds and 4 git commands to generate.