From a0c79fa51d832132535681b83f0dc9c5344c2482 Mon Sep 17 00:00:00 2001 From: Valentin Raevsky Date: Thu, 25 Jul 2019 14:23:26 +0300 Subject: [PATCH] meta-bsp-imx8mq: tools: Added user configuration script Added user configuration script. Signed-off-by: Valentin Raevsky --- tools/setup-imx8mq-env | 14 ++------ tools/setup-user-env | 74 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 12 deletions(-) create mode 100755 tools/setup-user-env diff --git a/tools/setup-imx8mq-env b/tools/setup-imx8mq-env index 644862e..e92a5ca 100755 --- a/tools/setup-imx8mq-env +++ b/tools/setup-imx8mq-env @@ -4,19 +4,9 @@ EULA=1 . fsl-setup-release.sh $@ -declare -a ENVIRONMENT=('../sources/meta-bsp-imx8mq/tools/setup-compulab-env') +declare -a ENVIRONMENT=('../sources/meta-bsp-imx8mq/tools/setup-compulab-env \ + ../sources/meta-bsp-imx8mq/tools/setup-user-env') for env in ${ENVIRONMENT[@]};do [ -f ${env} ] && FORCE=Yes source ${env} done - -eval DISTRO=$(awk '(/DISTRO.*=/)&&($0=$NF)' conf/local.conf) -[[ ${DISTRO} == 'fsl-imx-fb' ]] && return - -cat << eom ---------------------- Chromium --------------------- -eom -echo -n "Would you like to add Chromium to the buid? (y/n) " -read value - -[[ ${value} == 'y' ]] && awk '/IMAGE_INSTALL_append = \\/' RS="" ../README-IMXBSP >> conf/local.conf diff --git a/tools/setup-user-env b/tools/setup-user-env new file mode 100755 index 0000000..64bbf5e --- /dev/null +++ b/tools/setup-user-env @@ -0,0 +1,74 @@ +#!/bin/bash -xv + +user_local_conf=$(mktemp --dry-run --tmpdir=/tmp userXXX) +local_conf="conf/local.conf" + +mem=( d1 d2 cfg ) +cfg_mem() { +cat << EOP >> ${user_local_conf} +UBOOT_CONFIG = "$1" +EOP +} + +chrome=( yes no ) +cfg_chrome() { +if [[ $1 == "yes" ]];then +cat << EOP >> ${user_local_conf} +# Add Chromium +IMAGE_INSTALL_append = \\ + "\${@bb.utils.contains('DISTRO_FEATURES', 'wayland', ' chromium-ozone-wayland', \\ + bb.utils.contains('DISTRO_FEATURES', 'x11', ' chromium-x11', \\ + '', d), d)}" +EOP +fi +} + +rootfs=( ro rw ) +cfg_rootfs() { +if [[ $1 == "ro" ]];then +cat << EOP >> ${user_local_conf} +IMAGE_FEATURES += "read-only-rootfs" +EOP +fi +} + +declare -A ARRAYNAME=( [mem]="cfg" [chrome]="yes" [rootfs]="rw" ) + +cat << EOG +--- Users' Configurations started --- +EOG + +for ARRAY in ${!ARRAYNAME[@]}; do +select_string='default ' +eval array=\${${ARRAY}[@]} +for value in ${array[@]}; do +select_string+=${value}" " +done +PS3="${ARRAY} configuration [ ${ARRAYNAME[${ARRAY}]} ] (Ctrl^C -- exit) : " +select i in $select_string; do +[[ -z ${i} ]] && echo "Invalid option -(" || case $i in + default) + break + ;; + *) + ARRAYNAME[${ARRAY}]=${i} + break + ;; +esac +done # select +done # for + +for ARRAY in ${!ARRAYNAME[@]}; do +command -v cfg_${ARRAY} &>/dev/null +[[ $? -eq 0 ]] && cfg_${ARRAY} ${ARRAYNAME[${ARRAY}]} +done + +if [[ -f ${local_conf} ]];then +cat << EOH >> ${local_conf} + +# Users' Configurations +EOH +cat ${user_local_conf} >> ${local_conf} +fi + +rm -rf ${user_local_conf}