1 #---------------------------------*- sh -*-------------------------------------
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright held by original author
7 #------------------------------------------------------------------------------
9 # This file is part of OpenFOAM.
11 # OpenFOAM is free software: you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
16 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 # You should have received a copy of the GNU General Public License
22 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # makeThirdPartyFunctionsForRPM
28 # Functions for managing the third-party packages with RPM
30 #------------------------------------------------------------------------------
32 # define the build and the system architecture type
33 buildBase=$WM_THIRD_PARTY_DIR/rpmBuild
34 architecture=`rpm --eval "%{_target_cpu}"`
37 RPM_CMD_XTRA_OPTIONS=''
39 # Adjust the rpm command options on Ubuntu/Debian based systems
40 ${RPM_CMD} --force-debian >& /dev/null
43 [ $RETVAL -eq 0 ] && RPM_CMD_XTRA_OPTIONS="--force-debian" #Success : Debian system
46 echo "This system rpm command: ${RPM_CMD} ${RPM_CMD_XTRA_OPTIONS}"
50 # Download/Build/Uninstall/Install a package
54 # Avoid word splitting on 'space'
63 while getopts p:s:u:a: flags
68 u) _PACKAGE_URL=$OPTARG
72 a) _ADDITIONALFLAGS=$OPTARG
77 echo "Package name : $_PACKAGE"
78 echo "Package URL : $_PACKAGE_URL"
79 echo "RPM spec file name: $_SPECFILE"
80 echo "Additional flags : $_ADDITIONALFLAGS"
83 shift `expr $OPTIND - 1`
85 # Make sure the ThirdParty environment is up-to-date
86 echo "Updating the ThirdParty environment variables before building package $_PACKAGE"
87 . $WM_PROJECT_DIR/etc/settings.sh
89 rpmName=$_PACKAGE-$WM_OPTIONS.$architecture
90 rpmFile=$buildBase/RPMS/$architecture/$rpmName.rpm
92 # We check immediatly if the RPM binary package is available in the local RPMs vault.
93 # If so, we basically uninstall/reinstall the package. This is handy for installation
94 # on machines with no Internet access, so without downloading capabilities. If one wants to
95 # force the recompilation of a given package, just make sure to move the corresponding RPM
96 # binary package away from the local RPM vault.
98 if [ ! -e "$rpmFile" ]; then
100 # The package's RPM is absent. We build from the package source tarball
105 # Do we need to download the package using the supplied URL
106 if [ -n "$_PACKAGE_URL" ]; then
107 packageTarBall=`basename $_PACKAGE_URL`
109 if [ ! -e "SOURCES/$packageTarBall" ]; then
110 echo "Download $packageTarBall from : $_PACKAGE_URL"
111 ( cd SOURCES; wget --no-check-certificate $_PACKAGE_URL )
115 echo "Making package $_PACKAGE using RPM."
116 rpm_build ${_PACKAGE} ${_SPECFILE} ${_ADDITIONALFLAGS} "$@"
119 # Install RPM package if not done already
120 if [ ! -e "$WM_THIRD_PARTY_DIR/packages/$_PACKAGE/platforms/$WM_OPTIONS" ]; then
121 echo "Installing package: $_PACKAGE"
122 rpm_uninstall $_PACKAGE
123 rpm_install $_PACKAGE
125 echo "Package $_PACKAGE is already installed"
131 unset _ADDITIONALFLAGS
133 echo "Done installing package $_PACKAGE"
138 # Build a RPM file using the package SPEC file
148 [ -e ./SPECS/$specFile ] || {
149 echo "rpm_build: missing SPEC file for package $package. Aborting."
154 echo "Building package $package using SPEC file : $specFile. Optional args: $@"
155 #rpmbuild --define "_topdir $buildBase" --dbpath $buildBase/rpmDB --clean -bb ./SPECS/$specFile "$@"
157 # Let's keep the compilation directory alive for now in order to facilitate postmortems of failed compilations
158 rpmbuild --define "_topdir $buildBase" --dbpath $buildBase/rpmDB -bb ./SPECS/$specFile "$@"
162 # Uninstall a package using its RPM
167 rpmName=$package-$WM_OPTIONS.$architecture
171 echo " Uninstalling $package using RPM: $rpmName"
172 ${RPM_CMD} ${RPM_CMD_XTRA_OPTIONS} -e $rpmName --dbpath $buildBase/rpmDB --norepackage >& /dev/null
174 # Note: rpm will rant when uninstalling packages with an error message
175 # starting with "error: LOOP:"
176 # Googling about this problem shows that this error is benign, and
177 # is related to the list of the files included in the RPM, and the
178 # syntax used in the SPEC file. Need to revisit later... MB
182 # Install a package using its relocatable RPM
187 rpmName=$package-$WM_OPTIONS.$architecture;
188 rpmFile=$buildBase/RPMS/$architecture/$rpmName.rpm;
190 echo " Installing $package using RPM file: $rpmFile";
191 ${RPM_CMD} ${RPM_CMD_XTRA_OPTIONS} -ivh \
193 --dbpath $buildBase/rpmDB --force --nodeps;
198 # Populate the local RPM vault with comand-line supplied list of RPMs
200 rpm_populateRPMvault()
202 rpmVault=$buildBase/RPMS/$architecture
204 echo " Local RPM vault location: $rpmVault"
206 echo " Moving the following RPMs to the local RPM vault: `echo $@`"
212 echo " Current content of the local RPM vault:"
217 # ----------------------------------------------------------------- end-of-file