Beispiel #1
0
 def _setup_base_tools(self, base):
     if base in ("core", "core16", "core18"):
         self.stage_packages.extend(
             ["python3-pip", "python3-wheel", "python3-setuptools"])
         self.build_packages.append("intltool")
     else:
         raise errors.PluginBaseError(part_name=self.name, base=base)
Beispiel #2
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project.info.base not in ("core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name, base=project.info.base)

        self.build_packages.append("make")
Beispiel #3
0
 def _setup_base_tools(self, go_channel, base):
     if go_channel:
         self.build_snaps.append("go/{}".format(go_channel))
     elif base in ("core", "core16", "core18"):
         self.build_packages.append("golang-go")
     else:
         raise errors.PluginBaseError(part_name=self.name, base=base)
Beispiel #4
0
def get_plugin_for_base(plugin_name: str, *, build_base: str) -> PluginTypes:
    """
    Return a suitable plugin implementation for build_base.

    :raises errors.PluginError: when a plugin implementation cannot be found
                                for build_base.
    """
    # TODO: segregate this more and remove the checks UnsupportedBase checks
    # from the plugins

    # Default for unknown, and core20
    plugin_version = "v2"
    # Others use v1
    if build_base == "core18":
        plugin_version = "v1"
    elif build_base == "core":
        raise errors.PluginBaseError(plugin_name=plugin_name, base=build_base)
    elif build_base == "":
        # This should never happen when using build_base from Project.
        raise RuntimeError("'build_base' cannot be unset.")

    try:
        plugin_classes = _PLUGINS[plugin_version]
        return plugin_classes[plugin_name]
    except KeyError:
        raise errors.PluginError(f"unknown plugin: {plugin_name!r}")
Beispiel #5
0
    def __init__(self, name, options, project) -> None:
        super().__init__(name, options, project)
        if project.info.base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project.info.base)

        self._conda_home = os.path.join(self.partdir, "miniconda")
        self._miniconda_script = os.path.join(self.partdir, "miniconda.sh")
Beispiel #6
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)
        self.build_packages.append("cmake")
        self.out_of_source_build = True

        if project.info.base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name, base=project.info.base)

        if options.make_parameters:
            logger.warning("make-paramaters is deprecated, ignoring.")
Beispiel #7
0
 def _setup_base_tools(self, base):
     if base in ("core16", "core18"):
         self.build_packages.append("python3-pip")
         self.build_packages.append("python3-setuptools")
         self.build_packages.append("python3-wheel")
         self.build_packages.append("ninja-build")
     else:
         raise errors.PluginBaseError(part_name=self.name, base=base)
     if base == "core18":
         self.build_packages.append("python3-distutils")
Beispiel #8
0
    def __init__(self, name, options, project) -> None:
        super().__init__(name, options, project)

        if project._get_build_base() not in ("core", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project._get_build_base())

        logger.warning(
            "The flutter plugin is currently in beta, its API may break. Use at your "
            "own risk.")
Beispiel #9
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project.info.base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name, base=project.info.base)

        self.build_packages.extend(["gcc", "git", "curl", "file"])
        self._rust_dir = os.path.expanduser(os.path.join("~", ".cargo"))
        self._rustup_cmd = os.path.join(self._rust_dir, "bin", "rustup")
        self._cargo_cmd = os.path.join(self._rust_dir, "bin", "cargo")
        self._rustc_cmd = os.path.join(self._rust_dir, "bin", "rustc")
        self._rustdoc_cmd = os.path.join(self._rust_dir, "bin", "rustdoc")

        self._manifest = collections.OrderedDict()
Beispiel #10
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project.info.base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project.info.base)

        self.build_packages.extend(["bc", "gcc", "make"])

        self.make_targets = []
        self.make_install_targets = ["install"]
        self.make_cmd = ["make", "-j{}".format(self.parallel_build_count)]
        if logger.isEnabledFor(logging.DEBUG):
            self.make_cmd.append("V=1")
