Exemplo n.º 1
0
def conduct_project_sanity_check(project: Project, **kwargs) -> None:
    """Sanity check the project itself before continuing.

    The checks done here are meant to be light, and not rely on the build environment.
    """
    # The snapcraft.yaml should be valid even without extensions applied
    # This here check is mostly for backwards compatibility with the
    # rest of the code base.
    if project.info is not None:
        project.info.validate_raw_snapcraft()

    if project._get_build_base() == "core":
        raise errors.UnsupportedBaseError(base="core")

    snap_dir_path = os.path.join(project._get_snapcraft_assets_dir())
    if os.path.isdir(snap_dir_path):
        # TODO: move this check to the ProjectInfo class.
        _check_snap_dir(snap_dir_path)

    if (project._get_build_base() in ["core20"]
            and kwargs.get("target_arch") is not None
            and not os.getenv("SNAPCRAFT_ENABLE_EXPERIMENTAL_TARGET_ARCH")):
        raise SnapcraftEnvironmentError(
            "*EXPERIMENTAL* '--target-arch' configured, but not enabled. "
            "Enable with '--enable-experimental-target-arch' flag.")

    # Icon should refer to project file, verify it exists.
    icon = project.info.get_raw_snapcraft().get("icon")
    if icon and not os.path.exists(icon):
        raise SnapcraftEnvironmentError(
            f"Specified icon {icon!r} does not exist.")
Exemplo n.º 2
0
def conduct_project_sanity_check(project: Project, **kwargs) -> None:
    """Sanity check the project itself before continuing.

    The checks done here are meant to be light, and not rely on the build environment.
    """
    # The snapcraft.yaml should be valid even without extensions applied
    # This here check is mostly for backwards compatibility with the
    # rest of the code base.
    if project.info is not None:
        project.info.validate_raw_snapcraft()

    snap_dir_path = os.path.join(project._get_snapcraft_assets_dir())
    if os.path.isdir(snap_dir_path):
        # TODO: move this check to the ProjectInfo class.
        _check_snap_dir(snap_dir_path)

    if project._snap_meta.package_repositories and not os.getenv(
            "SNAPCRAFT_ENABLE_EXPERIMENTAL_PACKAGE_REPOSITORIES"):
        raise SnapcraftEnvironmentError(
            "*EXPERIMENTAL* 'package-repositories' configured, but not enabled. "
            "Enable with '--enable-experimental-package-repositories' flag.")

    if (project._get_build_base() in ["core20"]
            and kwargs.get("target_arch") is not None):
        raise SnapcraftEnvironmentError(
            "--target-arch has been deprecated and is no longer supported on core20."
        )
Exemplo n.º 3
0
def conduct_project_sanity_check(project: Project) -> None:
    """Sanity check the project itself before continuing.

    The checks done here are meant to be light, and not rely on the build environment.
    """
    # The snapcraft.yaml should be valid even without extensions applied
    # This here check is mostly for backwards compatibility with the
    # rest of the code base.
    if project.info is not None:
        project.info.validate_raw_snapcraft()

    snap_dir_path = os.path.join(project._get_snapcraft_assets_dir())
    if os.path.isdir(snap_dir_path):
        # TODO: move this check to the ProjectInfo class.
        _check_snap_dir(snap_dir_path)