-
-
Save robbat2/cb797f3aafb788e44907b60b413ea469 to your computer and use it in GitHub Desktop.
genkernel use-modules load.sh proof of concept from consus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| load() { | |
| # TODO: validate the path to avoid escapes | |
| . ./$2 | |
| # FIX: This loop could be replaced w/ set+awk | |
| for modules_group in ${!MODULES_*}; do | |
| echo ${1}_${modules_group}=\"${!modules_group}\" | |
| done | |
| } | |
| # TODO: merge this with the loop that starts right afterwards, inputs structured. | |
| eval "$(load DEFAULT modules_load.default)" | |
| eval "$(load ARCH modules_load.arch)" | |
| eval "$(load CONFIG modules_load.config)" | |
| for pfx in DEFAULT ARCH CONFIG; do | |
| for modules_group in $(eval echo \${!${pfx}_MODULES_*}); do | |
| eval ${modules_group#${pfx}}+=\(\${${modules_group}[@]}\) | |
| done | |
| done | |
| for modules_group in ${!_MODULES_*}; do | |
| declare -A result | |
| for module in $(eval echo \${$modules_group[@]}); do | |
| if [[ ${module} == -* ]]; then | |
| unset result[${module#-}] | |
| else | |
| result[${module}]=1 | |
| fi | |
| done | |
| if [[ ${#result[@]} -gt 0 ]]; then | |
| eval ${modules_group#_}=$(echo \${!result[@]}) | |
| fi | |
| unset ${modules_group} | |
| done | |
| for modules_group in ${!MODULES_*}; do | |
| echo ${modules_group} contains ${!modules_group} | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| load() { | |
| . ./$2 | |
| for modules_group in ${!MODULES_*}; do | |
| echo ${1}_${modules_group}=\"${!modules_group}\" | |
| done | |
| } | |
| eval "$(load DEFAULT modules_load.default)" | |
| eval "$(load ARCH modules_load.arch)" | |
| eval "$(load CONFIG modules_load.config)" | |
| for pfx in DEFAULT ARCH CONFIG; do | |
| for modules_group in $(eval echo \${!${pfx}_MODULES_*}); do | |
| eval ${modules_group#${pfx}}+=\(\${${modules_group}[@]}\) | |
| done | |
| done | |
| for modules_group in ${!_MODULES_*}; do | |
| declare -A result | |
| for module in $(eval echo \${$modules_group[@]}); do | |
| if [[ ${module} == -* ]]; then | |
| unset result[${module#-}] | |
| else | |
| result[${module}]=1 | |
| fi | |
| done | |
| if [[ ${#result[@]} -gt 0 ]]; then | |
| eval ${modules_group#_}=$(echo \${!result[@]}) | |
| fi | |
| unset ${modules_group} | |
| done | |
| for modules_group in ${!MODULES_*}; do | |
| echo ${modules_group} contains ${!modules_group} | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MODULES_FOO='-b a' | |
| MODULES_BAR='-*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MODULES_FOO='c' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MODULES_FOO='z -z b' | |
| MODULES_BAR='x' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment