예제 #1
0
def run_legacy_snapcraft() -> None:
    legacy_python = os.path.join(
        common.get_legacy_snapcraft_dir(), "usr", "bin", "python3"
    )
    legacy_snapcraft = os.path.join(
        common.get_legacy_snapcraft_dir(), "bin", "snapcraft"
    )

    os.execv(legacy_python, [legacy_python, legacy_snapcraft] + sys.argv[1:])
예제 #2
0
def run_legacy_snapcraft(argv=sys.argv[1:]) -> None:
    if not common.is_snap():
        raise errors.SnapcraftEnvironmentError(
            "Legacy mode not supported in this installation. "
            "Install snapcraft from https://snapcraft.io/snapcraft and try again."
        )

    legacy_python = os.path.join(common.get_legacy_snapcraft_dir(), "usr",
                                 "bin", "python3")
    legacy_snapcraft = os.path.join(common.get_legacy_snapcraft_dir(), "bin",
                                    "snapcraft")

    cmd = [legacy_python, legacy_snapcraft] + argv
    logging.debug("Running legacy snapcraft with: {}".format(cmd))
    os.execv(legacy_python, cmd)
예제 #3
0
def _needs_legacy() -> bool:
    if not os.path.isdir(common.get_legacy_snapcraft_dir()):
        return False

    try:
        # Early bootstrapping does not allow us to use the existing utilities we
        # have to manage this check.
        if os.getenv("SNAPCRAFT_BUILD_ENVIRONMENT") == "managed-host":
            base_dir = os.path.expanduser(os.path.join("~", "project"))
        else:
            base_dir = None
        snapcraft_yaml_path = project.get_snapcraft_yaml(base_dir=base_dir)
        with open(snapcraft_yaml_path, "r") as f:
            data = yaml_utils.load(f)
        return data.get("base") is None
    except Exception:
        # If there are issues loading/parsing the YAML, just pass off to the current version
        # where the error should be properly handled
        return False