Пример #1
0
def url(url_string):
    url = urlparse(url_string)
    if url.scheme not in ALLOWED_SCHEMES:
        tty.die("Invalid protocol in URL: '%s'" % url_string)

    if not allowed_archive(url_string):
        tty.die("Invalid file type in URL: '%s'" % url_string)
Пример #2
0
 def default_version(self):
     """Get the version in the default URL for this package,
        or fails."""
     try:
         return url.parse_version(self.__class__.url)
     except UndetectableVersionError:
         tty.die("Couldn't extract a default version from %s. You " +
                 "must specify it explicitly in the package." % self.url)
Пример #3
0
    def do_uninstall(self):
        if not os.path.exists(self.prefix):
            tty.die(self.name + " is not installed.")

        if not self.ignore_dependencies:
            deps = self.installed_dependents
            if deps: tty.die(
                "Cannot uninstall %s. The following installed packages depend on it:"
                % self.name, " ".join(deps))

        self.remove_prefix()
        tty.msg("Successfully uninstalled %s." % self.name)
Пример #4
0
    def fetch_available_versions(self):
        # If not, then try to fetch using list_url
        if not self._available_versions:
            try:
                self._available_versions = find_versions_of_archive(
                    self.url,
                    list_url=self.list_url,
                    list_depth=self.list_depth,
                    wildcard=self.default_version.wildcard())

                if not self._available_versions:
                    tty.warn("Found no versions for %s" % self.name,
                             "Check the list_url and list_depth attribute on the "
                             + self.name + " package.",
                             "Use them to tell Spack where to look for versions.")

            except spack.error.NoNetworkConnectionError, e:
                tty.die("Package.fetch_available_versions couldn't connect to:",
                        e.url, e.message)
Пример #5
0
    def do_fetch(self):
        """Creates a stage directory and downloads the taball for this package.
           Working directory will be set to the stage directory.
        """
        self.stage.setup()

        if spack.do_checksum and not self.version in self.versions:
            tty.die("Cannot fetch %s@%s safely; there is no checksum on file for this "
                    "version." % (self.name, self.version),
                    "Add a checksum to the package file, or use --no-checksum to "
                    "skip this check.")

        self.stage.fetch()

        if self.version in self.versions:
            digest = self.versions[self.version]
            checker = crypto.Checker(digest)
            if checker.check(self.stage.archive_file):
                tty.msg("Checksum passed for %s" % self.name)
            else:
                tty.die("%s checksum failed for %s.  Expected %s but got %s."
                        % (checker.hash_name, self.name, digest, checker.sum))
Пример #6
0
    def do_install(self):
        """This class should call this version of the install method.
           Package implementations should override install().
        """
        if not self.spec.concrete:
            raise ValueError("Can only install concrete packages.")

        if os.path.exists(self.prefix):
            tty.msg("%s is already installed." % self.name)
            tty.pkg(self.prefix)
            return

        if not self.ignore_dependencies:
            self.do_install_dependencies()

        self.do_stage()
        self.setup_install_environment()

        # Add convenience commands to the package's module scope to
        # make building easier.
        self.add_commands_to_module()

        tty.msg("Building %s." % self.name)
        try:
            # create the install directory (allow the layout to handle this in
            # case it needs to add extra files)
            spack.install_layout.make_path_for_spec(self.spec)

            self.install(self.spec, self.prefix)
            if not os.path.isdir(self.prefix):
                tty.die("Install failed for %s.  No install dir created." % self.name)

        except Exception, e:
            if not self.dirty:
                self.remove_prefix()
            raise
Пример #7
0
 def install(self, spec, prefix):
     """Package implementations override this with their own build configuration."""
     tty.die("Packages must provide an install method!")