Beispiel #11
0
    def _setup_base(self, base):
        # if base overide is defined, use it instead
        if self.options.kernel_initrd_core_base:
            build_base = self.options.kernel_initrd_core_base
        else:
            build_base = base

        if build_base in ("core", "core16"):
            self.uc_series = "16"
        elif build_base == "core18":
            self.uc_series = "18"
        elif build_base == "core20":
            self.uc_series = "20"
        else:
            raise errors.PluginBaseError(part_name=self.name, base=build_base)
Beispiel #12
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project.info.base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project.info.base)

        self.build_packages.append("make")
        if self.options.qt_version == "qt5":
            self.build_packages.extend(["qt5-qmake", "qtbase5-dev"])
        elif self.options.qt_version == "qt4":
            self.build_packages.extend(["qt4-qmake", "libqt4-dev"])
        else:
            raise RuntimeError("Unsupported Qt version: {!r}".format(
                self.options.qt_version))
Beispiel #13
0
 def _setup_base_tools(self, base):
     if base in ("core", "core16"):
         self.stage_packages.extend([
             "libcurl3",
             "libcurl3-gnutls",
             "libicu55",
             "liblttng-ust0",
             "libunwind8",
             "lldb",
             "libssl1.0.0",
             "libgssapi-krb5-2",
             "zlib1g",
             "libgcc1",
         ])
     else:
         raise errors.PluginBaseError(part_name=self.name, base=base)
Beispiel #14
0
    def __init__(self, name, options, project=None):
        self.name = name
        self.build_snaps = []
        self.stage_snaps = []
        self.build_packages = []
        self._stage_packages = []

        with contextlib.suppress(AttributeError):
            self._stage_packages = options.stage_packages.copy()
        with contextlib.suppress(AttributeError):
            self.build_packages = options.build_packages.copy()
        with contextlib.suppress(AttributeError):
            self.build_snaps = options.build_snaps.copy()
        with contextlib.suppress(AttributeError):
            self.stage_snaps = options.stage_snaps.copy()

        self.project = project
        self.options = options

        if project:
            if isinstance(project,
                          Project) and project._get_build_base() not in (
                              "core",
                              "core16",
                              "core18",
                          ):
                raise errors.PluginBaseError(part_name=self.name,
                                             base=project._get_build_base())

            self.partdir = os.path.join(project.parts_dir, name)
        else:
            self.partdir = os.path.join(os.getcwd(), "parts", name)

        self.sourcedir = os.path.join(self.partdir, "src")
        self.installdir = os.path.join(self.partdir, "install")
        self.statedir = os.path.join(self.partdir, "state")

        self.build_basedir = os.path.join(self.partdir, "build")
        source_subdir = getattr(self.options, "source_subdir", None)
        if source_subdir:
            self.builddir = os.path.join(self.build_basedir, source_subdir)
        else:
            self.builddir = self.build_basedir

        # By default, snapcraft does an in-source build. Set this property to
        # True if that's not desired.
        self.out_of_source_build = False
Beispiel #15
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project.info.base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project.info.base)

        self._ruby_version = options.ruby_version
        self._ruby_part_dir = os.path.join(self.partdir, "ruby")
        feature_pattern = re.compile(r"^(\d+\.\d+)\..*$")
        feature_version = feature_pattern.sub(r"\1", self._ruby_version)
        self._ruby_download_url = "https://cache.ruby-lang.org/pub/ruby/{}/ruby-{}.tar.gz".format(
            feature_version, self._ruby_version)
        self._ruby_tar = Tar(self._ruby_download_url, self._ruby_part_dir)
        self.build_packages.extend([
            "gcc", "g++", "make", "zlib1g-dev", "libssl-dev", "libreadline-dev"
        ])
