Panu Matilainen 41225d
--- rpm-4.8.0/macros.in	2010-02-04 17:42:32.228100971 +0000
Panu Matilainen 41225d
+++ rpm-4.8.0/macros.in.postscriptdriver-fixes	2010-02-04 17:43:03.867226950 +0000
Panu Matilainen 41225d
@@ -504,7 +504,7 @@ print (t)\
Panu Matilainen 41225d
 
Panu Matilainen 41225d
 %__fontconfig_provides	%{_rpmconfigdir}/fontconfig.prov
Panu Matilainen 41225d
 %__desktop_provides	%{_rpmconfigdir}/desktop-file.prov
Panu Matilainen 41225d
-%__psdriver_provides	%{_rpmconfigdir}/postscriptdriver.prov
Panu Matilainen 41225d
+%__psdriver_provides	%{_rpmconfigdir}/postscriptdriver.prov %{buildroot}
Panu Matilainen 41225d
 
Panu Matilainen 41225d
 #==============================================================================
Panu Matilainen 41225d
 # ---- Database configuration macros.
Panu Matilainen 41225d
--- rpm-4.8.0/scripts/postscriptdriver.prov	2010-02-04 17:25:15.672102648 +0000
Panu Matilainen 41225d
+++ rpm-4.8.0/scripts/postscriptdriver.prov.postscriptdriver-fixes	2010-02-05 10:46:44.517778993 +0000
Panu Matilainen 41225d
@@ -1,6 +1,6 @@ 
Panu Matilainen 41225d
 #!/bin/bash
Panu Matilainen 41225d
 shopt -s execfail
Panu Matilainen 41225d
-exec -a "$0" python -- "$@" <(tail -n +4 -- "$0") || exit 0 # -*- python -*-
Panu Matilainen 41225d
+exec -a "$0" python -- <(tail -n +4 -- "$0") "$@" || exit 0 # -*- python -*-
Panu Matilainen 41225d
 
Panu Matilainen 41225d
 ## Copyright (C) 2009, 2010 Red Hat, Inc.
Panu Matilainen 41225d
 ## Author: Tim Waugh <twaugh@redhat.com>
Panu Matilainen 41225d
@@ -23,21 +23,26 @@ import sys
Panu Matilainen 41225d
 
Panu Matilainen 41225d
 try:
Panu Matilainen 41225d
     import cups
Panu Matilainen 41225d
-    CAN_EXAMINE_PPDS=True
Panu Matilainen 41225d
+    CAN_EXAMINE_PPDS = True
Panu Matilainen 41225d
 except:
Panu Matilainen 41225d
-    CAN_EXAMINE_PPDS=False
Panu Matilainen 41225d
+    CAN_EXAMINE_PPDS = False
Panu Matilainen 41225d
 
Panu Matilainen 41225d
 from getopt import getopt
Panu Matilainen 41225d
+import errno
Panu Matilainen 41225d
 import os
Panu Matilainen 41225d
 import posix
Panu Matilainen 41225d
 import re
Panu Matilainen 41225d
 import shlex
Panu Matilainen 41225d
 import signal
Panu Matilainen 41225d
-import stat
Panu Matilainen 41225d
 import subprocess
Panu Matilainen 41225d
 import sys
Panu Matilainen 41225d
 import tempfile
Panu Matilainen 41225d
 
Panu Matilainen 41225d
+if len (sys.argv) > 1:
Panu Matilainen 41225d
+    RPM_BUILD_ROOT = sys.argv[1]
Panu Matilainen 41225d
+else:
Panu Matilainen 41225d
+    RPM_BUILD_ROOT = None
Panu Matilainen 41225d
+
Panu Matilainen 41225d
 class TimedOut(Exception):
Panu Matilainen 41225d
     def __init__ (self):
Panu Matilainen 41225d
         Exception.__init__ (self, "Timed out")
Panu Matilainen 41225d
@@ -139,9 +144,20 @@ class DynamicDriver(Driver):
Panu Matilainen 41225d
 
Panu Matilainen 41225d
     def list (self):
Panu Matilainen 41225d
         signal.alarm (60)
Panu Matilainen 41225d
+        env = os.environ.copy ()
Panu Matilainen 41225d
+        if RPM_BUILD_ROOT:
Panu Matilainen 41225d
+            buildroot = RPM_BUILD_ROOT
Panu Matilainen 41225d
+            if not buildroot.endswith (os.path.sep):
Panu Matilainen 41225d
+                buildroot += os.path.sep
Panu Matilainen 41225d
+
Panu Matilainen 41225d
+            env["DESTDIR"] = RPM_BUILD_ROOT
Panu Matilainen 41225d
+            env["LD_LIBRARY_PATH"] = "%susr/lib64:%susr/lib" % (buildroot,
Panu Matilainen 41225d
+                                                                buildroot)
Panu Matilainen 41225d
+
Panu Matilainen 41225d
         p = subprocess.Popen ([self.driver, "list"],
Panu Matilainen 41225d
                               stdout=subprocess.PIPE,
Panu Matilainen 41225d
-                              stderr=subprocess.PIPE)
Panu Matilainen 41225d
+                              stderr=subprocess.PIPE,
Panu Matilainen 41225d
+                              env=env)
Panu Matilainen 41225d
         try:
Panu Matilainen 41225d
             (stdout, stderr) = p.communicate ()
Panu Matilainen 41225d
             signal.alarm (0)
Panu Matilainen 41225d
@@ -214,6 +230,12 @@ class TagBuilder:
Panu Matilainen 41225d
                     self.ids += DynamicDriver (path).list ()
Panu Matilainen 41225d
                 except TimedOut:
Panu Matilainen 41225d
                     pass
Panu Matilainen 41225d
+                except OSError, e:
Panu Matilainen 41225d
+                    if e == errno.EACCES or e == errno.ENOENT:
Panu Matilainen 41225d
+                        # Not executable
Panu Matilainen 41225d
+                        pass
Panu Matilainen 41225d
+                    else:
Panu Matilainen 41225d
+                        raise
Panu Matilainen 41225d
 
Panu Matilainen 41225d
         if CAN_EXAMINE_PPDS:
Panu Matilainen 41225d
             for path in paths: