Commit 9be7928b authored by Yusei Tahara's avatar Yusei Tahara

download, downloadunpacked: Check shared directory is not enough. Shared...

download, downloadunpacked: Check shared directory is not enough. Shared directory may be created before completing installation. Check signature file too.
parent 9c883311
......@@ -30,7 +30,7 @@ import shutil
import zc.buildout
import logging
from hashlib import md5
from downloadunpacked import make_read_only_recursively
from downloadunpacked import make_read_only_recursively, test_shared_part
class Recipe(object):
_parts = None
......@@ -87,7 +87,7 @@ class Recipe(object):
log = logging.getLogger(self._name)
if self._shared:
log.info('Checking whether package is installed at shared path: %s', destination)
if os.path.exists(destination):
if test_shared_part(destination, '\n'.join(self._debug_signature_text)):
log.info('This shared package has been installed by other package')
return []
......
......@@ -99,7 +99,7 @@ class Recipe:
def install(self):
if self.shared:
self.logger.info('Checking whether package is installed at shared path : %s', self.destination)
if os.path.exists(self.destination):
if test_shared_part(self.destination, '\n'.join(self._debug_signature_text)):
self.logger.info('This shared package has been installed by other package')
return []
if self.parts is not None:
......@@ -225,6 +225,12 @@ def unpatch_archive_util():
setuptools.archive_util.unpack_tarfile,
)
def test_shared_part(path, expected_signature_text):
signature_path = os.path.join(path, '.slapos.recipe.build.signature')
if os.path.exists(signature_path) and open(signature_path).read() == expected_signature_text:
return True
return False
_read_only_mask = 0o777 ^ (stat.S_IWRITE | stat.S_IWGRP | stat.S_IWOTH)
def make_read_only(path):
os.chmod(path, os.stat(path).st_mode & _read_only_mask)
......
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