octave: Installing and Removing Packages
37.1 Installing and Removing Packages
=====================================
Assuming a package is available in the file ‘image-1.0.0.tar.gz’ it can
be installed from the Octave prompt with the command
pkg install image-1.0.0.tar.gz
If the package is installed successfully nothing will be printed on the
prompt, but if an error occurred during installation it will be
reported. It is possible to install several packages at once by writing
several package files after the ‘pkg install’ command. If a different
version of the package is already installed it will be removed prior to
installing the new package. This makes it easy to upgrade and downgrade
the version of a package, but makes it impossible to have several
versions of the same package installed at once.
To see which packages are installed type
pkg list
⊣ Package Name | Version | Installation directory
⊣ --------------+---------+-----------------------
⊣ image *| 1.0.0 | /home/jwe/octave/image-1.0.0
In this case only version 1.0.0 of the ‘image’ package is installed.
The ’*’ character next to the package name shows that the image package
is loaded and ready for use.
It is possible to remove a package from the system using the ‘pkg
uninstall’ command like this
pkg uninstall image
If the package is removed successfully nothing will be printed in the
prompt, but if an error occurred it will be reported. It should be
noted that the package file used for installation is not needed for
removal, and that only the package name as reported by ‘pkg list’ should
be used when removing a package. It is possible to remove several
packages at once by writing several package names after the ‘pkg
uninstall’ command.
To minimize the amount of code duplication between packages it is
possible that one package depends on another one. If a package depends
on another, it will check if that package is installed during
installation. If it is not, an error will be reported and the package
will not be installed. This behavior can be disabled by passing the
‘-nodeps’ flag to the ‘pkg install’ command
pkg install -nodeps my_package_with_dependencies.tar.gz
Since the installed package expects its dependencies to be installed it
may not function correctly. Because of this it is not recommended to
disable dependency checking.
-- : pkg COMMAND PKG_NAME
-- : pkg COMMAND OPTION PKG_NAME
-- : [OUT1, ...] = pkg (COMMAND, ... )
Manage or query packages (groups of add-on functions) for Octave.
Different actions are available depending on the value of COMMAND
and on return arguments.
Available commands:
‘install’
Install named packages. For example,
pkg install image-1.0.0.tar.gz
installs the package found in the file ‘image-1.0.0.tar.gz’.
The OPTION variable can contain options that affect the manner
in which a package is installed. These options can be one or
more of
‘-nodeps’
The package manager will disable dependency checking.
With this option it is possible to install a package even
when it depends on another package which is not installed
on the system. *Use this option with care.*
‘-local’
A local installation (package available only to current
user) is forced, even if the user has system privileges.
‘-global’
A global installation (package available to all users) is
forced, even if the user doesn’t normally have system
privileges.
‘-forge’
Install a package directly from the Octave-Forge
repository. This requires an internet connection and the
cURL library.
_Security risk_: no verification of the package is
performed before the installation. There are no
signature for packages, or checksums to confirm the
correct file was downloaded. It has the same security
issues as manually downloading the package from the
Octave Forge repository and installing it.
‘-verbose’
The package manager will print the output of all commands
as they are performed.
‘update’
Check installed Octave-Forge packages against repository and
update any outdated items. This requires an internet
connection and the cURL library. Usage:
pkg update
‘uninstall’
Uninstall named packages. For example,
pkg uninstall image
removes the ‘image’ package from the system. If another
installed package depends on the ‘image’ package an error will
be issued. The package can be uninstalled anyway by using the
‘-nodeps’ option.
‘load’
Add named packages to the path. After loading a package it is
possible to use the functions provided by the package. For
example,
pkg load image
adds the ‘image’ package to the path.
‘unload’
Remove named packages from the path. After unloading a
package it is no longer possible to use the functions provided
by the package.
‘list’
Show the list of currently installed packages. For example,
pkg list
will produce a short report with the package name, version,
and installation directory for each installed package. Supply
a package name to limit reporting to a particular package.
For example:
pkg list image
If a single return argument is requested then ‘pkg’ returns a
cell array where each element is a structure with information
on a single package.
installed_packages = pkg ("list")
If two output arguments are requested ‘pkg’ splits the list of
installed packages into those which were installed by the
current user, and those which were installed by the system
administrator.
[user_packages, system_packages] = pkg ("list")
The "-forge" option lists packages available at the
Octave-Forge repository. This requires an internet connection
and the cURL library. For example:
oct_forge_pkgs = pkg ("list", "-forge")
‘describe’
Show a short description of installed packages. With the
option "-verbose" also list functions provided by the package.
For example,
pkg describe -verbose
will describe all installed packages and the functions they
provide. Display can be limited to a set of packages:
pkg describe control signal # describe control and signal packages
If one output is requested a cell of structure containing the
description and list of functions of each package is returned
as output rather than printed on screen:
desc = pkg ("describe", "secs1d", "image")
If any of the requested packages is not installed, ‘pkg’
returns an error, unless a second output is requested:
[desc, flag] = pkg ("describe", "secs1d", "image")
FLAG will take one of the values "Not installed", "Loaded", or
"Not loaded" for each of the named packages.
‘prefix’
Set the installation prefix directory. For example,
pkg prefix ~/my_octave_packages
sets the installation prefix to ‘~/my_octave_packages’.
Packages will be installed in this directory.
It is possible to get the current installation prefix by
requesting an output argument. For example:
pfx = pkg ("prefix")
The location in which to install the architecture dependent
files can be independently specified with an addition
argument. For example:
pkg prefix ~/my_octave_packages ~/my_arch_dep_pkgs
‘local_list’
Set the file in which to look for information on locally
installed packages. Locally installed packages are those that
are available only to the current user. For example:
pkg local_list ~/.octave_packages
It is possible to get the current value of local_list with the
following
pkg local_list
‘global_list’
Set the file in which to look for information on globally
installed packages. Globally installed packages are those
that are available to all users. For example:
pkg global_list /usr/share/octave/octave_packages
It is possible to get the current value of global_list with
the following
pkg global_list
‘build’
Build a binary form of a package or packages. The binary file
produced will itself be an Octave package that can be
installed normally with ‘pkg’. The form of the command to
build a binary package is
pkg build builddir image-1.0.0.tar.gz ...
where ‘builddir’ is the name of a directory where the
temporary installation will be produced and the binary
packages will be found. The options ‘-verbose’ and ‘-nodeps’
are respected, while all other options are ignored.
‘rebuild’
Rebuild the package database from the installed directories.
This can be used in cases where the package database has been
corrupted.
See also: ver XREFver, news XREFnews.