# # Spec file for package openfoam # # Copyright (c) 2018-2019 OpenCFD Ltd. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, are GPL v3. # %define foam_patch %{nil} # Do not enable paraview plugins by default. # Could do so on openSUSE but the build then requires everything that # paraview and qt themselves require! %bcond_without paraview Name: openfoam1906 Version: 1906 Release: 0 Url: http://www.openfoam.com Summary: Free, Open Source, Computational Fluid Dynamics Package Group: Productivity/Scientific/Physics License: GPL-3.0-or-later Source0: https://sourceforge.net/projects/openfoam/files/v%{version}/OpenFOAM-v%{version}%{foam_patch}.tgz Source1: openfoam-rpmlintrc Prefix: /opt BuildRoot: %{_tmppath}/%{name}-%{version}-build Provides: openfoam = %{version} # Original directory (tar file) %define projectOrigDir OpenFOAM-v%{version} # Installation directory name %define projectDir openfoam-%{version} # We require C++11 (eg, gcc >= 4.8.5 etc). BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: flex BuildRequires: make BuildRequires: binutils BuildRequires: ncurses-devel BuildRequires: zlib-devel BuildRequires: readline-devel BuildRequires: boost-devel BuildRequires: fftw3-devel %if 0%{?suse_version} BuildRequires: cgal-devel %endif %if 0%{?fedora} BuildRequires: CGAL-devel %endif %if %{with paraview} BuildRequires: cmake BuildRequires: paraview-devel %if 0%{?suse_version} # As per paraview-devel, might be able to reduce this a bit BuildRequires: pkgconfig(Qt5Core) BuildRequires: pkgconfig(Qt5Gui) BuildRequires: pkgconfig(Qt5Help) BuildRequires: pkgconfig(Qt5Network) BuildRequires: pkgconfig(Qt5PrintSupport) BuildRequires: pkgconfig(Qt5WebKit) BuildRequires: pkgconfig(Qt5WebKitWidgets) BuildRequires: pkgconfig(Qt5Widgets) BuildRequires: pkgconfig(Qt5X11Extras) BuildRequires: pkgconfig(Qt5Xml) %endif %endif %if 0%{?fedora}%{?rhel}%{?centos} BuildRequires: environment-modules BuildRequires: infinipath-psm %endif BuildRequires: openmpi-devel BuildRequires: scotch-devel BuildRequires: ptscotch-openmpi-devel BuildRequires: rsync BuildRequires: openfoam-selector Requires(post): openfoam-selector Requires(preun): openfoam-selector Requires: gnuplot Requires: openmpi Requires: openmpi-devel %if %{with paraview} Requires: paraview %endif # OpenFOAM compiles without debug, so skip all of these %global _enable_debug_package 0 %global debug_package %{nil} %global __os_install_post %{nil} %define __debug_install_post %{nil} %description OpenFOAM is a free, open source computational fluid dynamics (CFD) software package produced by OpenCFD Ltd with twice yearly releases. It has a large user base across many areas of engineering and science, used in academic, government and commercial organizations. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics and electromagnetics. * Release notes https://www.openfoam.com/releases/openfoam-v%{version} * Documentation https://www.openfoam.com/documentation/ NOTE: The version in this package may not include any additional ParaView reader plugins, runTimePostProcessing etc. %package -n %{name}-doc Summary: OpenFOAM Documentation Group: Productivity/Scientific/Physics BuildArch: noarch Requires: %{name} = %{version} Provides: openfoam-doc = %{version} %description -n %{name}-doc OpenFOAM documentation (manpages and doxygen templates). %package -n %{name}-examples Summary: OpenFOAM Tutorials Group: Productivity/Scientific/Physics BuildArch: noarch Requires: %{name} = %{version} Provides: openfoam-examples = %{version} %description -n %{name}-examples OpenFOAM tutorial examples. %prep %setup -q -n %{projectOrigDir} # Configure third-party components bin/tools/foamConfigurePaths \ -version %{version} \ -boost boost-system \ -cgal cgal-system \ -fftw fftw-system \ -kahip kahip-none \ -scotch scotch-system \ %{?with_paraview:-paraview system} \ ; %build # MPI + scotch (suse) %if 0%{?suse_version} if [ -f %{_libdir}/mpi/gcc/openmpi/bin/mpivars.sh ] then source %{_libdir}/mpi/gcc/openmpi/bin/mpivars.sh fi bin/tools/foamConfigurePaths -scotch-path %{_libdir}/mpi/gcc/openmpi %endif # MPI + scotch (redhat) %if 0%{?fedora}%{?rhel}%{?centos} %{_openmpi_load} bin/tools/foamConfigurePaths -scotch-path %{_libdir}/openmpi %endif # Avoid external influence on the environment export FOAM_CONFIG_NOUSER=true unset FOAM_SETTINGS # When sourcing the bashrc file, some internal functions intentionally return # non-zero which triggers the '-o errexit' in some bash versions set +e # Turn errexit off source %{_builddir}/%{projectOrigDir}/etc/bashrc '' || \ echo "Ignore spurious sourcing error" set -e # Turn errexit back on # Avoid external influence on the environment unset FOAM_USER_APPBIN FOAM_USER_LIBBIN ./Allwmake -j -s -log=log.build # Check log for this type of content: # # api = 1812 # patch = 190828 # bin = 283 entries # lib = 139 entries [ -f log.build ] || { echo "No log.build file - build failed entirely" exit 1 } bins="$(tail -10 log.build | sed -ne 's/.*bin *= *\([0-9][0-9]*\).*/\1/p;')" libs="$(tail -10 log.build | sed -ne 's/.*lib *= *\([0-9][0-9]*\).*/\1/p;')" if [ "${bins:=0}" = 0 ] || [ "${libs:=0}" = 0 ] then echo echo "Build failed with $bins executables and $libs libraries" echo "Check the log.build file" echo exit 1 fi if [ -x bin/tools/foamCreateManpage ] then bin/tools/foamCreateManpage -gzip -version "v%{version}" || \ echo "ignore problems generating manpages" fi %install mkdir -p %{buildroot}%{prefix}/%{projectDir} rsync --delete --exclude build --exclude .gitignore --archive \ %{_builddir}/%{projectOrigDir}/ %{buildroot}%{prefix}/%{projectDir} %post projectDir="$RPM_INSTALL_PREFIX/%{projectDir}" # Update installation directory if pushd "$projectDir" then bin/tools/foamConfigurePaths \ -project-path "${projectDir}" popd fi # Register this version if /usr/bin/openfoam-selector \ --register %{name} \ --source-dir "${projectDir}" \ --yes then echo "Registered %{name} with openfoam-selector" else echo "Warn: could not register %{name} with openfoam-selector" fi # Install /usr/bin/openfoam-version script launcher="$projectDir/bin/tools/openfoam" wrapper="/usr/bin/openfoam-%{version}" if test -f "$launcher" then /usr/bin/sed -e "s#@PROJECT_DIR@#${projectDir}#" "$launcher" >| "$wrapper" echo "Registered %{name} as $wrapper" chmod 0755 "$wrapper" else echo "Warn: could not register %{name} as $wrapper" fi %preun wrapper="/usr/bin/openfoam-%{version}" # Only unregister when uninstalling if [ "$1" = "0" ] then # Deregister default if we are uninstalling it if [ "$(/usr/bin/openfoam-selector --system --query)" = "%{name}" ] then /usr/bin/openfoam-selector --system --unset --yes fi if /usr/bin/openfoam-selector --unregister %{name} --yes then echo "Unregistered %{name} from openfoam-selector" else echo "No %{name} found to unregister from openfoam-selector" fi if test -f "$wrapper" then echo "Unregistered %{name} as $wrapper" else echo "Warn: %{name} not registered as $wrapper" fi fi %files %defattr(-,root,root,-) %exclude %{prefix}/%{projectDir}/.git* %exclude %{prefix}/%{projectDir}/applications/test %exclude %{prefix}/%{projectDir}/doc %exclude %{prefix}/%{projectDir}/tutorials %exclude %{prefix}/%{projectDir}/modules/doc %exclude %{prefix}/%{projectDir}/modules/*/tutorials %{prefix}/%{projectDir} %files doc %defattr(-,root,root,-) %{prefix}/%{projectDir}/doc %{prefix}/%{projectDir}/modules/doc %files examples %defattr(-,root,root,-) %{prefix}/%{projectDir}/tutorials %{prefix}/%{projectDir}/modules/*/tutorials %changelog