コード例 #1
0
    def test_link_symlink_to_dir(self):
        os.symlink("bar", os.path.join("foo", "bar-link"))
        file_utils.link_or_copy_tree("foo", "qux")

        # Verify that the symlink remains a symlink
        self.assertThat(os.path.join("qux", "bar-link"),
                        unit.LinkExists("bar"))
コード例 #2
0
    def test_link_symlink_to_file(self):
        # Create a symlink to a file
        os.symlink("2", os.path.join("foo", "2-link"))
        file_utils.link_or_copy_tree("foo", "qux")

        # Verify that the symlink remains a symlink
        self.assertThat(os.path.join("qux", "2-link"), unit.LinkExists("2"))
コード例 #3
0
ファイル: nodejs.py プロジェクト: snapcore/snapcraft
    def build(self):
        super().build()

        package_dir = self._install(rootdir=self.builddir)

        # Now move everything over to the plugin's installdir
        link_or_copy_tree(package_dir, self.installdir)
        # Copy in the node binary
        link_or_copy(
            os.path.join(self._npm_dir, "bin", "node"),
            os.path.join(self.installdir, "bin", "node"),
        )
        # Create binary entries
        package_json = self._get_package_json(rootdir=self.builddir)
        _create_bins(package_json, self.installdir)

        lock_file_path = os.path.join(self.installdir, "yarn.lock")
        if os.path.isfile(lock_file_path):
            with open(lock_file_path) as lock_file:
                self._manifest["yarn-lock-contents"] = lock_file.read()

        # Get the names and versions of installed packages
        if self.options.nodejs_package_manager == "npm":
            installed_node_packages = self._get_installed_node_packages(self.installdir)
            self._manifest["node-packages"] = [
                "{}={}".format(name, installed_node_packages[name])
                for name in installed_node_packages
            ]
        # Skip this step if yarn is used, as it may produce different
        # dependency trees than npm
        else:
            self._manifest["node-packages"] = []
コード例 #4
0
ファイル: gradle.py プロジェクト: snapcore/snapcraft
    def build(self):
        super().build()

        if self._using_gradlew():
            gradle_cmd = ["./gradlew"]
        else:
            self._gradle_tar.provision(self._gradle_dir, keep_zip=True)
            gradle_cmd = ["gradle"]
        self.run(
            gradle_cmd + self._get_proxy_options() +
            self.options.gradle_options + ["jar"],
            rootdir=self.builddir,
        )

        src = os.path.join(self.builddir, self.options.gradle_output_dir)
        jarfiles = glob(os.path.join(src, "*.jar"))
        warfiles = glob(os.path.join(src, "*.war"))

        if len(jarfiles) > 0:
            basedir = "jar"
        elif len(warfiles) > 0:
            basedir = "war"
            jarfiles = warfiles
        else:
            raise RuntimeError("Could not find any built jar files for part")

        file_utils.link_or_copy_tree(
            src,
            os.path.join(self.installdir, basedir),
            copy_function=lambda src, dst: file_utils.link_or_copy(
                src, dst, self.installdir),
        )

        self._create_symlinks()
コード例 #5
0
ファイル: flutter.py プロジェクト: snapcore/snapcraft
    def build(self) -> None:
        super().build()

        self.run(["flutter", "pub", "get"])

        self.run([
            "flutter",
            "build",
            "linux",
            "--release",
            "-v",
            "-t",
            self.options.flutter_target,
        ])

        # Flutter only supports arm64 and amd64
        if Path(self.builddir, "build/linux/x64/release/bundle").exists():
            bundle_dir_path = Path(self.builddir,
                                   "build/linux/x64/release/bundle")
        elif Path(self.builddir, "build/linux/arm64/release/bundle").exists():
            bundle_dir_path = Path(self.builddir,
                                   "build/linux/arm64/release/bundle")
        else:
            bundle_dir_path = Path(self.builddir, "build/linux/release/bundle")

        install_bin_dir_path = Path(self.installdir) / "bin"
        install_bin_dir_path.mkdir(exist_ok=True)
        # Now move everything over to the plugin's installdir
        file_utils.link_or_copy_tree(bundle_dir_path.as_posix(),
                                     install_bin_dir_path.as_posix())
コード例 #6
0
ファイル: _deb.py プロジェクト: snapcore/snapcraft
    def unpack_stage_packages(
        cls, *, stage_packages_path: pathlib.Path, install_path: pathlib.Path
    ) -> None:
        pkg_path = None

        for pkg_path in stage_packages_path.glob("*.deb"):
            with tempfile.TemporaryDirectory(suffix="deb-extract") as extract_dir:
                # Extract deb package.
                cls._extract_deb(pkg_path, extract_dir)
                # Mark source of files.
                marked_name = cls._extract_deb_name_version(pkg_path)
                cls._mark_origin_stage_package(extract_dir, marked_name)
                # Stage files to install_dir.
                file_utils.link_or_copy_tree(extract_dir, install_path.as_posix())

        if pkg_path:
            cls.normalize(str(install_path))
コード例 #7
0
 def test_link_directory_to_directory(self):
     file_utils.link_or_copy_tree("foo", "qux")
     self.assertTrue(os.path.isfile(os.path.join("qux", "2")))
     self.assertTrue(os.path.isfile(os.path.join("qux", "bar", "3")))
     self.assertTrue(os.path.isfile(os.path.join("qux", "bar", "baz", "4")))
コード例 #8
0
 def test_link_subtree(self):
     file_utils.link_or_copy_tree("foo/bar", "qux")
     self.assertTrue(os.path.isfile(os.path.join("qux", "3")))
     self.assertTrue(os.path.isfile(os.path.join("qux", "baz", "4")))