Skip to content
Snippets Groups Projects
foamPack 3.37 KiB
Newer Older
  • Learn to ignore specific revisions
  • #!/bin/sh
    #------------------------------------------------------------------------------
    # =========                 |
    
    # \\      /  F ield         | foam-extend: Open Source CFD
    
    #  \\    /   O peration     | Version:     4.1
    
    Henrik's avatar
    Henrik committed
    #   \\  /    A nd           | Web:         http://www.foam-extend.org
    #    \\/     M anipulation  | For copyright notice see file Copyright
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
    #------------------------------------------------------------------------------
    
    #     This file is part of foam-extend.
    
    #     foam-extend is free software: you can redistribute it and/or modify it
    
    #     under the terms of the GNU General Public License as published by the
    
    #     Free Software Foundation, either version 3 of the License, or (at your
    
    #     option) any later version.
    #
    
    #     foam-extend is distributed in the hope that it will be useful, but
    #     WITHOUT ANY WARRANTY; without even the implied warranty of
    #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    #     General Public License for more details.
    
    #
    #     You should have received a copy of the GNU General Public License
    
    #     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
    
    #
    # Script
    #     foamPack [outputDir]
    #
    # Description
    
    #     Packs and compresses the foam directory for release
    
    #
    #------------------------------------------------------------------------------
    tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$
    
    timeStamp=$(date +%Y-%m-%d)
    packDir=$WM_PROJECT-$WM_PROJECT_VERSION
    packFile=${packDir}_${timeStamp}.tgz
    
    if [ ! -d $packDir ]
    then
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
        echo "Error: directory $packDir does not exist" 1>&2
        exit 1
    
    fi
    
    # add optional output directory
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
    if [ -d "$1" ]
    then
        packFile="$1/$packFile"
    
    fi
    
    if [ -f $packFile ]
    then
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
        echo "Error: $packFile already exists" 1>&2
        exit 1
    
    fi
    
    # Create time stamp file
    # ~~~~~~~~~~~~~~~~~~~~~~
    
    echo $timeStamp 2>/dev/null > $packDir/.timeStamp
    
    # Clean up on termination and on Ctrl-C
    trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT
    
    
    # Pack and compress the packFile using GNU tar
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    echo
    echo "Packing foam version $packDir into $packFile"
    echo
    echo "finding and packing"
    
    find -H $packDir               \
        ! -type d -type f          \
        ! -name "*~"               \
     -a ! -name ".*~"              \
     -a ! -name "*.orig"           \
     -a ! -name "*.dep"            \
     -a ! -name "*.o"              \
     -a ! -name "*.so"             \
     -a ! -name "*.a"              \
     -a ! -name "core"             \
     -a ! -name "core.[1-9]*"      \
     -a ! -name "pvml.[1-9]*"      \
     -a ! -name "log[0-9]*"        \
     -a ! -name "so_locations"     \
    | sed                          \
     -e "\@$packDir/.git/@d"       \
     -e "\@.svn/@d"                  \
     -e "\@$packDir/lib/@d"        \
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
     -e '\@/\.git/@d'              \
     -e '\@applications/bin/@d'    \
     -e '\@wmake/bin/@d'           \
     -e '\@/t/@d'                  \
    
     -e '\@Make[.A-Za-z]*/[^/]*/@d'   \
     -e '\@doc/[Dd]oxygen/html@d'     \
     -e '\@doc/[Dd]oxygen/latex@d'    \
     -e '\@doc/[Dd]oxygen/man@d'      \
     -e '\@/lnInclude@d'              \
     -e '\@/ii_files@d'               \
     | tee $tmpFile
    
    tar czpf $packFile --files-from $tmpFile
    
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
    if [ $? -eq 0 ]
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
        echo "Finished packing and compressing $packDir into file $packFile"
    
    Hrvoje Jasak's avatar
    Hrvoje Jasak committed
        echo "Error: failure packing $packDir into file $packFile" 1>&2
        rm -f $packFile 2>/dev/null
    
    fi
    
    #------------------------------------------------------------------------------