Beispiel #16
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        base = self.project._get_build_base()
        if base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name, base=base)

        self._rosdistro = _BASE_TO_ROS_RELEASE_MAP[base]

        self.build_packages.extend(
            ["gcc", "g++", "libc6-dev", "make", "python-pip"])
        self.__pip = None

        # roslib is the base requiremet to actually create a workspace with
        # setup.sh and the necessary hooks.
        self.stage_packages.append("ros-{}-roslib".format(self._rosdistro))

        # Get a unique set of packages
        self.catkin_packages = None
        if options.catkin_packages is not None:
            self.catkin_packages = set(options.catkin_packages)
        self.stage_packages_path = pathlib.Path(
            self.partdir) / "catkin_stage_packages"
        self._rosdep_path = os.path.join(self.partdir, "rosdep")
        self._catkin_path = os.path.join(self.partdir, "catkin")
        self._wstool_path = os.path.join(self.partdir, "wstool")

        # The path created via the `source` key (or a combination of `source`
        # and `source-subdir` keys) needs to point to a valid Catkin workspace
        # containing another subdirectory called the "source space." By
        # default, this is a directory named "src," but it can be remapped via
        # the `source-space` key. It's important that the source space is not
        # the root of the Catkin workspace, since Catkin won't work that way
        # and it'll create a circular link that causes rosdep to hang.
        if self.options.source_subdir:
            self._ros_package_path = os.path.join(self.sourcedir,
                                                  self.options.source_subdir,
                                                  self.options.source_space)
        else:
            self._ros_package_path = os.path.join(self.sourcedir,
                                                  self.options.source_space)

        if os.path.abspath(self.sourcedir) == os.path.abspath(
                self._ros_package_path):
            raise CatkinWorkspaceIsRootError()
Beispiel #17
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project.info.get_build_base() not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project.info.get_build_base())

        self.build_snaps.append("crystal/{}".format(
            self.options.crystal_channel))
        self.build_packages.extend([
            "gcc",
            "pkg-config",
            "libpcre3-dev",
            "libevent-dev",
            "libyaml-dev",
            "libgmp-dev",
            "libxml2-dev",
        ])
Beispiel #18
0
 def _setup_base_tools(self, base):
     # NOTE: stage-packages are lazily loaded.
     if base in ("core", "core16", "core18"):
         if self.options.python_version == "python3":
             self.build_packages.extend([
                 "python3-dev",
                 "python3-pip",
                 "python3-pkg-resources",
                 "python3-setuptools",
             ])
         elif self.options.python_version == "python2":
             self.build_packages.extend([
                 "python-dev",
                 "python-pip",
                 "python-pkg-resources",
                 "python-setuptools",
             ])
     else:
         raise errors.PluginBaseError(part_name=self.name, base=base)
Beispiel #19
0
    def _create_symlinks(self):
        base = self.project._get_build_base()
        if base not in ("core18", "core16", "core"):
            raise errors.PluginBaseError(part_name=self.name, base=base)

        os.makedirs(os.path.join(self.installdir, "bin"), exist_ok=True)
        java_bin = glob(
            os.path.join(
                self.installdir,
                "usr",
                "lib",
                "jvm",
                "java-{}-openjdk-*".format(self._java_version),
                "bin",
                "java",
            ))[0]
        os.symlink(
            os.path.relpath(java_bin, os.path.join(self.installdir, "bin")),
            os.path.join(self.installdir, "bin", "java"),
        )
Beispiel #20
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project._get_build_base() not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project._get_build_base())

        self.build_packages.extend(["gcc", "git", "curl", "file"])
        self._rustup_dir = os.path.expanduser(os.path.join("~", ".rustup"))
        self._cargo_dir = os.path.expanduser(os.path.join("~", ".cargo"))
        self._rustup_cmd = os.path.join(self._cargo_dir, "bin", "rustup")
        self._cargo_cmd = os.path.join(self._cargo_dir, "bin", "cargo")
        self._rustc_cmd = os.path.join(self._cargo_dir, "bin", "rustc")
        self._rustdoc_cmd = os.path.join(self._cargo_dir, "bin", "rustdoc")

        self._manifest = collections.OrderedDict()

        if self.options.source_subdir:
            self.source_path = Path(self.sourcedir, self.options.source_subdir)
        else:
            self.source_path = Path(self.sourcedir)
