Module luarocks.fetch

Functions related to fetching and loading local and remote files.

Functions

fetch_and_unpack_rock (rock_file, dest) Obtain a rock and unpack it.
fetch_sources (rockspec, extract) Download sources (via HTTP, FTP, CVS) for building a rock.
fetch_url (url, filename) Fetch a local or remote file.
load_manifest (repo_url) Load a local or remote manifest describing a repository.
load_rockspec (filename) Load a rockspec into a table.


Functions

fetch_and_unpack_rock (rock_file, dest)
Obtain a rock and unpack it. If a directory is not given, a temporary directory will be created, which will be deleted on program termination.

Parameters

  • rock_file: string: URL or filename of the rock.
  • dest: string or nil: if given, directory will be used as a permanent destination.

Return value:

string or (nil, string): the directory containing the contents of the unpacked rock.
fetch_sources (rockspec, extract)
Download sources (via HTTP, FTP, CVS) for building a rock.

Parameters

  • rockspec: table: The rockspec table
  • extract: boolean: Whether to extract the sources from the fetched source tarball or not.

Return value:

(string, string) or (nil, string): The absolute pathname of the fetched source tarball and the temporary directory created to store it; or nil and an error message.
fetch_url (url, filename)
Fetch a local or remote file. Make a remote or local URL/pathname local, fetching the file if necessary. Other "fetch" and "load" functions use this function to obtain files. If a local pathname is given, it is returned as a result.

Parameters

  • url: string: a local pathname or a remote URL.
  • filename: string or nil: this function attempts to detect the resulting local filename of the remote file as the basename of the URL; if that is not correct (due to a redirection, for example), the local filename can be given explicitly as this second argument.

Return value:

string or (nil, string): the absolute local pathname for the fetched file, or nil and a message in case of errors.
load_manifest (repo_url)
Load a local or remote manifest describing a repository. All functions that use manifest tables assume they were obtained through this function.

Parameters

  • repo_url: string: URL or pathname for the repository.

Return value:

table or (nil, string): A table representing the manifest, or nil followed by an error message.
load_rockspec (filename)
Load a rockspec into a table. All functions that use rockspec tables assume they were obtained through this function, which performs some validation and postprocessing of the rockspec contents.

Parameters

  • filename: string: Local or remote filename of a rockspec.

Return value:

table or (nil, string): A table representing the rockspec or nil followed by an error message.

Valid XHTML 1.0!