def _setup_core(deb_arch): core_path = common.get_core_path() if os.path.exists(core_path) and os.listdir(core_path): logger.debug( '{!r} already exists, skipping core setup'.format(core_path)) return snap_cache = SnapCache(project_name='snapcraft-core') # Try to get the latest revision. core_snap = snap_cache.get(deb_arch=deb_arch) if core_snap: # The current hash matches the filename current_hash = os.path.splitext(os.path.basename(core_snap))[0] else: current_hash = '' with TemporaryDirectory() as d: download_path = os.path.join(d, 'core.snap') download_hash = snapcraft.download('core', 'stable', download_path, deb_arch, except_hash=current_hash) if download_hash != current_hash: snap_cache.cache(snap_filename=download_path) snap_cache.prune(deb_arch=deb_arch, keep_hash=download_hash) core_snap = snap_cache.get(deb_arch=deb_arch) # Now unpack logger.info('Setting up {!r} in {!r}'.format(core_snap, core_path)) if os.path.exists(core_path) and not os.listdir(core_path): check_call(['sudo', 'rmdir', core_path]) check_call(['sudo', 'mkdir', '-p', os.path.dirname(core_path)]) check_call(['sudo', 'unsquashfs', '-d', core_path, core_snap])
def _setup_core(deb_arch): core_path = common.get_core_path() if os.path.exists(core_path) and os.listdir(core_path): logger.debug('{!r} already exists, skipping core setup'.format( core_path)) return snap_cache = SnapCache(project_name='snapcraft-core') # Try to get the latest revision. core_snap = snap_cache.get(deb_arch=deb_arch) if core_snap: # The current hash matches the filename current_hash = os.path.splitext(os.path.basename(core_snap))[0] else: current_hash = '' with TemporaryDirectory() as d: download_path = os.path.join(d, 'core.snap') download_hash = snapcraft.download('core', 'stable', download_path, deb_arch, except_hash=current_hash) if download_hash != current_hash: snap_cache.cache(snap_filename=download_path) snap_cache.prune(deb_arch=deb_arch, keep_hash=download_hash) core_snap = snap_cache.get(deb_arch=deb_arch) # Now unpack logger.info('Setting up {!r} in {!r}'.format(core_snap, core_path)) if os.path.exists(core_path) and not os.listdir(core_path): check_call(['sudo', 'rmdir', core_path]) check_call(['sudo', 'mkdir', '-p', os.path.dirname(core_path)]) check_call(['sudo', 'unsquashfs', '-d', core_path, core_snap])
def _setup_core(deb_arch, base): core_path = common.get_core_path(base) if os.path.exists(core_path) and os.listdir(core_path): logger.debug( "{!r} already exists, skipping core setup".format(core_path)) return # for backwards compatibility if base == "core": snap_cache = SnapCache(project_name="snapcraft-core") else: snap_cache = SnapCache(project_name=base) # Try to get the latest revision. core_snap = snap_cache.get(deb_arch=deb_arch) if core_snap: # The current hash matches the filename current_hash = os.path.splitext(os.path.basename(core_snap))[0] else: current_hash = "" with TemporaryDirectory() as d: download_path = os.path.join(d, "{}.snap".format(base)) download_hash = snapcraft.download(base, "stable", download_path, deb_arch, except_hash=current_hash) if download_hash != current_hash: snap_cache.cache(snap_filename=download_path) snap_cache.prune(deb_arch=deb_arch, keep_hash=download_hash) core_snap = snap_cache.get(deb_arch=deb_arch) # Now unpack logger.info("Setting up {!r} in {!r}".format(core_snap, core_path)) if os.path.exists(core_path) and not os.listdir(core_path): check_call(["sudo", "rmdir", core_path]) check_call(["sudo", "mkdir", "-p", os.path.dirname(core_path)]) unsquashfs_path = snapcraft.file_utils.get_tool_path("unsquashfs") check_call(["sudo", unsquashfs_path, "-d", core_path, core_snap])
def _setup_core(deb_arch, base): core_path = common.get_core_path(base) if os.path.exists(core_path) and os.listdir(core_path): logger.debug("{!r} already exists, skipping core setup".format(core_path)) return # for backwards compatibility if base == "core": snap_cache = SnapCache(project_name="snapcraft-core") else: snap_cache = SnapCache(project_name=base) # Try to get the latest revision. core_snap = snap_cache.get(deb_arch=deb_arch) if core_snap: # The current hash matches the filename current_hash = os.path.splitext(os.path.basename(core_snap))[0] else: current_hash = "" with TemporaryDirectory() as d: download_path = os.path.join(d, "{}.snap".format(base)) download_hash = snapcraft.download( base, "stable", download_path, deb_arch, except_hash=current_hash ) if download_hash != current_hash: snap_cache.cache(snap_filename=download_path) snap_cache.prune(deb_arch=deb_arch, keep_hash=download_hash) core_snap = snap_cache.get(deb_arch=deb_arch) # Now unpack logger.info("Setting up {!r} in {!r}".format(core_snap, core_path)) if os.path.exists(core_path) and not os.listdir(core_path): check_call(["sudo", "rmdir", core_path]) check_call(["sudo", "mkdir", "-p", os.path.dirname(core_path)]) unsquashfs_path = snapcraft.file_utils.get_tool_path("unsquashfs") check_call(["sudo", unsquashfs_path, "-d", core_path, core_snap])