Package: guix-patches;
Reported by: Paul Garlick <pgarlick <at> tourbillion-technology.com>
Date: Fri, 11 Aug 2017 11:08:01 UTC
Severity: normal
Tags: moreinfo, patch
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
View this message in rfc822 format
From: ludo <at> gnu.org (Ludovic Courtès) To: Paul Garlick <pgarlick <at> tourbillion-technology.com> Cc: mbakke <at> fastmail.com, 28045 <at> debbugs.gnu.org, ericbavier <at> centurylink.net Subject: [bug#28045] [PATCH] gnu: Add openfoam Date: Thu, 07 Sep 2017 13:57:10 +0200
[Message part 1 (text/plain, inline)]
Hi Paul, I made the modifications below (mostly cosmetic) and built it locally. However, the resulting layout, with /OpenFOAM-4.1 at the root and essentially all the source tree beneath it, is unsatisfying. Would it be possible to follow a layout closer to what we usually do: /gnu/store/…-openfoam-4.1 bin/ lib/ share/ etc/ If the answer is “no”, or if that would take an unreasonable amount of work which should really be upstream’s job, then I can understand and we can make an exception. Or perhaps there’s a middle ground we could find? For instance, we install the tree to lib/openfoam-4.1, and then create bin/ as a symlink to lib/openfoam-4.1/platforms/linux64GccDPInt32Opt/bin? Would that work? Thank you! Ludo’.
[Message part 2 (text/x-patch, inline)]
commit e334cc116c976aa13c5be61eedd895fb790fec83 Author: Ludovic Courtès <ludo <at> gnu.org> Date: Thu Sep 7 10:56:15 2017 +0200 openfoam fixlet diff --git a/gnu/packages/patches/openfoam-4.1-cleanup.patch b/gnu/packages/patches/openfoam-4.1-cleanup.patch index 590db5982..fc2107e0b 100644 --- a/gnu/packages/patches/openfoam-4.1-cleanup.patch +++ b/gnu/packages/patches/openfoam-4.1-cleanup.patch @@ -1,7 +1,7 @@ -# This patch removes all need for the ThirdParty files of OpenFOAM +# This patch removes all need for the ThirdParty files of OpenFOAM. -# Derived from easybuild patch: Ward Poelmans <wpoely86 <at> gmail.com> -# Modified for GNU Guix: Paul Garlick <pgarlick <at> tourbillion-technology.com> +# Derived from EasyBuild patch by Ward Poelmans <wpoely86 <at> gmail.com>. +# Modified for GNU Guix by Paul Garlick <pgarlick <at> tourbillion-technology.com>. diff -ur OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake --- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake @@ -76,7 +76,7 @@ diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL OpenFOAM-4.x-version-4. diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools --- OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools 2016-10-16 16:11:45.000000000 +0200 +++ OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools 2017-04-10 14:51:01.473221230 +0200 -@@ -29,13 +29,13 @@ +@@ -29,13 +29,5 @@ # #------------------------------------------------------------------------------ @@ -88,14 +88,6 @@ diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools OpenFOAM-4.x-vers - -export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH -export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH -+# version=svn -+# gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER -+# -+# GPERFTOOLS_VERSION=gperftools-$version -+# GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION -+# -+# export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH -+# export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH #------------------------------------------------------------------------------ diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis OpenFOAM-4.x-version-4.1/etc/config.sh/metis @@ -166,12 +158,11 @@ diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/o diff -ur OpenFOAM-4.x-version-4.1.org/wmake/makefiles/general OpenFOAM-4.x-version-4.1/wmake/makefiles/general --- OpenFOAM-4.x-version-4.1.org/wmake/makefiles/general +++ OpenFOAM-4.x-version-4.1/wmake/makefiles/general -@@ -33,7 +33,7 @@ +@@ -33,7 +33,6 @@ # The Makefile uses a POSIX shell #------------------------------------------------------------------------------ -SHELL = /bin/sh -+# SHELL = /bin/sh #------------------------------------------------------------------------------ diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm index 3446d72c6..ff2aa69b6 100644 --- a/gnu/packages/simulation.scm +++ b/gnu/packages/simulation.scm @@ -56,14 +56,14 @@ (version "4.1") (source (origin - (method url-fetch) - (uri (string-append + (method url-fetch) + (uri (string-append "http://dl.openfoam.org/source/" (string-map (lambda (x) (if (eq? x #\.) #\- x)) version))) - (file-name (string-append name "-" version ".tar.gz")) - (sha256 - (base32 "1hgh2kw7fqv4bfachhbjhw16v8j35jbv6s576fmz4ka2q4ks4wg3")) - (patches (search-patches "openfoam-4.1-cleanup.patch")))) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 "1hgh2kw7fqv4bfachhbjhw16v8j35jbv6s576fmz4ka2q4ks4wg3")) + (patches (search-patches "openfoam-4.1-cleanup.patch")))) (build-system gnu-build-system) (inputs `(("boost" ,boost) @@ -85,106 +85,116 @@ ("gnuplot" ,gnuplot) ("openmpi" ,openmpi))) (arguments - `(#:strip-directories (list (string-append + `( ;; Executable files and shared libraries are located in the 'platforms' + ;; subdirectory. + #:strip-directories (list (string-append "OpenFOAM-" ,version "/platforms/linux64GccDPInt32Opt/bin") (string-append "OpenFOAM-" ,version "/platforms/linux64GccDPInt32Opt/lib")) - ; executable files and shared libraries are - ; located in the 'platforms' subdirectory - #:validate-runpath? #f ; '#:elf-directories' is not recognised here - #:tests? #f ; no tests to run - #:phases (modify-phases %standard-phases - (add-after 'unpack 'rename-build-directory - (lambda _ - (use-modules (ice-9 ftw)) - (use-modules (ice-9 regex)) - (chdir "..") - ;; use 'OpenFOAM-version' convention to match pathname expectations - ;; in the build phase - (let ((unpack-dir (string-append - (getcwd) "/" - (list-ref (scandir (getcwd) (lambda (name) - (string-match "^OpenFOAM" name))) 0))) - (build-dir (string-append - (getcwd) "/OpenFOAM-" ,version))) - (rename-file unpack-dir build-dir) ; re-name build directory - (chdir (basename build-dir))) ; move to build directory - #t)) - (add-after 'patch-source-shebangs 'set-environment-variables - (lambda _ - (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch"))) - ;; set variables to define store paths - (for-each (lambda (library) - (setenv (string-append - (string-upcase library) "_ROOT") - (assoc-ref %build-inputs library))) libraries)) - ;; set variables to define package versions - (setenv "SCOTCHVERSION" ,(package-version scotch)) - (setenv "METISVERSION" ,(package-version metis)) - #t)) - (delete 'configure) ; no configure phase - (replace 'build - (lambda _ - ;; compile OpenFOAM libraries and applications - (zero? (system (format #f - "source ./etc/bashrc && ./Allwmake -j~a" - (parallel-job-count)))))) - (add-after 'build 'update-configuration-files - (lambda _ - ;; record store paths and package versions in configuration files - (substitute* "etc/config.sh/CGAL" - (("$BOOST_ROOT") (getenv "BOOST_ROOT"))) - (substitute* "etc/config.sh/CGAL" - (("$CGAL_ROOT") (getenv "CGAL_ROOT"))) - (substitute* "etc/config.sh/metis" - (("$METIS_ROOT") (getenv "METIS_ROOT"))) - (substitute* "etc/config.sh/metis" - (("$METISVERSION") (getenv "METISVERSION"))) - (substitute* "etc/config.sh/scotch" - (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT"))) - (substitute* "etc/config.sh/scotch" - (("$SCOTCHVERSION") (getenv "SCOTCHVERSION"))) - (substitute* "etc/config.sh/settings" - (("$GMP_ROOT") (getenv "GMP_ROOT"))) - (substitute* "etc/config.sh/settings" - (("$MPFR_ROOT") (getenv "MPFR_ROOT"))) - ;; reset lockDir variable to refer to write-enabled directory - (substitute* "wmake/wmake" - ((" lockDir=.*$") - " lockDir=$HOME/.$WM_PROJECT/.wmake\n")) - (substitute* "wmake/wmakeScheduler" - (("lockDir=.*$") - "lockDir=$HOME/.$WM_PROJECT/.wmake\n")) - (substitute* "wmake/wmakeSchedulerUptime" - (("lockDir=.*$") - "lockDir=$HOME/.$WM_PROJECT/.wmake\n")) - #t)) - (replace 'install - (lambda _ - ;; use 'OpenFOAM-version' convention - (let ((install-dir (string-append - %output "/OpenFOAM-" ,version))) - (mkdir-p install-dir) ; create install directory - ;; move contents of build directory to install directory - (copy-recursively "." install-dir))))))) - ;; Note: tutorial files are installed read-only in /gnu/store. - ;; To allow write permissions on files copied from the store a - ;; 'chmod' step is needed before running the applications. For - ;; example, from a user's login: - ;; $ source $GUIX_PROFILE/OpenFOAM-4.1/etc/bashrc - ;; $ mkdir -p $FOAM_RUN - ;; $ cd $FOAM_RUN - ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzdaily . - ;; $ cd pitzdaily - ;; $ chmod -R u+w . - ;; $ blockMesh + #:validate-runpath? #f ; '#:elf-directories' is not recognised here + #:tests? #f ; no tests to run + + #:modules ((ice-9 ftw) + (ice-9 regex) + (guix build gnu-build-system) + (guix build utils)) + + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'rename-build-directory + (lambda _ + (chdir "..") + ;; Use 'OpenFOAM-version' convention to match file name + ;; expectations in the build phase. + (let ((unpack-dir (string-append + (getcwd) "/" + (car (scandir (getcwd) + (lambda (name) + (string-match "^OpenFOAM" + name)))))) + (build-dir (string-append + (getcwd) "/OpenFOAM-" ,version))) + (rename-file unpack-dir build-dir) ; re-name build directory + (chdir (basename build-dir)) ; move to build directory + #t))) + (add-after 'patch-source-shebangs 'set-environment-variables + (lambda _ + (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch"))) + ;; set variables to define store paths + (for-each (lambda (library) + (setenv (string-append + (string-upcase library) "_ROOT") + (assoc-ref %build-inputs library))) libraries)) + ;; set variables to define package versions + (setenv "SCOTCHVERSION" ,(package-version scotch)) + (setenv "METISVERSION" ,(package-version metis)) + #t)) + (delete 'configure) ; no configure phase + (replace 'build + (lambda _ + ;; compile OpenFOAM libraries and applications + (zero? (system (format #f + "source ./etc/bashrc && ./Allwmake -j~a" + (parallel-job-count)))))) + (add-after 'build 'update-configuration-files + (lambda _ + ;; record store paths and package versions in configuration files + (substitute* "etc/config.sh/CGAL" + (("$BOOST_ROOT") (getenv "BOOST_ROOT"))) + (substitute* "etc/config.sh/CGAL" + (("$CGAL_ROOT") (getenv "CGAL_ROOT"))) + (substitute* "etc/config.sh/metis" + (("$METIS_ROOT") (getenv "METIS_ROOT"))) + (substitute* "etc/config.sh/metis" + (("$METISVERSION") (getenv "METISVERSION"))) + (substitute* "etc/config.sh/scotch" + (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT"))) + (substitute* "etc/config.sh/scotch" + (("$SCOTCHVERSION") (getenv "SCOTCHVERSION"))) + (substitute* "etc/config.sh/settings" + (("$GMP_ROOT") (getenv "GMP_ROOT"))) + (substitute* "etc/config.sh/settings" + (("$MPFR_ROOT") (getenv "MPFR_ROOT"))) + ;; reset lockDir variable to refer to write-enabled directory + (substitute* "wmake/wmake" + ((" lockDir=.*$") + " lockDir=$HOME/.$WM_PROJECT/.wmake\n")) + (substitute* "wmake/wmakeScheduler" + (("lockDir=.*$") + "lockDir=$HOME/.$WM_PROJECT/.wmake\n")) + (substitute* "wmake/wmakeSchedulerUptime" + (("lockDir=.*$") + "lockDir=$HOME/.$WM_PROJECT/.wmake\n")) + #t)) + (replace 'install + (lambda _ + ;; use 'OpenFOAM-version' convention + (let ((install-dir (string-append + %output "/OpenFOAM-" ,version))) + (mkdir-p install-dir) ; create install directory + ;; move contents of build directory to install directory + (copy-recursively "." install-dir) + #t)))))) + + ;; Note: tutorial files are installed read-only in /gnu/store. + ;; To allow write permissions on files copied from the store a + ;; 'chmod' step is needed before running the applications. For + ;; example, from a user's login: + ;; $ source $GUIX_PROFILE/OpenFOAM-4.1/etc/bashrc + ;; $ mkdir -p $FOAM_RUN + ;; $ cd $FOAM_RUN + ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzdaily . + ;; $ cd pitzdaily + ;; $ chmod -R u+w . + ;; $ blockMesh (native-search-paths - ;; define the FOAM_INST_DIR variable + ;; Define the FOAM_INST_DIR variable. (list (search-path-specification (variable "FOAM_INST_DIR") - (files '("."))))) + (files '(".")) + (separator #f)))) ;single entry (synopsis "Framework for numerical simulation of fluid flow") (description "OpenFOAM provides a set of solvers and methods for tackling problems in the field of Computational Fluid Dynamics (CFD). It is written in
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.