def package_id(self):
     del self.info.options.with_unit_tests  # ICU unit testing shouldn't affect the package's ID
     del self.info.options.silent  # Verbosity doesn't affect package's ID
     if self.info.options.dat_package_file:
         dat_package_file_sha256 = tools.sha256sum(
             str(self.info.options.dat_package_file))
         self.info.options.dat_package_file = dat_package_file_sha256
    def download(self, url, dst="", subdir=False, sha256=""):
        """
		Downloads an archive file from the specified URL, optionaly compares its SHA256 to the specified value and extracts the archive.
		
		Args:
		- url: source URL
		- dst: destination directory. If empty, then a directory name derived from the download link is used.
		- subdir: If False and the archive contains only a single root directory, then the content of that directory is extracted into the destination directory.
		- sha256: The expected SHA256 hash of the downloaded file to be compared to the actual file hash. If empty, then the check is omitted.
		"""

        self.output.info("")
        self.output.info("downloading " + url + " ...")

        filename = os.path.basename(url)
        extension = os.path.splitext(filename)[1]

        tools.download(url, filename, retry=3, retry_wait=10)

        if sha256:
            sha256File = tools.sha256sum(filename)

            if sha256.upper() != sha256File.upper():
                raise Exception("SHA256 of downloaded file (" +
                                sha256File.upper() +
                                ") does not match expected value (" +
                                sha256.upper() + ")")

        self.output.info("SHA256 of downloaded file matches expected value (" +
                         sha256.upper() + ")")

        if not dst:
            dst = os.path.join(os.getcwd(), self.name)

        self.output.info("extracting " + filename + " ...")

        if extension == ".xz":
            tools.untargz(filename, dst)
        else:
            tools.unzip(filename, dst)

        print("")

        content = os.listdir(dst)

        if not subdir and len(content) == 1 and os.path.isdir(
                os.path.join(dst, content[0])):
            tempDir = os.path.join(os.path.dirname(dst), self.name + "Temp")
            os.rename(os.path.join(dst, content[0]), tempDir)

            if os.path.isdir(dst):
                os.rmdir(dst)

            os.rename(tempDir, dst)

        os.remove(filename)
示例#3
0
 def build(self):
     license_url = "https://raw.githubusercontent.com/Microsoft/vswhere/develop/LICENSE.txt"
     self.output.info("Download %s " % license_url)
     tools.download(license_url, "LICENSE.txt")
     vswhere_url = "https://github.com/Microsoft/vswhere/releases/download/%s/vswhere.exe" % self.version
     self.output.info("Download %s " % vswhere_url)
     tools.download(vswhere_url, "vswhere.exe")
     checksum = "103f2784c4b2c8e70c7c1c03687abbf22bce052aae30639406e4e13ffa29ee04"
     if tools.sha256sum("vswhere.exe") != checksum:
         raise Exception("vswhere.exe invalid checksum")
示例#4
0
    def test(self):
        if not tools.cross_building(self.settings, skip_x64_x86=True):
            lzip = os.path.join(self.deps_cpp_info["lzip"].bin_paths[0],
                                "lzip")
            self.run("{} --version".format(lzip))

            shutil.copy(os.path.join(self.source_folder, "conanfile.py"),
                        "conanfile.py")

            sha256_original = tools.sha256sum("conanfile.py")
            self.run("{} conanfile.py".format(lzip), run_environment=True)
            if not os.path.exists("conanfile.py.lz"):
                raise ConanException("conanfile.py.lz does not exist")
            if os.path.exists("conanfile.py"):
                raise ConanException(
                    "copied conanfile.py should not exist anymore")

            self.run("{} -d conanfile.py.lz".format(lzip),
                     run_environment=True)
            if tools.sha256sum("conanfile.py") != sha256_original:
                raise ConanException(
                    "sha256 from extracted conanfile.py does not match original"
                )
示例#5
0
    def source(self):
        source_url = "http://downloads.xiph.org/releases/theora/libtheora-%s.zip" % self.version
        sha256 = "f644fef154f7a80e7258c8baec5c510f594d720835855cddce322b924934ba36"
        tools.get(source_url, sha256=sha256)
        extracted_dir = 'lib' + self.name + "-" + self.version
        os.rename(extracted_dir, self._source_subfolder)

        with tools.chdir(os.path.join(self._source_subfolder, 'lib')):
            # file somehow missed in distribution
            tools.download(
                'https://raw.githubusercontent.com/xiph/theora/master/lib/theora.def',
                'theora.def')
            assert "56362ca0cc73172c06b53866ba52fad941d02fc72084d292c705a1134913e806" == tools.sha256sum(
                'theora.def')