[jhbuild] postinstall: Only clean toplevel .la files



commit 90287e27367551cc8fb7c484c5dba7013b7e9b30
Author: Colin Walters <walters verbum org>
Date:   Tue Jul 5 16:26:50 2011 -0400

    postinstall: Only clean toplevel .la files
    
    This is safer - a program *could* be using libltdl to load .la files,
    and .la files at the toplevel are the ones that can actually cause
    *problems*, whereas ones in subdirs are just cruft.
    
    Also log a message when we do this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654013

 jhbuild/modtypes/__init__.py |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index c4b9db2..98073f6 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -160,17 +160,24 @@ class Package:
         return destdir
 
     def _clean_la_files(self, installroot):
+        """This method removes .la files from the toplevel lib*/
+        directories.  See bug 654013."""
         assert os.path.isabs(installroot)
-        files = os.listdir(installroot)
-        for name in files:
-            path = os.path.join(installroot, name)
-            if name.endswith('.la'):
-                try:
-                    os.unlink(path)
-                except OSError:
-                    pass
-            elif os.path.isdir(path):
-                self._clean_la_files(path)
+        assert os.path.isabs(self.config.prefix)
+        prefixdir = os.path.join(installroot, self.config.prefix[1:])
+        assert os.path.isdir(prefixdir)
+        for name in os.listdir(prefixdir):
+            namepath = os.path.join(prefixdir, name)
+            if not (name.startswith('lib') and os.path.isdir(namepath)):
+                continue
+            for subname in os.listdir(namepath):
+                subpath = os.path.join(namepath, subname)
+                if subname.endswith('.la'):
+                    try:
+                        logging.info(_('Deleting toplevel .la file: %r') % (subpath, ))
+                        os.unlink(subpath)
+                    except OSError:
+                        pass
 
     def _process_install_files(self, installroot, curdir, prefix):
         """Strip the prefix from all files in the install root, and move



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]