@@ -48,6 +48,9 @@ local function getPackageData(package_name)
4848 end
4949end
5050
51+ --- Checks if the provided "package_table" is valid.
52+ -- This works by checking if "package_table.unicornSpec" is a valid value,
53+ -- and then checks if there are unfulfilled dependencies.
5154local function check_valid (package_table )
5255 assert (package_table , " Expected 1 argument, got 0" )
5356 assert (
@@ -61,6 +64,10 @@ local function check_valid(package_table)
6164 end
6265end
6366
67+ --- Checks if a conflicting version of a package is installed.
68+ -- This checks if there is an equivalent or higher version of a package is installed.
69+ -- If one is not detected, installation continues.
70+ -- @param package_table A valid package table
6471local function check_installable (package_table )
6572 local existing_package = getPackageData (package_table .name )
6673 if existing_package then
@@ -78,6 +85,10 @@ local function check_installable(package_table)
7885 end
7986end
8087
88+ --- Installs filemaps from a "package_table" using "pkgType".
89+ -- This function traverses "/lib/unicorn/provider" for a valid package provider.
90+ -- If found, it uses that provider to install files to the system.
91+ -- Otherwise, it errors.
8192local function action_modular_providers (package_table )
8293 local match
8394 for _ , v in pairs (fs .list (" /lib/unicorn/provider/" )) do -- custom provider support
@@ -101,8 +112,11 @@ local function action_modular_providers(package_table)
101112 end
102113end
103114
115+ --- Gets "package_script_name" from "package_table.script" and runs it.
116+ -- @param package_table A valid package table
117+ -- @param package_script_name A value that is either "preinstall", "postinstall", "preremove", or "postremove".
104118local function action_script (package_table , package_script_name )
105- if package_table .script . preinstall then
119+ if package_table .script [ package_script_name ] then
106120 local output , scriptError = loadstring (package_table .script [package_script_name ])
107121 if scriptError then
108122 error (scriptError )
@@ -113,6 +127,9 @@ local function action_script(package_table, package_script_name)
113127end
114128
115129--- Installs a package from a package table.
130+ -- This function is split up into "checks" and "actions".
131+ -- Checks ensure that the operation can be completed,
132+ -- and actions do things with values in the package table.
116133-- @param package_table table A valid package table
117134-- @return boolean
118135-- @return table
@@ -136,6 +153,7 @@ function unicorn.core.install(package_table)
136153end
137154
138155--- Removes a package from the system.
156+ -- It traverses package_table.instdat.filemaps and deletes everything.
139157-- @param package_name string The name of a package.
140158-- @return boolean
141159function unicorn .core .uninstall (package_name )
0 commit comments