Module unicorn.core

Core logic for installing and uninstalling packages on the local system.

Index

Function

install()

Installs a package from a package table.

uninstall()

Removes a package from the system. It traverses package_table.instdat.filemaps and deletes everything.

Api reference

unicorn.core.install(package_table: table): boolean, table

Installs a package from a package table.

Example

Reads a package table from the disk and installs it.

Danger

This is insecure code. This will execute the file at /tmp/example_package. You may want to consider evaluating /tmp/example_package in a sandbox, like the one provided with unicorn.util.evaluateInSandbox().

>>> local unicorn = require("unicorn")
>>> local file_1 = fs.open("/tmp/example_package")
>>> local contents = file_1.readAll()
>>> unicorn.core.install(dofile(contents))
Parameters:

package_table (table) – A valid package table

unicorn.core.uninstall(package_name: string): boolean

Removes a package from the system. It traverses package_table.instdat.filemaps and deletes everything.

Example

Uninstall a package named example-package.

>>> unicorn.core.uninstall("example-package")
Parameters:

package_name (string) – The name of a package.