Skip to content

Fully controllable profile of functions executed by mkarchiso

Fully controllable profile of functions executed by mkarchiso

About

This patch defines two new associative arrays and one array. These arrays allow you to control the behavior of mkarchiso almost completely from profiledef.

Detail

ignore_functions is an array showing a list of function names to ignore execution. _run_once executes only the functions not included in ignore_functions.

pre_functions is an associative array that represents the commands to execute before the functions are executed. The key contains the name of the target function, and the value contains the command to actually execute. These are reinterpreted and executed in the shell by eval.

post_functions is an associative array similar to pre_functions. However, the command assigned as a value will be executed after the target function finishes.

It will be possible to freely delete and add functions executed by these, and it is possible to add functions without directly operating mkarchiso. A good example is when adding a Readme etc. to an image file.

Also, since profiledef is a shell script, you can define your own functions in it and add them to pre_functions and post_functions.

Meaning

This patch isn't useful for Arch Linux, but it should be a new way to expand a new expression for anyone with their own profile. In fact, I plan to use the features added in this patch to reuse customize_airootfs.sh, which will be deprecated in the future.

Example

Here is a small example.

pre_functions=(
    ["_make_pacman_conf"]='echo "Before _make_pacman_conf"'
)

post_functions=(
    ["_make_pacman_conf"]='echo "After _make_pacman_conf"'
)

This is almost meaningless code, but it can be used for great evolution.

Issue

Test

I haven't fully tested this feature yet, so there may still be undiscovered bugs.

Documents

I haven't written any documentation for this patch yet. With my English ability, it is difficult to explain the function of this function in a short and well document. I'm looking for someone to create a document.

Definition and command execution method

It's a fundamental design issue, but it's not a good idea to put a command with arguments in a single variable instead of an array. Bash doesn't support multiple arrays, so I had no choice but to do this. Another option was to define a pre_ <func_name> array. Unlike an associative array, the array name includes the target function, so the command line to be executed can be defined by the array. Please tell us your thoughts on which is better.

### Very experimental The degree of freedom is so high that there may be some security or fundamentally significant flaws, but I couldn't find them.

Merge request reports

Loading