diff options
author | Luotao Fu <l.fu@pengutronix.de> | 2010-02-25 08:46:23 +0100 |
---|---|---|
committer | Luotao Fu <l.fu@pengutronix.de> | 2010-02-25 08:52:10 +0100 |
commit | 62802b345c177ee80e1fbea2724914df78c01736 (patch) | |
tree | b959e034f1dc99f2912a9cb00140fc9e29746da1 /tests | |
parent | 4d528d5624bc0984a5cd6e29db743bb7424a9967 (diff) | |
download | ptxdist-62802b345c177ee80e1fbea2724914df78c01736.tar.gz ptxdist-62802b345c177ee80e1fbea2724914df78c01736.tar.xz |
[ptxdist] relocate setenv config file parsing code
remove the config parsing part from make_barebox_env and put into the main
setenv script to make the code more clear. Also updated some comments to make
clear how the stuff works.
Signed-off-by: Luotao Fu <l.fu@pengutronix.de>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/make_barebox_env | 19 | ||||
-rwxr-xr-x | tests/setenv | 30 |
2 files changed, 24 insertions, 25 deletions
diff --git a/tests/make_barebox_env b/tests/make_barebox_env index 7af778891..f49445519 100755 --- a/tests/make_barebox_env +++ b/tests/make_barebox_env @@ -4,25 +4,6 @@ set -e PTXDIST_SETENV_BAREBOX_ENV="${1}" ENVTMPDIR="$(mktemp -d "${PTXDIST_TEMPDIR}/barebox_env.XXXXXX")" -#source and export variables, so we can access them later with awk. -set -a -. "${PTXDIST_BOARDSETUP}" -set +a - -CONFFILE="${PTXDIST_PLATFORMCONFIGDIR}/barebox-env/config${PTXDIST_PLATFORMSUFFIX}" -if [ ! -r "${CONFFILE}.in" ]; then - if [ -r "`dirname "${CONFFILE}"`/config.in" ]; then - CONFFILE="`dirname "${CONFFILE}"`/config" - else - echo "Config file for barebox environment is missing!" >&2 - exit 1 - fi -fi - -#Replace @magics@ with PTXCONF-variables -#FIXME: Warn if variable is empty? -awk 'match($0, "@[A-Z0-9_]+@") { var=substr($0,RSTART+1,RLENGTH-2); gsub("@"var"@", ENVIRON[var]); } {print} ' "${CONFFILE}".in >"${CONFFILE}" - tar -C "${PTXDIST_PLATFORMCONFIGDIR}/barebox-env/" -c . \ --exclude .svn \ --exclude .pc \ diff --git a/tests/setenv b/tests/setenv index 450860390..6602d30bc 100755 --- a/tests/setenv +++ b/tests/setenv @@ -9,6 +9,9 @@ set -a . "${PTXDIST_BOARDSETUP}" set +a +# We can put both u-boot-env and barebox-env in the platformconfig directory. +# Both of them will be scanned and parsed. Kermit script will recognize which +# bootloader is running on the target and pick up the right configuration. UBOOT_ENVDIR="${PTXDIST_PLATFORMCONFIGDIR}/u-boot-env" BAREBOX_ENVDIR="${PTXDIST_PLATFORMCONFIGDIR}/barebox-env" @@ -22,16 +25,31 @@ if [ -d ${UBOOT_ENVDIR} -a -r ${UBOOT_ENVDIR} ]; then exit 1 fi fi + #Replace @magics@ with PTXCONF-variables + #FIXME: Warn if variable is empty? awk 'match($0, "@[A-Z0-9_]+@") { var=substr($0,RSTART+1,RLENGTH-2); gsub("@"var"@", ENVIRON[var]); } {print} ' "${CONFFILE}".in >"${CONFFILE}" + UBOOT_CONFFILE="${CONFFILE}" fi -if [ -d "${BAREBOX_ENVDIR}" -a -r "${BAREBOX_ENVDIR}" -a -z "${CONFFILE}" ]; then +if [ -d "${BAREBOX_ENVDIR}" -a -r "${BAREBOX_ENVDIR}" ]; then + CONFFILE="${BAREBOX_ENVDIR}/config${PTXDIST_PLATFORMSUFFIX}" + if [ ! -r "${CONFFILE}.in" ]; then + if [ -r "`dirname "${CONFFILE}"`/config.in" ]; then + CONFFILE="`dirname "${CONFFILE}"`/config" + else + echo "Directory for Barebox environment found, but config file is missing!" >&2 + exit 1 + fi + fi + #Replace @magics@ with PTXCONF-variables + #FIXME: Warn if variable is empty? + awk 'match($0, "@[A-Z0-9_]+@") { var=substr($0,RSTART+1,RLENGTH-2); gsub("@"var"@", ENVIRON[var]); } {print} ' "${CONFFILE}".in >"${CONFFILE}" # Neith u-boot-v2 nor barebox acutally need CONFFILE while calling # kermit setenv function. However U-Boot V1 need this. So we have to - # pass this information to the kwrapper. - # barebox parses its conffile in make_barebox_env separately. give a - # dummy here to make sure that setenv can parse the parameters correctly - CONFFILE="NULL"; + # pass this information to the kwrapper. In case that we only have + # barebox env directory we set UBOOT_CONFFILE to a dummy value to + # make sure that setenv can parse the parameters correctly + [ -z "${UBOOT_CONFFILE}" ] && UBOOT_CONFFILE="NULL" fi if [ -z "${CONFFILE}" ]; then @@ -42,6 +60,6 @@ fi PTXDIST_SETENV_ENV_IMAGE="$(mktemp "${PTXCONF_BOARDSETUP_TFTP_PATH}/environment_image.XXXXXX")" chmod 644 "${PTXDIST_SETENV_ENV_IMAGE}" -"${PTXDIST_TOPDIR}/tests/kwrapper" setenv "${CONFFILE}" "${PTXDIST_SETENV_ENV_IMAGE}" +"${PTXDIST_TOPDIR}/tests/kwrapper" setenv "${UBOOT_CONFFILE}" "${PTXDIST_SETENV_ENV_IMAGE}" rm -rf "${PTXDIST_SETENV_ENV_IMAGE}" |