From Fedora Project Wiki

 
(18 intermediate revisions by 4 users not shown)
Line 13: Line 13:
== RPM macros ==
== RPM macros ==


The following macros are defined in /etc/rpm/macros.octave in the octave package for help in packaging:
The following macros are defined in /etc/rpm/macros.octave in the octave 3.4.0 (Fedora 15+) package for help in packaging:


<pre>
<pre>
# Octave binary API provided
%octave_api %(octave-config -p API_VERSION || echo 0)}
%octave_api %(octave-config -p API_VERSION || echo 0)}
%_octshareprefix %{buildroot}%{_datadir}/octave
 
%_octprefix %{_octshareprefix}/packages
# Octave Package Directories
%_octarchprefix %{buildroot}%{_libexecdir}/octave/packages
%octshareprefix %{_datadir}/octave
%octave_cmd() octave -H -q --no-site-file --eval "%*";
%octprefix %{octshareprefix}/packages
%octave_pkg_build %octave_cmd pkg build '-verbose' %{_tmppath}/%{name}-%{version}-%{release}.%{_arch} %SOURCE0
%octarchprefix %{_libdir}/octave/packages
%octave_pkg_install \
 
mkdir -p %{_octprefix} \
%octpkgdir %{octshareprefix}/%{octpkg}-%{version}
mkdir -p %{_octarchprefix} \
%octpkglibdir %{octarchprefix}/%{octpkg}-%{version}
%octave_cmd warning('off','all');pkg('prefix','%{_octprefix}','%{_octarchprefix}');pkg('global_list',fullfile('%{_octshareprefix}','octave_packages'));pkg('local_list',fullfile('%{_octshareprefix}','octave_packages'));pkg('install','-nodeps','-verbose','%{_tmppath}/%{name}-%{version}-%{release}.%{_arch}/%{octpkg}-%{version}.tar.gz');unlink(pkg('local_list'));unlink(pkg('global_list')); \
 
if [ -e %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m ] \
# Run an octave command - quietly with no startup files
then \
%octave_cmd()
    mv %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m.orig \
 
fi \
# Build Source0 into a package tar file in a temporary location
echo "function on_uninstall (desc)" > %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m \
%octave_pkg_build
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 \
# Install a packageWe use the octave pkg install command to install the
%{nil}
# built package into the buildroot. We also put a note to prevent the root
%_octave_pkg_preun \
# user from removing the package with the octave pkg uninstall command
rm %{octpkgdir}/packinfo/on_uninstall.m \
%octave_pkg_install
if [ -e %{octpkgdir}/packinfo/on_uninstall.m.orig ]; then \
 
  mv %{octpkgdir}/packinfo/on_uninstall.m.orig %{octpkgdir}/packinfo/on_uninstall.m \
# preun script - we need to remove our uninstall protection and perhaps
  cd %{octpkgdir}/packinfo \
# run the package's own uninstall script.
  %octave_cmd l=pkg('list');on_uninstall(l{cellfun(@(x)strcmp(x.name,'%{octpkg}'),l)}); \
%octave_pkg_preun
fi \
%{nil}
%octpkgdir %{_datadir}/octave/packages/%{octpkg}-%{version}
%octpkglibdir %{_libexecdir}/octave/packages/%{octpkg}-%{version}
</pre>
</pre>
== Octave packaging tips ==
=== Naming of Octave packages ===
Packages of Octave packages have their own naming scheme. They should take into account the upstream name of the package. This makes a package name format of <code>octave-$NAME</code>. When in doubt, use the name of the module that you type to import it in octave.
'''Examples: '''
<pre>
octave-java (Octave package named java)
octave-gsl (Octave package named gsl)
</pre>
Limitations in the pkg function of octave (pkg.m) means that versioning of octave packages requires that the package version must have a MAJOR.MINOR.MICRO format. Failing to use this format results in octave not recognising binary package components in %prefix/libexec.
=== Updating the octave package database ===
Octave maintains a list of installed packages in /usr/share/octave/octave_packages that needs to be updated on package install and removal.  This file is in an octave plain-text format.
The contents of the /usr/share/octave/packages/ directory are scanned for the follwing files when performing a pkg('rebuild') from within octave.
* /usr/share/octave/packages/''NAMEOFPACKAGE''/packinfo/COPYING
* /usr/share/octave/packages/''NAMEOFPACKAGE''/packinfo/DESCRIPTION
If these files are not present in any given ''NAMEOFPACKAGE'' directory, then octave will silently skip the folder and fail to index it correctly.
Octave will use the contents of octave_packages to modify its path at startup, allowing octave to find plugins.
=== Documentation files ===
All package files are installed into the octave directories.


