#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# .
#
# Script
# create-tar [OPTION]
#
# Description
# Create a tar-file from OpenFOAM repository
# Grab and modify a corresponding .spec file, with rpmlintrc
#
# Requires
# bash curl git tar gzip sed
#
#------------------------------------------------------------------------------
repoUrl="https://develop.openfoam.com/Development/OpenFOAM-plus"
specUrl="$repoUrl/wikis/packaging/common"
specName="openfoamVERSION.spec"
branch="master"
release=0
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -gt 0 ]; do echo "$1"; shift; done
cat </dev/null
fi
mkdir -p "$outputDir"
[ "$verbose" = true ] && set -x
git clone -n --depth=1 \
--branch="$branch" \
"${repoUrl}.git" "$outputDir/$gitDir"
oldDir="$PWD"
if cd "$outputDir/$gitDir" # pushd
then
# The most current foamPackRelease (from develop branch)
curl "${repoUrl}/raw/develop/bin/tools/foamPackRelease" > foamPackRelease
# Minimum needed to get api/patch values
git checkout HEAD -- bin/foamEtcFile META-INFO
api="$(bin/foamEtcFile -show-api)"
patch="$(bin/foamEtcFile -show-patch)"
# Apparently cannot update submodule without checking out files
if [ -z "$skipModules" ]
then
git checkout HEAD -- .gitmodules modules
git submodule init && git submodule update --depth=1
fi
# Fetch tgz file, placing into parent dir (out-dir)
bash ./foamPackRelease \
${skipModules:+-no-modules} \
-tgz -output=.. HEAD | \
bash
# Preserve some information?
# for file in META-INFO/api-info
# do
# if [ -f "$file" ]
# then
# cp "$file" ..
# fi
# done
cd "$oldDir" # popd
else
echo "Could not change to $outputDir/$gitDir, did git clone fail?"
exit 1
fi
if [ "${keepTmpDir}" = true ]
then
echo "Retaining $outputDir/$gitDir"
echo " ... must be removed manually"
else
echo "Removing $outputDir/$gitDir"
rm -rf -- "$outputDir/$gitDir" 2>/dev/null
fi
if [ -n "${skipSpec}" ]
then
echo "Created tar only, without spec file"
exit 0
fi
# Filtering rules
unset filterPatch filterRelease
# Change foam_patch %{nil} -> foam_patch _patchNum
if [ "${patch:-0}" != 0 ]
then
filterPatch="/%define *foam_patch/s/patch.*\$/patch _${patch}/"
fi
# Any special handling for release info?
case "${release}" in
patch)
release="${patch:-0}"
;;
esac
# Modify release info in spec file,
# include '%{?dist}' macro (RedHat) if specified
if [ "${release:-0}" != 0 ]
then
filterRelease='s/^\(Release: *\).*/\1'"${release}${distMacro}/"
fi
oldDir="$PWD"
if cd "$outputDir" # pushd
then
# Grab and modify the spec file
curl "${specUrl}/${specName}" \
| sed -e 's/^\(Name: *\).*/\1'"openfoam$api/" \
| sed -e 's/^\(Version: *\).*/\1'"$api/" \
| sed -e "${filterPatch}" \
| sed -e "${filterRelease}" \
> "openfoam${api}.spec"
# Grab the rmplintrc file
curl "${specUrl}/openfoam-rpmlintrc" > "openfoam-rpmlintrc"
# List the files
ls -al
cd "$oldDir" # popd
else
echo "Could not change to $outputDir, should not happen"
exit 1
fi
# -----------------------------------------------------------------------------