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 @@ ...@@ -24,6 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import errno
import os import os
import shutil import shutil
import zc.buildout import zc.buildout
...@@ -61,16 +62,18 @@ class Recipe(object): ...@@ -61,16 +62,18 @@ class Recipe(object):
os.mkdir(parts) os.mkdir(parts)
result.append(parts) result.append(parts)
path, is_temp = self._downloader(self._url, md5sum=self._md5sum) path, is_temp = self._downloader(self._url, md5sum=self._md5sum)
try: with open(path, 'rb') as fsrc:
if os.path.exists(destination):
os.unlink(destination)
shutil.copy(path, destination)
finally:
if is_temp: if is_temp:
os.unlink(path) os.remove(path)
mode = self._mode try:
if mode is not None: os.remove(destination)
os.chmod(destination, mode) 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 return result
update = install 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