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, dest_dir) Download sources for building a rock, calling the appropriate protocol method.
fetch_url (url, filename) Fetch a local or remote file.
fetch_url_at_temp_dir (url, tmpname, filename) For remote URLs, create a temporary directory and download URL inside it.
get_sources (rockspec, extract, dest_dir) Download sources for building a rock using the basic URL downloader.
load_local_rockspec (filename, file) Back-end function that actually loads the local rockspec.
load_rockspec (filename) Load a local or remote 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, dest_dir)
Download sources for building a rock, calling the appropriate protocol method.

Parameters

  • rockspec: table: The rockspec table
  • extract: boolean: When downloading compressed formats, whether to extract the sources from the fetched archive or not.
  • dest_dir: string or nil: If set, will extract to the given directory.

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.
fetch_url_at_temp_dir (url, tmpname, filename)
For remote URLs, create a temporary directory and download URL inside it. This temporary directory will be deleted on program termination. For local URLs, just return the local pathname and its directory.

Parameters

  • url: string: URL to be downloaded
  • tmpname: string: name pattern to use for avoiding conflicts when creating temporary directory.
  • filename: string or nil: local filename of URL to be downloaded, in case it can't be inferred from the URL.

Return value:

(string, string) or (nil, string): absolute local pathname of the fetched file and temporary directory name; or nil and an error message.
get_sources (rockspec, extract, dest_dir)
Download sources for building a rock using the basic URL downloader.

Parameters

  • rockspec: table: The rockspec table
  • extract: boolean: Whether to extract the sources from the fetched source tarball or not.
  • dest_dir: string or nil: If set, will extract to the given directory.

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.
load_local_rockspec (filename, file)
Back-end function that actually loads the local rockspec. Performs some validation and postprocessing of the rockspec contents.

Parameters

  • filename:
  • file: string: The local filename of the rockspec file.

Return value:

table or (nil, string): A table representing the rockspec or nil followed by an error message.
load_rockspec (filename)
Load a local or remote rockspec into a table. This is the entry point for the LuaRocks tools. Only the LuaRocks runtime loader should use load_local_rockspec directly.

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!