2011-02-23 17:40:13 +00:00
|
|
|
# Octave packaging macros
|
|
|
|
|
|
|
|
# Octave binary API provided
|
2011-12-15 23:42:54 +00:00
|
|
|
%octave_api %(octave-config -p API_VERSION || echo 0)
|
2011-02-23 17:40:13 +00:00
|
|
|
|
|
|
|
# Octave Package Directories
|
|
|
|
%octshareprefix %{_datadir}/octave
|
|
|
|
%octprefix %{octshareprefix}/packages
|
2011-03-30 17:09:06 +00:00
|
|
|
%octarchprefix %{_libdir}/octave/packages
|
2011-02-23 17:56:38 +00:00
|
|
|
%octpkgdir %{octprefix}/%{octpkg}-%{version}
|
2011-02-23 17:40:13 +00:00
|
|
|
%octpkglibdir %{octarchprefix}/%{octpkg}-%{version}
|
|
|
|
|
|
|
|
# Run an octave command - quietly with no startup files
|
2012-01-16 08:09:26 +00:00
|
|
|
%octave_cmd() octave -H -q --no-window-system --no-site-file --eval "%*";
|
2011-02-23 17:40:13 +00:00
|
|
|
|
2013-12-28 23:33:27 +00:00
|
|
|
# Build unpacked source directory into a package tar file in a temporary location
|
|
|
|
%octave_pkg_build %octave_cmd pkg build '-verbose' '-nodeps' %{_tmppath}/%{name}-%{version}-%{release}.%{_arch} %{_builddir}/%{buildsubdir}
|
2011-02-23 17:40:13 +00:00
|
|
|
|
|
|
|
# Install a package. We use the octave pkg install command to install the
|
|
|
|
# built package into the buildroot. We also put a note to prevent the root
|
|
|
|
# user from removing the package with the octave pkg uninstall command
|
2011-02-14 21:51:21 +00:00
|
|
|
%octave_pkg_install \
|
2011-02-23 17:40:13 +00:00
|
|
|
mkdir -p %{buildroot}/%{octprefix} \
|
|
|
|
mkdir -p %{buildroot}/%{octarchprefix} \
|
|
|
|
%octave_cmd warning('off','all');pkg('prefix','%{buildroot}/%{octprefix}','%{buildroot}/%{octarchprefix}');pkg('global_list',fullfile('%{buildroot}/%{octshareprefix}','octave_packages'));pkg('local_list',fullfile('%{buildroot}/%{octshareprefix}','octave_packages'));pkg('install','-nodeps','-verbose','%{_tmppath}/%{name}-%{version}-%{release}.%{_arch}/%{octpkg}-%{version}.tar.gz');unlink(pkg('local_list'));unlink(pkg('global_list')); \
|
2011-02-14 21:51:21 +00:00
|
|
|
if [ -e %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m ] \
|
|
|
|
then \
|
|
|
|
mv %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m.orig \
|
|
|
|
fi \
|
|
|
|
echo "function on_uninstall (desc)" > %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m \
|
|
|
|
echo " error ('Can not uninstall %s installed by the redhat package manager', desc.name);" >> %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m \
|
|
|
|
echo "endfunction" >> %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m \
|
|
|
|
%{nil}
|
2011-02-23 17:40:13 +00:00
|
|
|
|
|
|
|
# preun script - we need to remove our uninstall protection and perhaps
|
|
|
|
# run the package's own uninstall script.
|
2011-03-30 17:09:06 +00:00
|
|
|
%octave_pkg_preun \
|
2011-02-14 21:51:21 +00:00
|
|
|
rm %{octpkgdir}/packinfo/on_uninstall.m \
|
|
|
|
if [ -e %{octpkgdir}/packinfo/on_uninstall.m.orig ]; then \
|
|
|
|
mv %{octpkgdir}/packinfo/on_uninstall.m.orig %{octpkgdir}/packinfo/on_uninstall.m \
|
|
|
|
cd %{octpkgdir}/packinfo \
|
|
|
|
%octave_cmd l=pkg('list');on_uninstall(l{cellfun(@(x)strcmp(x.name,'%{octpkg}'),l)}); \
|
|
|
|
fi \
|
|
|
|
%{nil}
|