diff options
author | Dave Reisner <dreisner@archlinux.org> | 2017-03-18 19:14:36 +0100 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2017-03-19 20:14:47 +0100 |
commit | c5ad00c2e565eaae8e8b02b92d7f193852008c80 (patch) | |
tree | 18493daa87e45e9f75a35699015917b8440a536c /functions | |
parent | 91b212551a5066bda4eb76c83bdd9c0d0ac8e6cc (diff) | |
download | mkinitcpio-c5ad00c2e565eaae8e8b02b92d7f193852008c80.tar.gz mkinitcpio-c5ad00c2e565eaae8e8b02b92d7f193852008c80.tar.xz |
arrayize config vars in mkinitcpio.conf
allows for backwards compat by detecting and converting old-style
string-based configs.
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -198,6 +198,16 @@ map() { return $r } +arrayize_config() { + set -f + [[ ${MODULES@a} != *a* ]] && MODULES=($MODULES) + [[ ${BINARIES@a} != *a* ]] && BINARIES=($BINARIES) + [[ ${FILES@a} != *a* ]] && FILES=($FILES) + [[ ${HOOKS@a} != *a* ]] && HOOKS=($HOOKS) + [[ ${COMPRESSION_OPTIONS@a} != *a* ]] && COMPRESSION_OPTIONS=($COMPRESSION_OPTIONS) + set +f +} + in_array() { # Search for an element in an array. # $1: needle @@ -608,18 +618,15 @@ add_binary() { parse_config() { # parse key global variables set by the config file. - set -f - map add_module $MODULES - map add_binary $BINARIES - map add_file $FILES - set +f + map add_module "${MODULES[@]}" + map add_binary "${BINARIES[@]}" + map add_file "${FILES[@]}" tee "$BUILDROOT/buildconfig" < "$1" | { . /dev/stdin - # sanitize of any extra whitespace - read -ra modules <<<"${MODULES//-/_}" for mod in "${modules[@]%\?}"; do + mod=${mod//-/_} # only add real modules (2 == builtin) (( _addedmodules["$mod"] == 1 )) && add+=("$mod") done @@ -688,7 +695,7 @@ initialize_buildroot() { run_build_hook() { local hook=$1 script= realscript= - local MODULES= BINARIES= FILES= SCRIPT= + local MODULES=() BINARIES=() FILES=() SCRIPT= # find script in install dirs if ! script=$(PATH=$_d_install type -P "$hook"); then |