commit:     0aac11200780225cf14a07d6e4445234f1e0f72a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 17 12:39:15 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jan 17 13:02:29 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0aac1120

doebuild: use NamedTemporaryFile for PORTAGE_BINPKG_TMPFILE

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/package/ebuild/doebuild.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/portage/package/ebuild/doebuild.py 
b/lib/portage/package/ebuild/doebuild.py
index f6cee4518..476689d5e 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -1175,11 +1175,14 @@ def doebuild(myebuild, mydo, 
_unused=DeprecationWarning, settings=None, debug=0,
                                # the current user doesn't have write access to 
$PKGDIR.
                                if hasattr(portage, 'db'):
                                        bintree = 
portage.db[mysettings['EROOT']]['bintree']
-                                       mysettings["PORTAGE_BINPKG_TMPFILE"] = \
-                                               
bintree.getname(mysettings.mycpv) + \
-                                               ".%s" % (portage.getpid(),)
-                                       bintree._ensure_dir(os.path.dirname(
-                                               
mysettings["PORTAGE_BINPKG_TMPFILE"]))
+                                       binpkg_tmpfile_dir = 
os.path.join(bintree.pkgdir, mysettings["CATEGORY"])
+                                       bintree._ensure_dir(binpkg_tmpfile_dir)
+                                       with tempfile.NamedTemporaryFile(
+                                               prefix=mysettings["PF"],
+                                               suffix=".tbz2." + 
str(portage.getpid()),
+                                               dir=binpkg_tmpfile_dir,
+                                               delete=False) as binpkg_tmpfile:
+                                               
mysettings["PORTAGE_BINPKG_TMPFILE"] = binpkg_tmpfile.name
                                else:
                                        parent_dir = 
os.path.join(mysettings["PKGDIR"],
                                                mysettings["CATEGORY"])

Reply via email to