minimal icon indicating copy to clipboard operation
minimal copied to clipboard

Overlay bundles - extract common logic in shell functions

Open ivandavidov opened this issue 8 years ago • 2 comments

Right now the overlay build system has more code than the main build system. Considering that most of the overlay bundles are disabled by default, it is quite safe to try to extract at least some of the common logic in shell functions. One example is the source code download in most of the 01 scripts, as well as the handling of the configuration variables.

Note that the implementation of #120 prior to this functionality will be significant advantage when handling the configuration variable parsing in the common logic.

In addition, I now recognize the explicit referring to common.sh in all scripts as bad design (noted by @bauen1). This approach works perfectly fine and it helps the new MLL users to figure out where all the 'magic' variables come from but in reality this doesn't make much sense and it could lead to some unexpected behavior if someone tries to source the same script from different folder. The only reference point where common.sh should be sourced is the main bundle.sh file.

ivandavidov avatar Dec 02 '17 13:12 ivandavidov

Regarding common.sh - it seems that function declarations cannot be easily exported in POSIX compliant way. Possible solutions are to migrate to bash and use export -f or simply source the script where it is needed. For now the latter approach is easier.

ivandavidov avatar Dec 02 '17 17:12 ivandavidov

The kernel download process has been refactored and now it uses function logic from 'common.sh'. The 'coreutils' bundle has also been refactored to use function logic from 'common.sh'.

ivandavidov avatar Dec 06 '17 01:12 ivandavidov