diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-09-26 04:37:40 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-09-26 04:37:40 +0000 |
commit | bc7943432207630818a58b6b1b95a537be01fd04 (patch) | |
tree | 0d7b88d6bf6be2b1fc55976557dba43d8face6fd | |
parent | c6445f495325b69dcb2c804a9b05b4f107b67cd4 (diff) | |
download | portage-bc7943432207630818a58b6b1b95a537be01fd04.tar.gz portage-bc7943432207630818a58b6b1b95a537be01fd04.tar.bz2 portage-bc7943432207630818a58b6b1b95a537be01fd04.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. (trunk r7801)
svn path=/main/branches/2.1.2/; revision=7829
-rw-r--r-- | pym/portage_checksum.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pym/portage_checksum.py b/pym/portage_checksum.py index d0cd2d7d4..30b9ca95c 100644 --- a/pym/portage_checksum.py +++ b/pym/portage_checksum.py @@ -10,6 +10,7 @@ from portage_const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE import os import errno import stat +import tempfile import portage_exception import portage_exec import portage_locks @@ -201,16 +202,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_exec.spawn([PRELINK_BINARY, "--undo", "-o", - prelink_tmpfile, filename], fd_pipes={}) + tmpfile_fd, prelink_tmpfile = tempfile.mkstemp() + try: + retval = portage_exec.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: @@ -225,7 +229,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: |