Exemple #1
0
 def pull(self):
     super().pull()
     snapcraft.download(
         "core",
         risk="stable",
         download_path=self.os_snap,
         arch=self.project.deb_arch,
     )
 def pull(self):
     super().pull()
     logger.info("Using reference initrd: {}".format(self.snap_url))
     is_source_url = snapcraft.internal.common.isurl(self.snap_url)
     # TODO: this should be eventually pulled from snap store
     # for now check if url is valid and use it
     # If not we try to download it from store
     if is_source_url:
         download_urllib_source(self.snap_url, self.vanilla_initrd_snap)
     else:
         snapcraft.download(_INITRD_SNAP_NAME,
                            risk="stable",
                            track=self.uc_series,
                            download_path=self.vanilla_initrd_snap,
                            arch=self.initrd_arch)
Exemple #3
0
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])
Exemple #4
0
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])
Exemple #5
0
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])
Exemple #6
0
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])
Exemple #7
0
 def pull(self):
     super().pull()
     snapcraft.download(
         'ubuntu-core', 'edge', self.os_snap, self.project.deb_arch)
 def pull(self):
     super().pull()
     snapcraft.download("core", "stable", self.os_snap,
                        self.project.deb_arch)
Exemple #9
0
 def pull(self):
     super().pull()
     snapcraft.download(
         'ubuntu-core', 'edge', self.os_snap, self.project.deb_arch)
Exemple #10
0
 def pull(self):
     super().pull()
     snapcraft.download(
         'core', 'stable', self.os_snap, self.project.deb_arch)
Exemple #11
0
 def pull(self):
     super().pull()
     snapcraft.download("core", "stable", self.os_snap, self.project.deb_arch)