diff --git a/README.rst b/README.rst index 8b84f12da761831f31ebe880edee198875a07715..999095ee365100130f50dccc62f517f747a10eba 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/slapos/recipe/download.py b/slapos/recipe/download.py index 5a941012ea18d34bf000ea0e945a6bbe51d816d7..e798d73596a748a19a51585a31691d78d16b7289 100644 --- a/slapos/recipe/download.py +++ b/slapos/recipe/download.py @@ -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() diff --git a/slapos/recipe/downloadunpacked.py b/slapos/recipe/downloadunpacked.py index 9963da09c3490a39065e6818c82ce1988137662b..2af338cf261c4bf8e8a8655bb91866e35ae44d29 100644 --- a/slapos/recipe/downloadunpacked.py +++ b/slapos/recipe/downloadunpacked.py @@ -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