updated on Thu Jan 5 13:17:10 UTC 2012
[aur-mirror.git] / openfoam / PKGBUILD
blobc47b680da6c1b5812ca987873362ba9e5e0dd966
1 # Original Contributor: aquavitae <aquavitae69: gmail>
2 # Current Maintainer: Andrew Fischer <andrew_at_ltengsoft.com>
4 pkgname=openfoam
6 # The distributors package name
7 _distpkgname=OpenFOAM
9 pkgver=2.1.0
10 pkgrel=1
11 pkgdesc="The open source CFD toolbox"
12 arch=('i686' 'x86_64')
13 url="http://www.openfoam.com"
14 license=('GPL')
15 groups=()
16 depends=(paraview parmetis scotch ptscotch-openmpi)
17 makedepends=()
18 optdepends=()
19 provides=()
20 conflicts=()
21 replaces=()
22 backup=()
23 options=()
24 source=(http://downloads.sourceforge.net/foam/$_distpkgname-$pkgver.tgz)
25 noextract=()
26 install=openfoam.install
28 md5sums=('b48ca762fc2c87453b48d2f5c7a026bc')
30 # NOTE: build() and package() are split here due to OpenFOAM's use of the mpicc executable
31 # to determine the system openmpi settings during build(). 
32 # This currently does not function under fakeroot, for details see:
33 # https://svn.open-mpi.org/trac/ompi/ticket/2812
34 # https://bbs.archlinux.org/viewtopic.php?id=117493
36 build() {
37   # Extract the current version and major of paraview and of scotch for use in the system preferences
38   _pversion=`pacman -Qi paraview | grep Version | sed -e 's/Version.*: //g' | sed -e 's/-.*//g'`
39   _pmajor=`echo $_pversion | sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
40   _sversion=`pacman -Qi scotch | grep Version | sed -e 's/Version.*: //g' | sed -e 's/-.*//g'`
42   # Generate and install the system preferences file
43   echo "compilerInstall=system" > $startdir/prefs.sh
44   echo "export WM_MPLIB=SYSTEMOPENMPI" >> $startdir/prefs.sh
45   echo "export ParaView_VERSION=$_pversion" >> $startdir/prefs.sh
46   echo "export ParaView_MAJOR=$_pmajor" >> $startdir/prefs.sh
47   cp $startdir/prefs.sh $srcdir/$_distpkgname-$pkgver/etc || return 1
49   # Generate the scotch.sh file for arch
50   echo "export SCOTCH_VERSION=scotch_$_sversion" > $startdir/scotch.sh
51   echo "export SCOTCH_ARCH_PATH=/usr" >> $startdir/scotch.sh
52   cp $startdir/scotch.sh $srcdir/$_distpkgname-$pkgver/etc/config || return 1
54   # Patch for archlinux parmetis and paraview
55   patch -p1 < $startdir/decomp-options.patch
56   patch -p1 < $startdir/paraFoam.patch
58   # Setup the build environment
59   export FOAM_INST_DIR=$srcdir 
60   foamDotFile=$srcdir/$_distpkgname-$pkgver/etc/bashrc
61   [ -f $foamDotFile ] && . $foamDotFile || return 1
63   # Build and clean up OpenFOAM
64   cd "$srcdir/$_distpkgname-$pkgver" || return 1
65   ./Allwmake || return 1
66   wclean all || return 1
67   cd "$startdir"
70 package() {
71   # Create destination directories
72   mkdir -p "$pkgdir/opt/$_distpkgname" "$pkgdir/etc/profile.d" || return 1
74   # Move package to pkgdir
75   mv "$srcdir/$_distpkgname-$pkgver" "$pkgdir/opt/$_distpkgname/$_distpkgname-$pkgver" || return 1
77   # Add source file
78   cp "$startdir/openfoam.sh" "$pkgdir/etc/profile.d/openfoam.sh" || return 1
80   # Add stub thirdparty directory to keep openfoam happy
81   mkdir -p "$pkgdir/opt/$_distpkgname/ThirdParty-$pkgver"
83   # Permission fixes - for system-wide install and use
84   chmod -R go+r "$pkgdir/opt"
85   chmod -R 755 "$pkgdir/opt/$_distpkgname/$_distpkgname-$pkgver/bin"
86   chmod -R 755 "$pkgdir/opt/$_distpkgname/$_distpkgname-$pkgver/etc"
89 # vim:set ts=2 sw=2 et: