Skip to content

Commit

Permalink
meta-bsp-imx8mq: tools: Added user configuration script
Browse files Browse the repository at this point in the history
Added user configuration script.

Signed-off-by: Valentin Raevsky <valentin@compulab.co.il>
  • Loading branch information
vraevsky committed Jul 25, 2019
1 parent bbfdb55 commit a0c79fa
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 12 deletions.
14 changes: 2 additions & 12 deletions tools/setup-imx8mq-env
Original file line number Diff line number Diff line change
Expand Up @@ -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
74 changes: 74 additions & 0 deletions tools/setup-user-env
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit a0c79fa

Please sign in to comment.