Bug #261992 - Inside Binpkg._prefetch_exit(), avoid potention issues with
authorZac Medico <zmedico@gentoo.org>
Thu, 12 Mar 2009 05:57:24 +0000 (05:57 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 Mar 2009 05:57:24 +0000 (05:57 -0000)
shutil.rmtree() by just doing a minimal cleanup. (trunk r13070)

svn path=/main/branches/2.1.6/; revision=13084

pym/_emerge/__init__.py

index 345fe8c45f2eec6a17a1c8a4802f4cbb43589d1a..6b23b4c9776b0cb1ff2f4ce0a7e4bcbd50c26d56 100644 (file)
@@ -3394,12 +3394,14 @@ class Binpkg(CompositeTask):
                pkg_count = self.pkg_count
                if not (self.opts.pretend or self.opts.fetchonly):
                        self._build_dir.lock()
-                       try:
-                               shutil.rmtree(self._build_dir.dir_path)
-                       except EnvironmentError, e:
-                               if e.errno != errno.ENOENT:
-                                       raise
-                               del e
+                       # If necessary, discard old log so that we don't
+                       # append to it.
+                       for x in ('.logid', 'temp/build.log'):
+                               try:
+                                       os.unlink(os.path.join(self._build_dir.dir_path, x))
+                               except OSError:
+                                       pass
+                       # Initialze PORTAGE_LOG_FILE.
                        portage.prepare_build_dirs(self.settings["ROOT"], self.settings, 1)
                fetcher = BinpkgFetcher(background=self.background,
                        logfile=self.settings.get("PORTAGE_LOG_FILE"), pkg=self.pkg,