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
|
2016-03-24 23:21:20 +00:00
|
|
|
%octave_cmd() octave -H -q --no-window-system --no-site-file --eval '%*';
|
2011-02-23 17:40:13 +00:00
|
|
|
|
2016-12-07 18:01:23 +00:00
|
|
|
# For compiled tarfile name
|
|
|
|
%octave_host %(octave-config -p CANONICAL_HOST_TYPE || echo 0)
|
|
|
|
|
2013-12-28 23:33:27 +00:00
|
|
|
# Build unpacked source directory into a package tar file in a temporary location
|
2016-12-07 05:44:18 +00:00
|
|
|
# Pass -T to use source tarball
|
|
|
|
%octave_pkg_build(T) %{lua:
|
2016-12-07 21:36:17 +00:00
|
|
|
if (rpm.expand("%{-T}") == "-T") then
|
|
|
|
octpkg_tarfile = rpm.expand("%{SOURCE0}")
|
|
|
|
else
|
2016-12-07 05:44:18 +00:00
|
|
|
octpkg_tarfile = rpm .expand("%{_tmppath}/%{octpkg}-%{version}.tar.gz")
|
|
|
|
print("tar czf "..octpkg_tarfile.." -C "..rpm.expand("%{_builddir} %{buildsubdir}").."\\n")
|
|
|
|
end
|
2016-12-07 21:36:17 +00:00
|
|
|
-- Avoid a warning from pkg build about making the build directory
|
|
|
|
-- and use a clean directory as octave pkg build will delete contents
|
|
|
|
print(rpm.expand("mkdir -p %{_builddir}/%{buildsubdir}/build\\n"))
|
|
|
|
-- This fails to keep the arguments to %octave_cmd for some reason
|
2016-12-07 05:44:18 +00:00
|
|
|
-- print(rpm.expand("%octave_cmd pkg build -verbose -nodeps %{_builddir}/%{buildsubdir} "..octpkg_tarfile).."\\n")
|
2016-12-08 21:28:22 +00:00
|
|
|
print(rpm.expand("octave -H -q --no-window-system --no-site-file --eval 'pkg build -verbose -nodeps %{_builddir}/%{buildsubdir}/build "..octpkg_tarfile).."'\\n")
|
2016-12-07 21:36:17 +00:00
|
|
|
-- Extract the source tarball for debuginfo generation
|
|
|
|
print(rpm.expand("tar xf "..octpkg_tarfile.." -C %{_builddir}/%{buildsubdir}/build\\n"))
|
2016-12-07 05:44:18 +00:00
|
|
|
}
|
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
|
2015-07-31 14:17:24 +00:00
|
|
|
# We call unlink to remove the 'octave_packages' file which contains the
|
|
|
|
# buildroot string and needs to be generated at package install time.
|
2011-02-14 21:51:21 +00:00
|
|
|
%octave_pkg_install \
|
2015-07-31 14:17:24 +00:00
|
|
|
mkdir -p %{buildroot}%{octprefix} \
|
|
|
|
mkdir -p %{buildroot}%{octarchprefix} \
|
2022-04-07 17:51:01 +00:00
|
|
|
%octave_cmd pkg("prefix","%{buildroot}%{octprefix}","%{buildroot}%{octarchprefix}");pkg("global_list",fullfile("%{buildroot}%{octshareprefix}","octave_packages"));pkg("install","-nodeps","-verbose",glob("%{_builddir}/%{buildsubdir}/build/%{octpkg}-%{version}-*.tar.gz"){1,1});unlink(pkg("global_list")); \
|
2011-02-14 21:51:21 +00:00
|
|
|
if [ -e %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m ] \
|
|
|
|
then \
|
2017-08-12 15:12:44 +00:00
|
|
|
mv %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m.orig \
|
2011-02-14 21:51:21 +00:00
|
|
|
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 \
|
2018-07-02 06:23:18 +00:00
|
|
|
if [ -e %{_builddir}/%{buildsubdir}/build/%{octpkg}-%{version}/*.metainfo.xml ] \
|
2017-08-11 04:33:13 +00:00
|
|
|
then \
|
2018-07-02 06:23:18 +00:00
|
|
|
echo "Found .metainfo.xml appdata file" \
|
2018-10-28 19:14:45 +00:00
|
|
|
mkdir -p %{buildroot}/%{_metainfodir} \
|
|
|
|
cp -p %{_builddir}/%{buildsubdir}/build/%{octpkg}-%{version}/*.metainfo.xml %{buildroot}/%{_metainfodir}/ \
|
|
|
|
appstream-util validate-relax --nonet %{buildroot}/%{_metainfodir}/*.metainfo.xml \
|
2018-07-02 06:23:18 +00:00
|
|
|
else \
|
|
|
|
echo "Did not find a .metainfo.xml appdata file" \
|
2017-08-11 04:33:13 +00:00
|
|
|
fi \
|
2011-02-14 21:51:21 +00:00
|
|
|
%{nil}
|
2011-02-23 17:40:13 +00:00
|
|
|
|
2015-07-31 14:17:24 +00:00
|
|
|
# Run pkg tests - We need to reinstall to recreate 'octave_packages' so that
|
2017-02-08 18:02:56 +00:00
|
|
|
# octave can find the package, then remove 'octave_packages' again, and re-strip
|
|
|
|
# any shared objects.
|
2015-07-31 14:17:24 +00:00
|
|
|
%octave_pkg_check \
|
2023-03-09 02:44:09 +00:00
|
|
|
%octave_cmd pkg("prefix","%{buildroot}%{octprefix}","%{buildroot}%{octarchprefix}");pkg("local_list",fullfile("%{buildroot}%{octshareprefix}","octave_packages"));pkg("list");pkg("install","-verbose",glob("%{_builddir}/%{buildsubdir}/build/%{octpkg}-%{version}-*.tar.gz"){1,1});pkg("load","%{octpkg}");pkg("list");oruntests("%{buildroot}%{octpkgdir}");unlink(pkg("local_list")); \
|
2021-05-30 18:42:39 +00:00
|
|
|
/usr/lib/rpm/brp-strip %{__strip} \
|
2015-07-31 14:17:24 +00:00
|
|
|
%{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
|
|
|
if [ -e %{octpkgdir}/packinfo/on_uninstall.m.orig ]; then \
|
|
|
|
mv %{octpkgdir}/packinfo/on_uninstall.m.orig %{octpkgdir}/packinfo/on_uninstall.m \
|
|
|
|
cd %{octpkgdir}/packinfo \
|
2016-03-24 23:21:20 +00:00
|
|
|
%octave_cmd l=pkg("list");on_uninstall(l{cellfun(@(x)strcmp(x.name,"%{octpkg}"),l)}); \
|
2015-07-31 17:04:19 +00:00
|
|
|
else \
|
|
|
|
echo > %{octpkgdir}/packinfo/on_uninstall.m \
|
2011-02-14 21:51:21 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|