diff --git a/superflore/generators/bitbake/yocto_recipe.py b/superflore/generators/bitbake/yocto_recipe.py index 2c554d68..aeab7935 100644 --- a/superflore/generators/bitbake/yocto_recipe.py +++ b/superflore/generators/bitbake/yocto_recipe.py @@ -424,37 +424,11 @@ def generate_distro_cache(basepath, distro, skip_keys=[]): distro_cache_file_path = '{0}{1}-cache.yaml'.format( distro_cache_path, distro) try: - make_dir(distro_cache_path) - from rosdistro import get_index, get_index_url, _get_dist_file_data - import gzip - try: - from urllib.request import urlopen - except ImportError: - from urllib2 import urlopen - try: - from cStringIO import StringIO - except ImportError: - from io import BytesIO as StringIO + from rosdistro import get_index, get_index_url, get_distribution_cache_string index_url = get_index_url() index = get_index(index_url) - dist = index.distributions.get(distro, None) - if not dist: - raise RuntimeError( - 'Unknown distribution {0} when looking at {1}'.format(distro, index_url)) - cache_url = dist.get('distribution_cache', None) - if not cache_url: - raise RuntimeError( - 'Distribution {0} has no cache'.format(distro)) - raw_data = urlopen(cache_url, timeout=10).read() - if cache_url.endswith('.yaml.gz'): - yaml_gz_stream = StringIO(raw_data) - f = gzip.GzipFile(fileobj=yaml_gz_stream, mode='rb') - yaml_str = f.read() - f.close() - if not isinstance(yaml_str, str): - yaml_str = yaml_str.decode('utf-8') - else: - yaml_str = raw_data.decode('utf-8') + yaml_str = get_distribution_cache_string(index, distro) + make_dir(distro_cache_path) with open(distro_cache_file_path, "w") as distro_cache_file: distro_cache_file.write(yaml_str) ok('Wrote {0}'.format(distro_cache_file_path))