== Spec Templates for Octave packages ==
== Spec Templates for Octave packages ==
Line 54: Line 78:
<pre>
<pre>
%global octpkg image
%global octpkg image
# Exclude .oct files from provides
%global __provides_exclude_from ^%{octpkglibdir}/.*\\.oct$


Name:          octave-%{octpkg}
Name:          octave-%{octpkg}
Line 63: Line 89:
URL:            http://octave.sourceforge.net/image/
URL:            http://octave.sourceforge.net/image/
Source0:        http://downloads.sourceforge.net/octave/%{octpkg}-%{version}.tar.gz
Source0:        http://downloads.sourceforge.net/octave/%{octpkg}-%{version}.tar.gz
Requires:      octave(api) = %{octave_api}


BuildRequires:  octave-devel
BuildRequires:  octave-devel


Requires:      octave(api) = %{octave_api}
Requires(post): octave
Requires(postun): octave


%description
%description
Line 85: Line 112:


%install
%install
rm -rf %{buildroot}
%octave_pkg_install
%octave_pkg_install


Line 99: Line 125:


%files
%files
%defattr(-,root,root,-)
%{octpkglibdir}
%{octpkglibdir}
%dir %{octpkgdir}
%dir %{octpkgdir}
Line 126: Line 151:
Source0:        http://downloads.sourceforge.net/octave/%{octpkg}-%{version}.tar.gz
Source0:        http://downloads.sourceforge.net/octave/%{octpkg}-%{version}.tar.gz
BuildArch:      noarch
BuildArch:      noarch
Requires:      octave


BuildRequires:  octave-devel
BuildRequires:  octave-devel


Requires:      octave
Requires(post): octave
Requires(postun): octave


%description
%description
Line 145: Line 171:


%install
%install
rm -rf %{buildroot}
%octave_pkg_install
%octave_pkg_install


Line 159: Line 184:


