Пример #1
0
 def download(self, package_name, config):
   if not os.path.exists(PREBUILT_ROOT):
     util.makedirs(PREBUILT_ROOT)
   info = self.packages[(package_name, config)]
   filename = os.path.join(PREBUILT_ROOT, os.path.basename(info['BIN_URL']))
   if os.path.exists(filename):
     try:
       util.verify_hash(filename, info['BIN_SHA1'])
       return filename
     except util.HashVerificationError:
       pass
   util.log('Downloading prebuilt binary ...')
   util.download_file(filename, info['BIN_URL'])
   util.verify_hash(filename, info['BIN_SHA1'])
   return filename
Пример #2
0
  def download(self, force_mirror=None):
    """Download upstream sources and verify integrity."""
    if self.is_git_upstream():
      self.git_clone_to_mirror()
      return

    archive = self.download_location()
    if not archive:
      return

    if force_mirror is None:
      force_mirror = os.environ.get('FORCE_MIRROR', False)
    self.download_archive(force_mirror=force_mirror)

    if self.SHA1 is None:
      raise PkgFormatError('missing SHA1 attribute: %s' % self.info)

    util.verify_hash(archive, self.SHA1)
    log('verified: %s' % util.rel_path(archive))
Пример #3
0
 def test_verify_hash(self):
   util.verify_hash('foo', 'sha1')
   with self.assertRaises(util.HashVerificationError):
     util.verify_hash('foo', 'sha1x')