Commit 0553c23e authored by Julien Muchembled's avatar Julien Muchembled

download: fix default permission of installed files

zc.buildout.download.Download may return temporary files
(only readable/writable by the current user) and by default
we'd like installed files to respect umask.

In the case of SlapOS, we usually want installed files to be readable
by members of 'slapsoft' group.
parent cdd67eed
......@@ -24,6 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import errno
import os
import shutil
import zc.buildout
......@@ -61,16 +62,18 @@ class Recipe(object):
os.mkdir(parts)
result.append(parts)
path, is_temp = self._downloader(self._url, md5sum=self._md5sum)
try:
if os.path.exists(destination):
os.unlink(destination)
shutil.copy(path, destination)
finally:
with open(path, 'rb') as fsrc:
if is_temp:
os.unlink(path)
mode = self._mode
if mode is not None:
os.chmod(destination, mode)
os.remove(path)
try:
os.remove(destination)
except OSError as e:
if e.errno != errno.ENOENT:
raise
with open(destination, 'wb') as fdst:
if self._mode is not None:
os.fchmod(fdst.fileno(), self._mode)
shutil.copyfileobj(fsrc, fdst)
return result
update = install
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment