octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OctavePackaging Again


From: David Bateman
Subject: OctavePackaging Again
Date: Fri, 15 Jun 2007 00:29:01 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Sorry for the size of the attachments to this message, but I'd like the
largest audience possible to comment on these packaging issues.. Ok,
I've taken another look at this based on the ideas previously discussed
with Paul. I see there are several conflicting criteria for a good
Octave package that includes "configure;make;make install" capabilities.
These are

* The Octave package manager should be encapsulated in the build
process, as much as possible. So that the logic of the Octave packager
manager is not replicated in the configure, make or install steps.

* The configure and make steps must take arbitrary flags, so that "make
-j2 DESTDIR=..." will work as expected. This means that the configure
and build steps must not use the Octave Package manager. These steps
don't have much overhead in the package manager and so there is very
little package manager logic to replicate. The install target is a
little messy though.

* As much of the Octave specific stuff should be hidden from the OSes
package manager. The post-install, pre-uninstall and post-uninstall
steps of the package installation need Octave specific steps. We can
handle them in a script that hides the details

* If a user runs "./configure;make;make install" the build should do
something sensible.

Essentially its impossible to get rid of all of the Octave specific
stuff in the OSes package manager. The reason is that Octave package
database needs updating at some point. The uninstall might be done by
Octave itself but that means that there is a very Octave specific
uninstall step in the RPM or DEB. Alternatively, we can just use the
OSes package manager to remove the packages files and use
"pkg('rebuild')" to reconstruct the database afterwards.

Based, on this I've written a pretty ugly Makefile and a very simple
configure script that are completely generic and might be added to all
octave-forge packages. I attach a sample SPEC file together with the
SRPM, the added Makefile and configure script. Thomas particular would
you be happy with such a solution?

The only downside of this solution I see is that the Makefile is quite
ugly and might break with either different versions of Octave or even
the shell. Any suggestions to simplify the Makefile while continuing to
hide the maximum number of details form the OSes package manager would
be appreciated.

D.

Attachment: octave_gsl-1.0.0-1mdk.src.rpm
Description: audio/pn-realaudio-plugin

Name:           octave_gsl
Version:        1.0.0
Release:        1%{?distsuffix}
Summary:        GNU Scientific Library.
Group:          Applications/Engineering
License:        GPL version 2 or later
URL:            http://octave.sourceforge.net
Source0:        http://downloads.sourceforge.net/octave/gsl-1.0.0.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root

## Package installs in a directory tree specific to the installed
## version of octave, so the following version dependency is necessary.
%define octave_ep  %(rpm -q --qf '%%{epoch}' octave)
%define octave_ver %(rpm -q --qf '%%{version}' octave)

Requires:       octave = %{octave_ep}:%{octave_ver}

BuildRequires:  octave >= 2.9.7
BuildRequires:  gcc-c++ gcc-gfortran libstdc++-devel
BuildRequires:  libstdc++-devel 
BuildRequires:  %(rpm -q --qf '%%{name}' %(rpm -q -f `which mkoctfile`))
BuildRequires: gsl-devel

%define octave octave-%{octave_ver}

%description
Octave bindings to the GNU Scientific Library

%prep
%setup -q -n gsl-1.0.0

%build
%configure
make TMPDIR=%{_tmppath} DESTDIR=%{buildroot} DISTPKG=%{distversion}

%install
rm -rf %{buildroot}
make install TMPDIR=%{_tmppath} DESTDIR=%{buildroot} DISTPKG=%{distversion}

%clean
rm -rf %{buildroot}

%post
%{_datadir}/octave/packages/gsl-1.0.0/packinfo/dist_admin install

%preun
%{_datadir}/octave/packages/gsl-1.0.0/packinfo/dist_admin uninstall

%postun
%{octave} -q -H --no-site-file --eval "pkg('rebuild');"

%files
%defattr(-,root,root)
%{_datadir}/octave/packages/*

%changelog
# Changelog for packages rebuilt on stable releases (leave it first):
%{!?_with_unstable:* %(LC_ALL=C date +"%a %b %d %Y") %{packager} 
%{version}-%{release}}
%{!?_with_unstable: - rebuild of %{version}-%{rel}%{?distsuffix} for 
%{distversion}}

* Mon Jun 4 2007 Teemu Ikonen   <address@hidden> 1.0.0-1%{?distsuffix}
- Automatically created from octave-forge package
#! /bin/sh -f

if [ -e src/configure ]; then
  cd src
  ./configure $*
fi

PKGDIR := $(shell pwd | sed -e 's|^.*/||')
TMPDIR ?= /tmp
PACKAGE := $(TMPDIR)/$(PKGDIR).tar.gz
PKG := $(shell echo $(PKGDIR) | sed -e 's|^\(.*\)-.*|\1|')

