Exemple #1
0
 def __init__(self, name, options, project):
     super().__init__(name, options, project)
     self._source_package_json = os.path.join(
         os.path.abspath(self.options.source), 'package.json')
     self._npm_dir = os.path.join(self.partdir, 'npm')
     self._nodejs_tar = sources.Tar(
         get_nodejs_release(self.options.node_engine,
                            self.project.deb_arch), self._npm_dir)
     if self.options.node_package_manager == 'yarn':
         logger.warning(
             'EXPERIMENTAL: use of yarn to manage packages is experimental')
         self._yarn_tar = sources.Tar(_YARN_URL, self._npm_dir)
Exemple #2
0
    def _get_sdk(self):
        sdk_arch = self.project.deb_arch
        if sdk_arch not in _SDK_ARCH:
            raise DotNetBadArchitectureError(architecture=sdk_arch, supported=_SDK_ARCH)
        # TODO: Make this a class that takes care of retrieving the infos
        sdk_files = self._get_sdk_info(self.options.dotnet_runtime_version)

        return sources.Tar(sdk_files["url"], self._dotnet_sdk_dir)
Exemple #3
0
 def __init__(self, name, options, project):
     super().__init__(name, options, project)
     self._npm_dir = os.path.join(self.partdir, "npm")
     self._nodejs_tar = sources.Tar(
         nodejs.get_nodejs_release(self.options.node_engine,
                                   self.project.deb_arch),
         self._npm_dir,
     )
Exemple #4
0
    def _install(self, rootdir):
        self._nodejs_tar.provision(self._npm_dir,
                                   clean_target=False,
                                   keep_tarball=True)
        if self.options.nodejs_package_manager == "yarn":
            self._yarn_tar.provision(self._npm_dir,
                                     clean_target=False,
                                     keep_tarball=True)

        cmd = [
            os.path.join(self._npm_dir, "bin",
                         self.options.nodejs_package_manager)
        ]

        if self.options.nodejs_package_manager == "yarn":
            if os.getenv("http_proxy"):
                cmd.extend(["--proxy", os.getenv("http_proxy")])
            if os.getenv("https_proxy"):
                cmd.extend(["--https-proxy", os.getenv("https_proxy")])

        flags = []
        if rootdir == self.builddir:
            flags = ["--prod"]

        self.run(cmd + ["install"] + flags, rootdir)

        package_json = self._get_package_json(rootdir)
        # Take into account scoped names
        name = package_json["name"].lstrip("@").replace("/", "-")
        version = package_json["version"]

        # npm pack will create a tarball of the form
        # <package-name>-<package-version>.tgz
        # and we will tell yarn pack to create one with this
        # predictable name.
        package_tar_path = "{name}-{version}.tgz".format(name=name,
                                                         version=version)
        if self.options.nodejs_package_manager == "yarn":
            self.run(cmd + ["pack", "--filename", package_tar_path], rootdir)
        else:
            self.run(cmd + ["pack"], rootdir)

        package_dir = os.path.join(rootdir, "package")
        package_tar = sources.Tar(package_tar_path, rootdir)
        package_tar.file = package_tar_path
        os.makedirs(package_dir, exist_ok=True)
        package_tar.provision(package_dir)

        with contextlib.suppress(FileNotFoundError):
            shutil.copy(
                os.path.join(rootdir, "yarn.lock"),
                os.path.join(package_dir, "yarn.lock"),
            )

        self.run(cmd + ["install"] + flags, package_dir)

        return package_dir
Exemple #5
0
 def _yarn_tar(self):
     if self._yarn_tar_handle is None:
         if self.options.nodejs_yarn_version:
             url = _YARN_VERSION_URL.format(
                 version=self.options.nodejs_yarn_version)
         else:
             url = _YARN_LATEST_URL
         self._yarn_tar_handle = sources.Tar(url, self._npm_dir)
     return self._yarn_tar_handle
Exemple #6
0
    def _get_sdk(self):
        sdk_arch = self.project.deb_arch
        if sdk_arch not in _SDK_ARCH:
            raise DotNetBadArchitectureError(architecture=sdk_arch, supported=_SDK_ARCH)
        # TODO: Make this a class that takes care of retrieving the infos
        sdk_info = self._get_sdk_info(self.options.dotnet_runtime_version)

        sdk_url = sdk_info["package_url"]
        return sources.Tar(
            sdk_url, self._dotnet_sdk_dir, source_checksum=sdk_info["checksum"]
        )
Exemple #7
0
    def _get_sdk(self):
        try:
            sdk_arch = _SDK_DICT_FOR_ARCH[self.project.deb_arch]
        except KeyError as missing_arch:
            raise NotImplementedError(
                'This plugin does not support architecture '
                '{}'.format(missing_arch))
        # TODO support more SDK releases
        sdk_version = sdk_arch['2.0.0']

        sdk_url = sdk_version['url_path']
        return sources.Tar(sdk_url,
                           self._dotnet_sdk_dir,
                           source_checksum=sdk_version['checksum'])
Exemple #8
0
 def _nodejs_tar(self):
     if self._nodejs_tar_handle is None:
         self._nodejs_tar_handle = sources.Tar(self._nodejs_release_uri,
                                               self._npm_dir)
     return self._nodejs_tar_handle
Exemple #9
0
 def __init__(self, name, options, project):
     super().__init__(name, options, project)
     self._npm_dir = os.path.join(self.partdir, 'npm')
     self._nodejs_tar = sources.Tar(
         _get_nodejs_release(self.options.node_engine), self._npm_dir)
Exemple #10
0
 def __init__(self, name, options, project):
     super().__init__(name, options, project)
     self._nodejs_dir = os.path.join(self.partdir, 'node')
     self._nodejs_tar = sources.Tar(
         get_nodejs_release(self.options.node_version), self._nodejs_dir)
 def _yarn_tar(self):
     if self._yarn_tar_handle is None:
         self._yarn_tar_handle = sources.Tar(_YARN_URL, self._npm_dir)
     return self._yarn_tar_handle
Exemple #12
0
 def __init__(self, name, options):
     super().__init__(name, options)
     self._nodejs_tar = sources.Tar(_get_nodejs_release(),
                                    os.path.join(self.partdir, 'npm'))