[jhbuild] Package: Fail if the module doesn't support DESTDIR at all



commit 9182f46c7f58bcdb31cee9c3ed465814ab30ee73
Author: Colin Walters <walters verbum org>
Date:   Thu Jul 14 10:15:48 2011 -0400

    Package: Fail if the module doesn't support DESTDIR at all
    
    If the installer completely ignored DESTDIR, we have a problem;
    we can't implement uninstall.  Fail in this case.

 jhbuild/modtypes/__init__.py |   56 ++++++++++++++++++++++++-----------------
 1 files changed, 33 insertions(+), 23 deletions(-)
---
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 7475318..0110e65 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -218,43 +218,53 @@ them into the prefix."""
 
         buildscript.packagedb.add(self.name, revision or '', destdir)
 
+        install_succeeded = False
+        save_broken_tree = False
+        broken_name = destdir + '-broken'
         destdir_prefix = os.path.join(destdir, stripped_prefix)
         if os.path.isdir(destdir_prefix):
+            destdir_install = True
             logging.info(_('Moving temporary DESTDIR %r into build prefix') % (destdir, ))
             num_copied = self._process_install_files(destdir, destdir_prefix, buildscript.config.prefix)
             logging.info(_('Install complete: %d files copied') % (num_copied, ))
-        else:
-            logging.warning(_('Module \'%(module_name)s\' does not support '
-                            'DESTDIR') % {'module_name': self.name})
         
-        # Now the destdir should have a series of empty directories:
-        # $JHBUILD_PREFIX/_jhbuild/root-foo/$JHBUILD_PREFIX
-        # Remove them one by one to clean the tree to the state we expect,
-        # so we can better spot leftovers or broken things.
-        prefix_dirs = filter(lambda x: x != '', stripped_prefix.split(os.sep))
-        while len(prefix_dirs) > 0:
-            dirname = prefix_dirs.pop()
-            subprefix = os.path.join(*([destdir] + prefix_dirs))
-            target = os.path.join(subprefix, dirname)
-            assert target.startswith(buildscript.config.prefix)
-            try:
-                os.rmdir(target)
-            except OSError, e:
-                pass
-
-        remaining_files = os.listdir(destdir)
-        if len(remaining_files) > 0:
-            broken_name = destdir + '-broken'
+            # Now the destdir should have a series of empty directories:
+            # $JHBUILD_PREFIX/_jhbuild/root-foo/$JHBUILD_PREFIX
+            # Remove them one by one to clean the tree to the state we expect,
+            # so we can better spot leftovers or broken things.
+            prefix_dirs = filter(lambda x: x != '', stripped_prefix.split(os.sep))
+            while len(prefix_dirs) > 0:
+                dirname = prefix_dirs.pop()
+                subprefix = os.path.join(*([destdir] + prefix_dirs))
+                target = os.path.join(subprefix, dirname)
+                assert target.startswith(buildscript.config.prefix)
+                try:
+                    os.rmdir(target)
+                except OSError, e:
+                    pass
+
+            remaining_files = os.listdir(destdir)
+            if len(remaining_files) > 0:
+                logging.warn(_("Files remaining in buildroot %(dest)r; module may have installed files outside of prefix.") % {'num': len(remaining_files),
+                                                                                                                               'dest': broken_name})
+                save_broken_tree = True
+            # Even if there are some files outside the DESTDIR, count that as success for now; we just warn
+            install_succeeded = True
+        else:
+            save_broken_tree = True
+
+        if save_broken_tree:
             if os.path.exists(broken_name):
                 assert broken_name.startswith(buildscript.config.prefix)
                 shutil.rmtree(broken_name)
             os.rename(destdir, broken_name)
-            logging.warn(_("Files remaining in DESTDIR %(dest)r; module may have installed files outside of prefix.") % {'num': len(remaining_files),
-                                                                                                                         'dest': broken_name})
         else:
             assert destdir.startswith(buildscript.config.prefix)
             os.rmdir(destdir)
 
+        if not install_succeeded:
+            raise CommandError(_("Module failed to install into DESTDIR %(dest)r") % {'dest': broken_name})
+
     def get_revision(self):
         return self.branch.tree_id()
 



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