View Source MishkaInstaller.Installer.Installer (Mishka installer v0.1.0)
When it comes to Erlan
g and Elixir
, the process of runtime installing and runtime uninstalling a
new library or runtime upgrading it is subject to a number of constraints.
These restrictions can be implemented based on specific strategies and under specific conditions.
Please take note that this is not about hot coding, which refers to the process of updating
a module that was developed using GenServer
.
On account of this objective, a number of action functions have been incorporated into this module in order to make it possible for this task to be completed for you in accordance with some established strategies.
Among these tactics is the utilisation of the Mix
tool, which is located within
the System
and Port
module.
During the subsequent releases, we will make an effort to incorporate the script
mode.
- Based on: https://elixirforum.com/t/12114/14
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Use cases information
Especially when you want to work with a library that depends on a large number of other libraries or vice versa, each of the functions of this file has its own requirements that must be taken into consideration.
Note:
If you are using Phoenix as developer mode, please disable
live_reload
indev.exs
. Please addreloadable_apps: [:mishka_installer]
to your endpoint config inconfig.exs
file.
Summary
Functions
This function is the same as the install/1
function, with the difference that it executes
one by one in a simple queue
To delete a runtime library from Mnesia database by id or name.
To drop all runtime libraries from Mnesia database.
To get all runtime libraries information from Mnesia database.
To get a runtime library information from Mnesia database by id.
To get a runtime library information from Mnesia database by App name.
To get all runtime libraries ids from Mnesia database.
This function, in point of fact, combines a number of different methods for downloading, compiling, and activating a library within the system. It is possible that this library is already present on the system, or it may serve as an update to the version that was previously available.
This function allows you to remove a library's directory from the build folder and deactivate the library from runtime.
The only difference of this function is in the custom path of deleting the build directory.
See uninstall/1
.
To check is a runtime library unique or not in Mnesia database.
This function is exactly like unique/2
function, except that its output is a Boolean.
To Add or edit a runtime library information from Mnesia database.
To edit a specific field/fields of a runtime library from the Mnesia database.
Types
@type com_type() :: :none | :cmd | :port | :mix
@type dep_type() :: :none | :force_update
@type download_type() ::
:hex
| :github
| :github_latest_release
| :github_latest_tag
| :github_release
| :github_tag
| :url
@type t() :: %MishkaInstaller.Installer.Installer{ app: String.t(), branch: branch() | nil, compile_type: com_type(), custom_command: String.t() | nil, dependency_type: dep_type(), depends: [String.t()], id: MishkaDeveloperTools.Helper.UUID.t() | nil, inserted_at: DateTime.t() | nil, path: String.t(), prepend_paths: [String.t()], release: String.t() | nil, tag: String.t() | nil, type: download_type(), updated_at: DateTime.t() | nil, version: String.t() }
Functions
@spec async_install(t()) :: error_return() | :ok
This function is the same as the install/1
function, with the difference that it executes
one by one in a simple queue
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
alias MishkaInstaller.Installer.Installer
# Normal calling
Installer.async_install(%__MODULE__{app: "some_name", path: "some_name", type: :hex})
# Use builder
{:ok, hex_tag} = Installer.builder(%{
app: "mishka_developer_tools",
version: "0.1.5",
tag: "0.1.5",
type: :hex,
path: "mishka_developer_tools"
})
Installer.async_install(hex_tag)
@spec delete(atom(), String.t()) :: error_return() | okey_return()
To delete a runtime library from Mnesia database by id or name.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
delete(:app, "mishka_developer_tools")
delete(:id, "c63aea42-209a-40fb-b5c6-a0d28ee7e25b")
To drop all runtime libraries from Mnesia database.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
drop()
To get all runtime libraries information from Mnesia database.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
get()
To get a runtime library information from Mnesia database by id.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
get("c63aea42-209a-40fb-b5c6-a0d28ee7e25b")
To get a runtime library information from Mnesia database by App name.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
get(:app, "mishka_developer_tools")
@spec ids() :: [String.t()]
To get all runtime libraries ids from Mnesia database.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
ids()
@spec install(t()) :: error_return() | okey_return()
This function, in point of fact, combines a number of different methods for downloading, compiling, and activating a library within the system. It is possible that this library is already present on the system, or it may serve as an update to the version that was previously available.
It ought to be underlined. Adding or updating a library in the system is supported by three different techniques in this version of the software.
- Obtain the file from
hex.pm
and install it. - Obtain the version from
GitHub
and install it. - Install by utilising the
folder
itself direct.
Naturally, it is important to point out that there are also features that can be used to enhance the system's customised functions. In order to accomplish this, the programmer needs to incorporate additional functions into his/her programme, such as downloading from a predetermined URL.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
In reality, the structure of this module __MODULE__.builder/1
, which likewise possesses
a high access level validation, is what this function takes as its input.
It is important to note that this validation and sanitizer is not intended for the user and is only necessary for the administrative level of data cleaning. Pay particular attention to the cautions regarding security.
For read more please see this type MishkaInstaller.Installer.Installer.t()
.
Example:
alias MishkaInstaller.Installer.Installer
# Normal calling
Installer.install(%__MODULE__{app: "some_name", path: "some_name", type: :hex})
# Use builder
{:ok, hex_tag} = Installer.builder(%{
app: "mishka_developer_tools",
version: "0.1.5",
tag: "0.1.5",
type: :hex,
path: "mishka_developer_tools"
})
Installer.install(hex_tag)
More info:
type
--> hex - github - github_latest_release - github_latest_tag - url - extractedcompile_type
--> cmd - port - mix- Download methods see
MishkaInstaller.Installer.Downloader
@spec uninstall(atom()) :: :ok
This function allows you to remove a library's directory from the build folder and deactivate the library from runtime.
Note that the sub-set libraries are not removed by this function.
In later versions, a checker to delete sub-app libraries might be included. You can add it as a custom for now.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
alias MishkaInstaller.Installer.Installer
# Normal calling
Installer.uninstall(%__MODULE__{app: "some_name", path: "some_name", type: :hex})
The only difference of this function is in the custom path of deleting the build directory.
See uninstall/1
.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
@spec unique(:app, String.t()) :: :ok | error_return()
To check is a runtime library unique or not in Mnesia database.
It returns
:ok
, or{:error, reason}
. Note that if the requested runtime library does not exist, It means it is unique, and if it is already in the database, it means it is not unique
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
unique(:app, "mishka_developer_tools")
This function is exactly like unique/2
function, except that its output is a Boolean.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
unique?(:app, "mishka_developer_tools")
@spec write(builder_entry()) :: error_return() | okey_return()
To Add or edit a runtime library information from Mnesia database.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
data = %{app: "uniq", version: "0.6.1", tag: "0.6.1", type: :hex, path: "uniq"}
write(data)
@spec write(atom(), String.t(), map()) :: error_return() | okey_return()
To edit a specific field/fields of a runtime library from the Mnesia database.
The first input can only be name and ID
[:app]
.
Security considerations
It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.
Example:
write(:app, "mishka_developer_tools", %{type: :hex})
write(:id, "c63aea42-209a-40fb-b5c6-a0d28ee7e25b", %{type: :hex})