all: build package

build:
        @if [ -e src/Makefile ]; then \
           make -C src all; \
        fi

package:
        @if [ -d src ]; then \
          cd src; \
          if [ -e FILES ]; then \
            files=`cat FILES`; \
          else \
            files=`ls *.mex *.oct 2> /dev/null`; \
          fi; \
          if [ ! -d ../inst ]; then \
            mkdir ../inst; \
          fi; \
          cp -rf $$files ../inst; \
          cd ../; \
        fi; \
        cd ../; \
        tar --exclude='$(PKGDIR)/src' -czf $(PACKAGE) $(PKGDIR);

install: package
        @cd ../; \
        if [ "X${DISTPKG}X" != "XX" ]; then \
          stripcmd="unlink(pkg('local_list'));unlink(pkg('global_list'));"; \
        fi; \
        if [ "X$(DESTDIR)X" = "XX" ]; then \
          pkgdir=`octave -H -q --no-site-file --eval 
"warning('off','all');pkg('install','$(PACKAGE)');l=pkg('list');disp(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)}.dir);$$stripcmd;"`;
 \
        else \
          shareprefix=$(DESTDIR)/`octave -H -q --no-site-file --eval 
"disp(fullfile(OCTAVE_HOME(),'share','octave'));"`; \
          octprefix=$$shareprefix/packages; \
          if [ ! -e $$octprefix ]; then \
            mkdir -p $$octprefix; \
          fi; \
          pkgdir=`octave -H -q --no-site-file --eval 
"warning('off','all');pkg('prefix','$$octprefix');pkg('global_list',fullfile('$$shareprefix','octave_packages'));pkg('local_list',fullfile('$$shareprefix','octave_packages'));pkg('install','$(PACKAGE)');l=pkg('list');disp(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)}.dir);$$stripcmd;"`;
 \
        fi; \
        if [ "X${DISTPKG}X" != "XX" ]; then \
          if [ -e $$pkgdir/packinfo/on_uninstall.m ]; then \
            mv $$pkgdir/packinfo/on_uninstall.m \
               $$pkgdir/packinfo/on_uninstall.m.orig; \
          fi; \
          echo "function on_uninstall (desc)" > 
$$pkgdir/packinfo/on_uninstall.m; \
          echo "  error ('Can not uninstall %s installed by the $(DISTPKG) 
package manager', desc.name);" >> $$pkgdir/packinfo/on_uninstall.m; \
          echo "endfunction" >> $$pkgdir/packinfo/on_uninstall.m; \
          echo "#! /bin/sh -f" > $$pkgdir/packinfo/dist_admin; \
          echo "if [ \"\$$1\" == \"install\" ]; then" >> 
$$pkgdir/packinfo/dist_admin; \
          echo "  octave -H -q --no-site-file --eval \"pkg('rebuild');\"" >> 
$$pkgdir/packinfo/dist_admin; \
          echo "else"  >> $$pkgdir/packinfo/dist_admin; \
          echo "  pkgdir=`octave -H -q --no-site-file --eval 
\"pkg('rebuild');l=pkg('list');disp(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)}.dir);\"`"
 >> $$pkgdir/packinfo/dist_admin; \
          echo "  rm \$$pkgdir/packinfo/on_uninstall.m" >> 
$$pkgdir/packinfo/dist_admin; \
          echo "  if [ -e \$$pkgdir/packinfo/on_uninstall.m.orig ]; then" >> 
$$pkgdir/packinfo/dist_admin; \
          echo "    mv \$$pkgdir/packinfo/on_uninstall.m.orig 
\$$pkgdir/packinfo/on_uninstall.m" >> $$pkgdir/packinfo/dist_admin; \
          echo "    cd \$$pkgdir/packinfo" >> $$pkgdir/packinfo/dist_admin; \
          echo "    octave -q -H --no-site-file --eval 
\"l=pkg('list');on_uninstall(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)});\"" >> 
$$pkgdir/packinfo/dist_admin; \
          echo "  fi"  >> $$pkgdir/packinfo/dist_admin; \
          echo "fi"  >> $$pkgdir/packinfo/dist_admin; \
          chmod a+x $$pkgdir/packinfo/dist_admin; \
        fi;

clean:
        rm $(PACKAGE)
        make -C src clean

reply via email to

[Prev in Thread] Current Thread [Next in Thread]