Beispiel #21
0
    def _setup_base_tools(self, base):
        if base not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=self.project._get_build_base())

        if base in ("core", "core16"):
            valid_versions = ["8", "9"]
        elif base == "core18":
            valid_versions = ["8", "11"]

        version = self.options.ant_openjdk_version
        if not version:
            version = valid_versions[-1]
        elif version not in valid_versions:
            raise UnsupportedJDKVersionError(version=version,
                                             base=base,
                                             valid_versions=valid_versions)

        self.stage_packages.append("openjdk-{}-jre-headless".format(version))
        self.build_packages.append("openjdk-{}-jdk-headless".format(version))
        self._java_version = version
Beispiel #22
0
    def _setup_base_tools(self, base):
        if base not in ("core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=self.project.info.base)

        if base == "core16":
            valid_versions = ["8", "9"]
        elif base == "core18":
            valid_versions = ["8", "11"]

        version = self.options.ant_openjdk_version
        if version and version not in valid_versions:
            raise UnsupportedJDKVersionError(version=version,
                                             base=base,
                                             valid_versions=valid_versions)
        elif not version:
            # Get the latest version from the slice
            version = valid_versions[-1]

        self.stage_packages.append("openjdk-{}-jre-headless".format(version))
        self.build_packages.append("openjdk-{}-jdk-headless".format(version))
Beispiel #23
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)
        self.build_packages.append("cmake")
        self.build_packages.append("ninja-build")
        self.out_of_source_build = True

        cmd = '''
        echo 'deb http://archive.neon.kde.org/unstable bionic main' > /etc/apt/sources.list.d/neon.list
        echo 'deb http://ppa.launchpad.net/ymshenyu/grpc-1/ubuntu bionic main' > /etc/apt/sources.list.d/grpc.list
        sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E6D4736255751E5D
        sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 281f24e574404629aa3bda1a4f10c386c55cdb04
        sudo apt update -qq
        '''

        subprocess.call(cmd, shell=True)

        if project.info.get_build_base() not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(
                part_name=self.name, base=project.info.get_build_base()
            )

        if options.make_parameters:
            logger.warning("make-paramaters is deprecated, ignoring.")
Beispiel #24
0
    def _create_symlinks(self):
        if self.project.info.base not in ("core18", "core19"):
            raise errors.PluginBaseError(
                part_name=self.name, base=self.project.info.base
            )

        os.makedirs(os.path.join(self.installdir, "bin"), exist_ok=True)
        java_bin = glob(
            os.path.join(
                self.installdir,
                "usr",
                "lib",
                "jvm",
                "java-{}-openjdk-*".format(self.options.maven_openjdk_version),
                "jre",
                "bin",
                "java",
            )
        )[0]
        os.symlink(
            os.path.relpath(java_bin, os.path.join(self.installdir, "bin")),
            os.path.join(self.installdir, "bin", "java"),
        )
Beispiel #25
0
    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        if project.info.get_build_base() not in ("core", "core16", "core18"):
            raise errors.PluginBaseError(part_name=self.name,
                                         base=project.info.get_build_base())

        # Beta Warning
        # Remove this comment and warning once ruby plugin is stable.
        logger.warning("The ruby plugin is currently in beta, "
                       "its API may break. Use at your own risk")

        self._ruby_version = options.ruby_version
        self._ruby_part_dir = os.path.join(self.partdir, "ruby")
        feature_pattern = re.compile(r"^(\d+\.\d+)\..*$")
        feature_version = feature_pattern.sub(r"\1", self._ruby_version)
        self._ruby_download_url = "https://cache.ruby-lang.org/pub/ruby/{}/ruby-{}.tar.gz".format(
            feature_version, self._ruby_version)
        self._ruby_tar = Tar(self._ruby_download_url, self._ruby_part_dir)
        self._gems = options.gems or []
        self.build_packages.extend([
            "gcc", "g++", "make", "zlib1g-dev", "libssl-dev", "libreadline-dev"
        ])
Beispiel #26
0
 def _setup_base_tools(self, base):
     if base in ("core16", "core18"):
         self.build_packages.append("scons")
     else:
         raise errors.PluginBaseError(part_name=self.name, base=base)