Package is the manager of Flux packages.

This library is the centralized controlling mechanism for them. Individual packages are represented by PackageInstance objects.

Summary

Methods

Adds a search path relative to the 'LUA' system.
Returns -1 if version1 is older than version2.
Describes the current package's specification.
Searches for the package with the specified name and returns true if the package exists, false otherwise.
Searches for a package with the specified name and returns the full path to its packagespec, the name of the package and the full path to the folder.
Attempts to include the package with the specified name.
Determines if the package has already been installed.
Returns true if version2 matches the version1 template.
Parse a version string.
Reloads the package with the specified name.

Methods

Package:add_path(path)

shared lib/package.lua:41

Adds a search path relative to the 'LUA' system.

Parameters

  • path String folder to look for packages in; a trailing slash is added if missing

Returns

  • Package self

Package:compare_version(version1, version2)

shared lib/package.lua:308

Returns -1 if version1 is older than version2. Returns 0 if versions are equal. Returns 1 if version1 is newer than version2.

Parameters

  • version1 Map version data from Package:parse_version
  • version2 Map version data from Package:parse_version

Returns

  • Number/Boolean -1, 0 or 1; false if either argument is not a table

Package:describe(callback)

shared lib/package.lua:73

Describes the current package's specification. A field may be given in its plural form, such as authors or files, and is stored under the singular one. Once the globals are set up, the dependencies are included.

Package:describe(function(s)
  s.name        = 'Example Package'
  s.version     = '1.0'
  s.date        = '2019-03-09'
  s.summary     = 'Brief summary of what the package does.'
  s.description = 'A more detailed description of what the package does.'
  s.authors     = { 'Flux Developer' }
  s.email       = 'example@example.com'
  s.files       = { 'lib/example.lua', 'config/example.lua' }
  s.global      = 'ExamplePackage'
  s.website     = 'https://example.com'
  s.license     = 'MIT'

  s.depends     'random_dependency'

  if IS_DEVELOPMENT then
    s.depends   'random_development_package'
  end
end)

Parameters

  • callback Function optional, defaults to nil receives the specification object to fill in as its only argument

Returns

  • PackageInstance

Package:exists(name)

shared lib/package.lua:218

Searches for the package with the specified name and returns true if the package exists, false otherwise.

Parameters

  • name String package name, or path to the package's folder

Returns

  • Boolean

Package:find(name)

shared lib/package.lua:194

Searches for a package with the specified name and returns the full path to its packagespec, the name of the package and the full path to the folder. Returns false if the package cannot be found.

Parameters

  • name String package name, or path to the package's folder

Returns

  • String/Boolean packagespec path or false if not found
  • String name
  • String folder path

Package:include(name, _version)

shared lib/package.lua:400

Attempts to include the package with the specified name. This function will look for the package in the search paths that have previously been added. If no package with the matching name can be found, throws an error.

Parameters

  • name String package name, or path to the package's folder
  • _version String optional, defaults to nil ignored

Returns

  • Boolean true if name is a .lua file, which is skipped; nothing otherwise

See also

Package:included(name)

shared lib/package.lua:180

Determines if the package has already been installed.

Parameters

  • name String package name

Returns

  • Boolean

Aliases

  • Package.present
  • Package.is_installed

Package:is_version(version1, version2)

shared lib/package.lua:326

Returns true if version2 matches the version1 template.

Parameters

  • version1 Map version data of the template, its op field sets the comparison
  • version2 Map version data of the version to check

Returns

  • Boolean

Package:parse_version(version)

shared lib/package.lua:239

Parse a version string.

Package:parse_version('~> 1.2.3-beta')
-- { x = 1, y = 2, z = 3, sum = 123, suffix = 'beta', op = '~>' }

Parameters

  • version String version such as '1.0', '>= 1.2.0' or '~> 1.2.3-beta'

Returns

  • Map version data with the fields x, y, z, sum, suffix and op

Package:reload(name)

shared lib/package.lua:225

Reloads the package with the specified name. Does nothing unless the package is installed and its specification allows reloading.

Parameters

  • name String package name

Defined in