Commit f36d8db4 authored by Jérome Perrin's avatar Jérome Perrin

Support new integrity option to replace md5sum

parent 6d809e51
......@@ -27,11 +27,11 @@ Example that installs software::
statlib:lib/libfoo.a
statlib:lib/libfoo.la
dynlib:bin/foo linked:libbar.so.1,libc.so.6,libfoo.so.1 rpath:${bar:location}/lib,!/lib
x86 = http://host/path/x86.zip [md5sum]
x86-64 = http://host/path/x64.zip [md5sum]
x86 = http://host/path/x86.zip [hashes]
x86-64 = http://host/path/x64.zip [hashes]
install =
url, md5sum = options[guessPlatform()].split()
extract_dir = self.extract(self.download(url, md5sum))
url, hashes = options[guessPlatform()].split()
extract_dir = self.extract(self.download(url, hashes=hashes))
self.copyTree(guessworkdir(extract_dir), location)
${:update}
update =
......@@ -134,7 +134,11 @@ filename parameter can be used to change destination named filename.
destination parameter allows to put explicit destination.
md5sum parameter allows pass md5sum.
integrity parameter allow to specify the expected hashes for the downloaded
file, in a format ``algorithm:hash``
md5sum parameter allows pass md5sum. This is deprecated, integrity is
recommended instead.
mode (octal, so for rw-r--r-- use 0644) allows to set mode
......
......@@ -40,6 +40,7 @@ class Recipe(object):
self._downloader = zc.buildout.download.Download(buildout_section,
hash_name=True)
self._url = options['url']
self._integrity = options.get('integrity')
self._md5sum = options.get('md5sum')
self._name = name
mode = options.get('mode')
......@@ -92,7 +93,10 @@ class Recipe(object):
if parts is not None and not os.path.isdir(parts):
os.mkdir(parts)
result.append(parts)
path, is_temp = self._downloader(self._url, md5sum=self._md5sum)
if self._integrity:
path, is_temp = self._downloader(self._url, hashes=self._integrity)
else:
path, is_temp = self._downloader(self._url, md5sum=self._md5sum)
with open(path, 'rb') as fsrc:
if is_temp:
os.remove(path)
......@@ -112,5 +116,5 @@ class Recipe(object):
return result
def update(self):
if not self._md5sum:
if not (self._md5sum or self._integrity):
self.install()
......@@ -108,8 +108,12 @@ class Recipe:
extract_dir = tempfile.mkdtemp(self.name)
try:
self.logger.debug('Created working directory %r', extract_dir)
path, is_temp = download(self.options['url'],
md5sum=self.options.get('md5sum'))
if self.options.get('integrity'):
path, is_temp = download(self.options['url'],
hashes=self.options['integrity'])
else:
path, is_temp = download(self.options['url'],
md5sum=self.options.get('md5sum'))
try:
patch_archive_util()
# ad-hoc support for .xz and .lz archive
......
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