def check_or_get_file(self, upstream_url, tarfile, mode="w"): """Download tarball from url unless it is present locally.""" tarball_path = self.config.download_path + "/" + tarfile if not os.path.isfile(tarball_path): download.do_curl(upstream_url, dest=tarball_path, is_fatal=True) self.write_upstream(get_sha1sum(tarball_path), tarfile, mode) else: self.write_upstream(get_sha1sum(tarball_path), tarfile, mode) return tarball_path
def check_or_get_file(upstream_url, tarfile, mode="w"): """Download tarball from url unless it is present locally.""" tarball_path = build.download_path + "/" + tarfile # check if url signifies a go dependency, which needs special handling if tarfile == "list": process_go_dependency(upstream_url, build.download_path) elif not os.path.isfile(tarball_path): download.do_curl(upstream_url, dest=tarball_path, is_fatal=True) write_upstream(get_sha1sum(tarball_path), tarfile, mode) else: write_upstream(get_sha1sum(tarball_path), tarfile, mode) return tarball_path
def get_go_artifacts(url, target, ver): """Get artifacts required to be a go proxy alternative.""" for name in [f"{ver}.{x}" for x in ["info", "mod", "zip"]]: path = os.path.join(target, name) if not os.path.exists(path): download.do_curl(os.path.join(url, name), dest=path, is_fatal=True) sha1 = get_sha1sum(path) write_upstream(sha1, name, mode="a")
def license_from_copying_hash(copying, srcdir, config): """Add licenses based on the hash of the copying file.""" try: data = get_contents(copying) except FileNotFoundError: # LICENSE file is a bad symlink (qemu-4.2.0!) return if data.startswith(b'#!'): # Not a license if this is a script return data = decode_license(data) if not data: return hash_sum = get_sha1sum(copying) if config.license_fetch: values = {'hash': hash_sum, 'text': data, 'package': tarball.name} data = urllib.parse.urlencode(values) data = data.encode('utf-8') buffer = download.do_curl(config.license_fetch, post=data, is_fatal=True) response = buffer.getvalue() page = response.decode('utf-8').strip() if page: print("License : ", page, " (server) (", hash_sum, ")") process_licenses(page, config.license_translations, config.license_blacklist) if page != "none": # Strip the build source directory off the front lic_path = copying[len(srcdir):] # Strip any leading slashes while lic_path.startswith('/'): lic_path = lic_path[1:] lic_path = shlex.quote(lic_path) license_files.append(lic_path) hashes[lic_path] = hash_sum return if hash_sum in config.license_hashes: add_license(config.license_hashes[hash_sum], config.license_translations, config.license_blacklist) else: if not config.license_show: return print_warning("Unknown license {0} with hash {1}".format( copying, hash_sum)) hash_url = config.license_show % {'HASH': hash_sum} print_warning("Visit {0} to enter".format(hash_url))