Skip to content
August 18, 2011 / jonathanunderwood

Deploying Mathematica as an rpm – spec file

For various reasons I need to deploy Mathematica across a bunch of machines and don’t want to do this manually. Since I have a local yum repository for locally built software, it’s handy to be able to deploy an rpm. Of course, we don’t really want to use all the dependency generation facilities of rpm as this is nasty binary compiled software which pays no attention to packaging standards but just dumps everything into a directory. Anyhow, this is what seems to work for me:


# Don't generate any debuginfo packages
%global debug_package %{nil}

# Disable rpath checking
%define __arch_install_post %{nil} 
%define __spec_install_post %{nil}

# Disable automatic dependency and provides information
%define __find_provides %{nil} 
%define __find_requires %{nil} 
%define _use_internal_dependency_generator 0
Autoprov: 0
Autoreq: 0


Name:           Mathematica
Version:        8.0.1
Release:        3%{?dist}
Summary:        A platform for scientific, engineering, and mathematical computation

Group:          Applications/Engineering
License:        Proprietary
URL:            http://wwww.wolfram.com
Source0:        %{name}_%{version}_LINUX.sh
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

#BuildRequires: 
#Requires:      

%description
Mathematica is a computational software program used in scientific,
engineering, and mathematical fields and other areas of technical
computing.

%prep
%setup -T -c %{name}-%{version}

cp %SOURCE0 .


%build
# Nothing to do

%install
rm -rf $RPM_BUILD_ROOT
%define destdir /opt/%{name}/%{version}

./%{name}_%{version}_LINUX.sh -- \
        -auto -createdir=y -selinux=y -verbose \
        -targetdir=$RPM_BUILD_ROOT%{destdir} \
        -execdir=$RPM_BUILD_ROOT%{destdir}/bin

# Unfortunately the installer script creates absolute symlinks which
# break once files are moved out of the build root. So, we have to
# manually recreate them here as relative links
before=($(echo $RPM_BUILD_ROOT%{destdir}/bin/*))

rm -rf $RPM_BUILD_ROOT%{destdir}/bin/*

for i in `ls $RPM_BUILD_ROOT%{destdir}/Executables` ; do
    ln -s %{destdir}/Executables/${i} $RPM_BUILD_ROOT%{destdir}/bin/${i}
done

ln -s %{destdir}/SystemFiles/Kernel/Binaries/Linux-x86-64/MathematicaScript $RPM_BUILD_ROOT%{destdir}/bin/MathematicaScript

after=($(echo $RPM_BUILD_ROOT%{destdir}/bin/*))

if [ "${before[*]}" != "${after[*]}" ] ; then
   echo "$RPM_BUILD_ROOT%{destdir}/bin doesn't contain all required symlinks after relinking"
   exit 1
fi

# Fix up prelink error 
# prelink: # $BUILDROOT/Mathematica-8.0.1-1.el6.x86_64/opt/Mathematica/8.0.1/SystemFiles/Libraries/Linux/libPHANToMIO.so.4:
# Could not find one of the dependencies)
# See eg. http://www.redhat.com/archives/rpm-list/2008-May/msg00011.html
prelink -u $RPM_BUILD_ROOT%{destdir}/SystemFiles/Libraries/Linux/libPHANToMIO.so.4

# Create mathpass file specifying license server 
cat > $RPM_BUILD_ROOT%{destdir}/Configuration/Licensing/mathpass << EOF
!mathlm-server.some.where.org
EOF



%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{destdir}
%{_sysconfdir}/profile.d/*

%changelog

Due to the large number of files being packaged, this takes quite a while to rpmbuild.

Leave a comment