File: README.Developers

package info (click to toggle)
matlab-support 0.0.21
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 240 kB
  • ctags: 4
  • sloc: sh: 418; makefile: 12
file content (106 lines) | stat: -rw-r--r-- 4,186 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Notes for developers
--------------------

If you are working on a package that needs to build MEX extensions for Matlab
you might want to follow the following steps to achieve this with relatively
little effort.

Since an official Debian package cannot build-depend on Matlab, MEX extensions
have to be built when a package is installed on a particular system. To
guarantee that a local Matlab is installed, a binary package may simply depend
on the 'matlab-support' package that represents one or more local Matlab
installations in the Debian package management system.

For maximum comfort, install all sources for MEX extensions into

  /usr/src/matlab/<package name>

Analogous to Octave, the 'matlab-support-dev' package ships a little Makefile
snippet defining the MATLAB_MEX_SRCDIR variable that points to
/usr/src/matlab/. The script can be included into debian/rules like this

  include /usr/share/matlab/debian/defs.make

To get the extensions built one needs to add a helper call to the package's
postinst script. Such postinst script might look like this:

-----------------------------------------------------------------------------
#!/bin/sh
set -e

case "$1" in
    configure)
        debian-matlab-mexhelper somepackagename install \
            --build-cmd 'matlab -nodesktop -nodisplay -nojvm -r build_matlab'
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#
-----------------------------------------------------------------------------

The call to 'debian-matlab-mexhelper' is fully customizable for arbitrary
commands to build and install extensions, as well as to clean up the source
tree afterwards. The matlab-support package offers default installation
directories for Matlab MEX extensions and M-files (hence complete toolboxes)
under /usr/lib/matlab/site and /usr/share/matlab/site/m respectively. The
aforementioned Makefile snippet defines the MATLAB_MEX_BINDIR and MATLAB_MDIR
variables that point to these locations. When Matlab toolboxes including MEX
extensions are installed into MATLAB_MDIR the debian-matlab-mexhelper helper
can also automatically move binary extensions to the respective
MATLAB_MEX_BINDIR and symlink them back into the actual installation directory.

Please take a look at the manpage for 'debian-matlab-mexhelper' for a
comprehensive list of options and a number of examples for common use cases.

Because 'debian-matlab-mexhelper' builds and installs extension files, as well
as symlinks (in some cases) this additional content has to be taken care of
separately when removing a package from the system. In this simplest case,
a package maintainer installs extensions into the aforementioned 'standard'
locations and adds a prerm script like this:

-----------------------------------------------------------------------------
#!/bin/sh
set -e

case "$1" in
    remove|upgrade|deconfigure)
        debian-matlab-mexhelper somepackagename clean
    ;;

    failed-upgrade)
    ;;

    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#
-----------------------------------------------------------------------------

Caveats
-------

While the matlab-support package tries to offer some integration of a local
Matlab installation into a Debian system this integration is not and cannot be
complete. For example, if a potentially required license manager is not running
the build process will fail and in turn cause the package installation itself
to fail -- leaving the package broken. A log file will be available for
inspection. The matlab-support package supports building extensions under a
user other than 'root', in case specific permissions for contacting a license
manager are required.

Moreover, Matlab lacks the concept of a 'package' (in contrast to Octave) that
can be used to enable/disable packages at runtime to deal with namespace
collisions. For this reason, no Matlab toolbox (installed by a Debian package)
is automatically added to Matlab's search path. Sysadmins or users have to
perform this final configuration step manually.