openfoam/bin/tools/update-mpi-links.in
Mark Olesen 9fe09ad21d ENH: installation helpers
----
install-dirs: a general directory installer

  Copy installs non-binary (platform) directories.
  Eg,

      install-dirs -prefix=... -devel
      install-dirs -prefix=... -default -no-app

----
install-platform: a platform (binary) installer

  This is primarily driven by the need to install into system mpi
  directories. The problem noted in issue #1893 is caused by the
  rpm-mpi-hooks (fedora and redhat-8).

  For the additional mpi library qualifier (openmpi-x86_64) to be
  added to the requirements, the mpi-specific libraries (eg,
  libPstream.so) need to be installed in the mpi system directory
  (eg, /usr/lib64/openmpi).

  However, then need symlinks from the system locations back to our
  local directories to ensure that the libraries are correctly found
  via our LD_LIBRARY_PATH and we don't get dummy libraries.

----
update-mpi-links: a post-install update hook

  Expected paths are registered as persistent information into the
  hook during packaging. Triggering the hook after installation
  completes the creation of the symlinks.

Normal usage,
```
prefix="/tmp/local-install/openfoam"

bin/tools/install-dirs -prefix="$prefix" -common
bin/tools/install-platform -prefix="$prefix"
```
Installs
 - /tmp/local-install/openfoam/META-INFO
 - /tmp/local-install/openfoam/bin
 - /tmp/local-install/openfoam/etc
 - /tmp/local-install/openfoam/platforms/linux64GccDPInt32Opt/bin
 - /tmp/local-install/openfoam/platforms/linux64GccDPInt32Opt/lib

Can also place architecture-dependent bits elsewhere,
```
prefix="/tmp/local-install/openfoam"
multi_arch="$(dpkg-architecture -qDEB_TARGET_MULTIARCH)"

bin/tools/install-dirs -prefix="$prefix" -common
bin/tools/install-platform -exec-prefix="$prefix/$multi_arch"
```
Installs
 - /tmp/local-install/openfoam/META-INFO
 - /tmp/local-install/openfoam/bin
 - /tmp/local-install/openfoam/etc
 - /tmp/local-install/openfoam/x86_64-linux-gnu/bin
 - /tmp/local-install/openfoam/x86_64-linux-gnu/lib

Can use it to flatten out platforms entirely,
```
prefix="/tmp/local-install/openfoam"
bin/tools/install-dirs -prefix="$prefix" -common
bin/tools/install-platform -exec-prefix="$prefix"
```
Installs
 - /tmp/local-install/openfoam/META-INFO
 - /tmp/local-install/openfoam/bin
 - /tmp/local-install/openfoam/etc
 - /tmp/local-install/openfoam/lib
2020-11-25 21:31:22 +01:00

76 lines
2.1 KiB
Bash

#!/bin/sh
FOAM_MPI="@FOAM_MPI@"
FOAM_SYSTEM_MPI_LIBBIN="@FOAM_SYSTEM_MPI_LIBBIN@"
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Description
# Update of links from system mpi lib/ to local lib/mpi-name
#
# Note
# Normally located as a trigger within the platforms/ directory
# Uses hard-coded values (eg, generated with autoconfig).
#
#------------------------------------------------------------------------------
cd "${0%/*}" || exit # Run from this directory
# Local values
FOAM_LIBBIN="$(pwd -P)/lib"
FOAM_MPI_LIBBIN="$FOAM_LIBBIN/$FOAM_MPI"
#------------------------------------------------------------------------------
echo "Link OpenFOAM ($FOAM_MPI) from system locations"
echo "Target: $FOAM_MPI_LIBBIN"
echo "Source: $FOAM_SYSTEM_MPI_LIBBIN"
if [ -z "$FOAM_MPI" ]
then
echo "FOAM_MPI not defined - skipping"
exit 0
fi
if [ -z "$FOAM_SYSTEM_MPI_LIBBIN" ]
then
echo "FOAM_SYSTEM_MPI_LIBBIN not defined - skipping"
exit 0
fi
if [ ! -d "$FOAM_SYSTEM_MPI_LIBBIN" ]
then
echo "No system mpi lib: $FOAM_SYSTEM_MPI_LIBBIN"
echo "... not updating"
exit 0
fi
if [ ! -d "$FOAM_LIBBIN" ]
then
echo "Missing $FOAM_LIBBIN"
exit 0
fi
#------------------------------------------------------------------------------
mkdir -p "$FOAM_MPI_LIBBIN"
# Create symlinks
(
cd "$FOAM_MPI_LIBBIN" || exit
for i in "$FOAM_SYSTEM_MPI_LIBBIN"/*
do
if [ -f "$i" ]
then
ln -svf "$i" "${i##*/}"
fi
done
)
exit 0 # clean exit
#------------------------------------------------------------------------------