%files
%files
%defattr(-,root,root,-)
%dir %{octpkgdir}
%dir %{octpkgdir}
%{octpkgdir}/*.m
%{octpkgdir}/*.m
Line 177: Line 201:
* Noarch packages don't install anything into %{octpkglibdir}
* Noarch packages don't install anything into %{octpkglibdir}


== Octave packaging tips ==
=== Obsoletes notes ===


=== Naming of Octave packages ===
Packages that used to be in the octave-forge package need to have the Obsoletes line abovePackages that were not do not.
Packages of Octave packages have their own naming scheme. They should take into account the upstream name of the package. This makes a package name format of <code>octave-$NAME</code>. When in doubt, use the name of the module that you type to import it in octave.
 
'''Examples: '''
<pre>
octave-java (Octave package named java)
octave-gsl (Octave package named gsl)
</pre>
 
Limitations in the pkg function of octave (pkg.m) means that versioning of octave packages requires that the package version must have a MAJOR.MINOR.MICRO format. Failing to use this format results in octave not recognising binary package components in %prefix/libexec.
 
=== unset TERM ===
Due to an issue with octave emitting an escape sequence (due to readline library) on startup, you need to unset the TERM variable in the %build and %install sections.
 
NOTE: This may no longer be necessaryIf it is, it will be added to the %octave_cmd macro.
 
=== Updating the octave package database ===
Octave maintains a list of installed packages in /usr/share/octave/octave_packages that needs to be updated on package install and removal.  This file is in an octave plain-text format.
 
The contents of the /usr/share/octave/packages/ directory are scanned for the follwing files when performing a pkg('rebuild') from within octave.
* /usr/share/octave/packages/''NAMEOFPACKAGE''/packinfo/COPYING
* /usr/share/octave/packages/''NAMEOFPACKAGE''/packinfo/DESCRIPTION
 
If these files are not present in any given ''NAMEOFPACKAGE'' directory, then octave will silently skip the folder and fail to index it correctly.
 
Octave will use the contents of octave_packages to modify its path at startup, allowing octave to find plugins.
 
=== Documentation files ===
All package files are installed into the octave directories.  The COPYING and DESCRIPTION files are documentation and need to be marked as %doc.  The others are not.


[[Category:Packaging guidelines drafts]]
[[Category:Packaging guidelines drafts]]

Latest revision as of 17:06, 8 March 2014

How to package Octave packages

What is Octave?

The definition from website says:

"GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab. It may also be used as a batch-oriented language."

If you are interested in packaging Octave packages, you should check here for upstream sources:

RPM macros

The following macros are defined in /etc/rpm/macros.octave in the octave 3.4.0 (Fedora 15+) package for help in packaging:

# Octave binary API provided
%octave_api %(octave-config -p API_VERSION || echo 0)}

# Octave Package Directories
%octshareprefix %{_datadir}/octave
%octprefix %{octshareprefix}/packages
%octarchprefix %{_libdir}/octave/packages

%octpkgdir %{octshareprefix}/%{octpkg}-%{version}
%octpkglibdir %{octarchprefix}/%{octpkg}-%{version}

# Run an octave command - quietly with no startup files
%octave_cmd()

# Build Source0 into a package tar file in a temporary location
%octave_pkg_build

# 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
%octave_pkg_install 

# preun script - we need to remove our uninstall protection and perhaps
# run the package's own uninstall script.
%octave_pkg_preun

Octave packaging tips

Naming of Octave packages

Packages of Octave packages have their own naming scheme. They should take into account the upstream name of the package. This makes a package name format of octave-$NAME. When in doubt, use the name of the module that you type to import it in octave.

Examples:

octave-java (Octave package named java)
octave-gsl (Octave package named gsl)

Limitations in the pkg function of octave (pkg.m) means that versioning of octave packages requires that the package version must have a MAJOR.MINOR.MICRO format. Failing to use this format results in octave not recognising binary package components in %prefix/libexec.

Updating the octave package database

Octave maintains a list of installed packages in /usr/share/octave/octave_packages that needs to be updated on package install and removal. This file is in an octave plain-text format.

The contents of the /usr/share/octave/packages/ directory are scanned for the follwing files when performing a pkg('rebuild') from within octave.

  • /usr/share/octave/packages/NAMEOFPACKAGE/packinfo/COPYING
  • /usr/share/octave/packages/NAMEOFPACKAGE/packinfo/DESCRIPTION

If these files are not present in any given NAMEOFPACKAGE directory, then octave will silently skip the folder and fail to index it correctly.

Octave will use the contents of octave_packages to modify its path at startup, allowing octave to find plugins.

Documentation files

All package files are installed into the octave directories.

Spec Templates for Octave packages

There are two types of Octave packages: arch-specific and noarch.

Arch specific Octave spec template

%global octpkg image
# Exclude .oct files from provides
%global __provides_exclude_from ^%{octpkglibdir}/.*\\.oct$

Name:           octave-%{octpkg}
Version:        1.0.13
Release:        1%{?dist}
Summary:        Image processing for Octave
Group:          Applications/Engineering
License:        GPLv2+
URL:            http://octave.sourceforge.net/image/
Source0:        http://downloads.sourceforge.net/octave/%{octpkg}-%{version}.tar.gz

BuildRequires:  octave-devel

Requires:       octave(api) = %{octave_api}
Requires(post): octave
Requires(postun): octave

%description
The Octave-forge Image package provides functions for processing images. The
package also provides functions for feature extraction, image statistics,
spatial and geometric transformations, morphological operations, linear
filtering, and much more. 


%prep
%setup -q -n %{octpkg}-%{version}


%build
%octave_pkg_build


%install
%octave_pkg_install


%post
%octave_cmd pkg rebuild

%preun
%octave_pkg_preun

%postun
%octave_cmd pkg rebuild

%files
%{octpkglibdir}
%dir %{octpkgdir}
%{octpkgdir}/*.m
%doc %{octpkgdir}/doc-cache
%{octpkgdir}/packinfo


%changelog
* Sat Feb 12 2011 Orion Poplawski <orion@cora.nwra.com> 1.0.13-1
- Initial Fedora package

Noarch Octave spec template

%global octpkg actuarial

Name:           octave-%{octpkg}
Version:        1.1.0
Release:        1%{?dist}
Summary:        Actuarial functions for Octave
Group:          Applications/Engineering
License:        GPLv2+
URL:            http://octave.sourceforge.net/
Source0:        http://downloads.sourceforge.net/octave/%{octpkg}-%{version}.tar.gz
BuildArch:      noarch

BuildRequires:  octave-devel

Requires:       octave
Requires(post): octave
Requires(postun): octave

%description
Actuarial functions for Casualty and Property lines.


%prep
%setup -q -n %{octpkg}-%{version}


%build
%octave_pkg_build


%install
%octave_pkg_install


%post
%octave_cmd pkg rebuild

%preun
%octave_pkg_preun

%postun
%octave_cmd pkg rebuild

%files
%dir %{octpkgdir}
%{octpkgdir}/*.m
%doc %{octpkgdir}/doc-cache
%{octpkgdir}/packinfo


%changelog
* Sat Feb 12 2011 Orion Poplawski <orion@cora.nwra.com> 1.1.0-1
- Initial Fedora package

Summary of differences between arch-specific and noarch octave packages

  • Noarch packages set BuildArch: noarch
  • Don't require a specific api version
  • Noarch packages don't install anything into %{octpkglibdir}

Obsoletes notes

Packages that used to be in the octave-forge package need to have the Obsoletes line above. Packages that were not do not.