From 9ed9a541c9d7be3729339f810c50496ff6ceb63a Mon Sep 17 00:00:00 2001 From: marcost2 <52476474+marcost2@users.noreply.github.com> Date: Mon, 30 Oct 2023 10:19:42 -0300 Subject: freesurfer: fix support for linux (#39864) * Load the script file during enviroment setup so that all the enviroment variables are set properly * Patch csh/tcsh so that it uses spacks via env * Update SHA for latest version * Extend shebang to perl and fix up the regex --- .../repos/builtin/packages/freesurfer/package.py | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/var/spack/repos/builtin/packages/freesurfer/package.py b/var/spack/repos/builtin/packages/freesurfer/package.py index 4bf4a4a2f5..0e7188db06 100644 --- a/var/spack/repos/builtin/packages/freesurfer/package.py +++ b/var/spack/repos/builtin/packages/freesurfer/package.py @@ -3,7 +3,11 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import glob +import os + from spack.package import * +from spack.util.environment import EnvironmentModifications class Freesurfer(Package): @@ -14,11 +18,11 @@ class Freesurfer(Package): # A license is required, but is free to obtain. license_required = True - license_files = ["./license.txt"] + license_files = [".license"] maintainers("robgics") - version("7.4.1", sha256="eb6545d1ffdee17a90abd2e7dc444aa1091a6138e257f6f956a7ff214635b092") + version("7.4.1", sha256="313a96caeb246c5985f483633b5cf43f86ed8f7ccc6d6acfac8eedb638443010") version("7.4.0", sha256="6b65c2edf3b88973ced0324269a88966c541f221b799337c6570c38c2f884431") version("7.3.2", sha256="58518d3ee5abd2e05109208aed2eef145c4e3b994164df8c4e0033c1343b9e56") version("7.2.0", sha256="4cca78602f898bf633428b9d82cbb9b07e3ab97a86c620122050803779c86d62") @@ -27,6 +31,9 @@ class Freesurfer(Package): depends_on("mesa-glu") depends_on("qt") + depends_on("tcsh") + depends_on("bc") + depends_on("perl") def url_for_version(self, version): return "https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/{0}/freesurfer-linux-centos7_x86_64-{1}.tar.gz".format( @@ -34,10 +41,24 @@ class Freesurfer(Package): ) def setup_run_environment(self, env): + source_file = join_path(self.prefix, "SetUpFreeSurfer.sh") env.prepend_path("PATH", self.prefix.bin) env.set("FREESURFER_HOME", self.prefix) env.set("SUBJECTS_DIR", join_path(self.prefix, "subjects")) env.set("FUNCTIONALS_DIR", join_path(self.prefix, "sessions")) + env.append_path("PERL5LIB", join_path(self.prefix, "mni/share/perl5")) + env.append_path("PATH", join_path(self.prefix, "mni/bin")) + env.extend(EnvironmentModifications.from_sourcing_file(source_file)) def install(self, spec, prefix): + scripts = ["sources.csh", "SetUpFreeSurfer.csh"] + scripts.extend(glob.glob("bin/*")) + scripts.extend(glob.glob("subjects/**/*", recursive=True)) + scripts.extend(glob.glob("fsfast/bin/*", recursive=True)) + scripts.extend(glob.glob("mni/bin/*", recursive=True)) + for s in scripts: + if os.path.isfile(s): + filter_file(r"(\/usr)?(\/local?)\/bin\/tcsh", "/usr/bin/env -S tcsh", s) + filter_file(r"(\/usr)?(\/local?)\/bin\/csh", "/usr/bin/env -S csh", s) + filter_file(r"(\/usr)?(\/local)?\/bin\/perl", "/usr/bin/env -S perl", s) install_tree(".", prefix) -- cgit v1.2.3-70-g09d2