Nature40 / pimod

Reconfigure Raspberry Pi images with an easy, Docker-like configuration file
GNU General Public License v3.0
122 stars 19 forks source link

Add INCLUDE command to include other Pifiles easily in our script without using sh'isms. #33

Closed aniongithub closed 2 years ago

aniongithub commented 3 years ago

To include other Pifiles, it's easy to use the source command, but this detracts from the Dockerfile-like nature of pimod. The INCLUDE command lets us do this, while ensuring that only Pifiles can be included (it appends a .Pifile to the provided filename).

oxzi commented 3 years ago

Thank you very much for your contribution! I like the idea of a more native feeling way to extend or include other Pifiles.

However, with your current approach, all INCLUDEd files will only be sourced in the 10-setup stage, as in every other stage the INCLUDE function does nothing. This results in the included Pifile being only sourced once, with only the 10-setup functions being available.

The current stage logic is implemented in a very straight forward way with a code block like the following for each of the four stages: https://github.com/Nature40/pimod/blob/a75017b8e038ff2a35279c620f2dd1ad6ad0a1e0/modules/pifile.sh#L36-L43 Thus, only the stage's commands have an implementation during the stage.

As one wants to extend another Pifile with all its stages, your INCLUDE command should be available for all of those. The most easy way would be to implement its function only within the 00-commands.sh file, as it is sourced first for every stage.

Would you please also add a brief description of the command to the README.md?

Thanks again!

aniongithub commented 3 years ago

Incorporated the suggested changes. Thanks!

aniongithub commented 2 years ago

Done, updated according to suggestions!

oxzi commented 2 years ago

The one CI error appears due to the unavailability of INCLUDE on the current master branch.