summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-24 20:26:09 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-24 20:26:09 +0000
commit32fc2c1d0ba5ad8ef1f223c1ae8a985d3dcdc8cf (patch)
tree63bba4172071788238d53277232b714e8a337482
parent71dd8e828ae8b9461ed28bd7770ae1ef37ff50f7 (diff)
downloadportage-32fc2c1d0ba5ad8ef1f223c1ae8a985d3dcdc8cf.tar.gz
portage-32fc2c1d0ba5ad8ef1f223c1ae8a985d3dcdc8cf.tar.bz2
portage-32fc2c1d0ba5ad8ef1f223c1ae8a985d3dcdc8cf.zip
Bug #190179 - Use `prelink --verify filename` to write the
temp file via stdout since --undo fails when run as a normal non-superuser because it tries to chown the output file. Also, use mkstemp() to eliminate the need for locking the temp file. Thanks to Israel G. Lugo <israel.lugo@lugosys.com> for the initial patch. svn path=/main/trunk/; revision=7801
-rw-r--r--pym/portage/checksum.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index fa00247ab..c663b68d9 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -7,6 +7,7 @@ from portage.const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE
import os
import errno
import stat
+import tempfile
import portage.exception
import portage.process
import portage.locks
@@ -198,16 +199,19 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
"""
global prelink_capable
myfilename = filename[:]
- prelink_tmpfile = os.path.join("/", PRIVATE_PATH, "prelink-checksum.tmp." + str(os.getpid()))
+ prelink_tmpfile = None
mylock = None
try:
if calc_prelink and prelink_capable:
- mylock = portage.locks.lockfile(prelink_tmpfile, wantnewlockfile=1)
# Create non-prelinked temporary file to checksum.
# Files rejected by prelink are summed in place.
try:
- retval = portage.process.spawn([PRELINK_BINARY, "--undo", "-o",
- prelink_tmpfile, filename], fd_pipes={})
+ tmpfile_fd, prelink_tmpfile = tempfile.mkstemp()
+ try:
+ retval = portage.process.spawn([PRELINK_BINARY,
+ "--verify", filename], fd_pipes={1:tmpfile_fd})
+ finally:
+ os.close(tmpfile_fd)
if retval == os.EX_OK:
myfilename = prelink_tmpfile
except portage.exception.CommandNotFound:
@@ -222,7 +226,7 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
if e.errno == errno.ENOENT:
raise portage.exception.FileNotFound(myfilename)
raise
- if calc_prelink and prelink_capable:
+ if prelink_tmpfile:
try:
os.unlink(prelink_tmpfile)
except OSError, e: