Use write_atomic to rewrite lafiles.
authorZac Medico <zmedico@gentoo.org>
Mon, 20 Dec 2010 13:48:39 +0000 (05:48 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 20 Dec 2010 13:48:39 +0000 (05:48 -0800)
This should succeed even in some cases in which a normal write might
fail due to file permission settings on some operating systems such as
HP-UX.

pym/portage/package/ebuild/doebuild.py

index 5bba19ff84d655fd9ae81c11942f645b084fb904..3071cf8d46f81636d0354310bc494fce15e8968f 100644 (file)
@@ -1453,11 +1453,12 @@ def _post_src_install_uid_fix(mysettings, out):
                                                        fixlafiles_announced = True
                                                        writemsg("Fixing .la files\n", fd=out)
                                                writemsg("   %s\n" % fpath[len(destdir):], fd=out)
-                                               f = open(_unicode_encode(fpath,
+                                               # write_atomic succeeds even in some cases in which
+                                               # a normal write might fail due to file permission
+                                               # settings on some operating systems such as HP-UX
+                                               write_atomic(_unicode_encode(fpath,
                                                        encoding=_encodings['merge'], errors='strict'),
-                                                       mode='wb')
-                                               f.write(new_contents)
-                                               f.close()
+                                                       new_contents, mode='wb')
 
                                mystat = os.lstat(fpath)
                                if stat.S_ISREG(mystat.st_mode) and \