diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2012-06-30 12:08:39 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2012-06-30 12:43:33 +0200 |
commit | 6b212b9ff3d5798ef2336434dc7c85857d5084b7 (patch) | |
tree | e1a060bf5673d22173b116efc313c6b01692683a /scripts | |
parent | d668fd06b43f039a336681480dbcce39bf1f2250 (diff) | |
download | ptxdist-6b212b9ff3d5798ef2336434dc7c85857d5084b7.tar.gz ptxdist-6b212b9ff3d5798ef2336434dc7c85857d5084b7.tar.xz |
ptxd_make_image_genimage: handle includes and dependencies
config files can include other config files. With this change, these
includes are found and preprocessed with the same mechanism as the primary
config file.
By generating the dependencies here, all includes are considered as well.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/ptxd_make_image_genimage.sh | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/scripts/lib/ptxd_make_image_genimage.sh b/scripts/lib/ptxd_make_image_genimage.sh index f2635fefd..e1587503a 100644 --- a/scripts/lib/ptxd_make_image_genimage.sh +++ b/scripts/lib/ptxd_make_image_genimage.sh @@ -9,20 +9,50 @@ # # +# find and prepare the config file and any includes +# +# returns: +# 0 if a config file and all includes are ready +# 1 otherwise +# +# array "genimage_configs" contains all config files starting with the +# requested file +# +ptxd_make_image_genimage_config() { + local cfg tmp inc + local -a includes + ptxd_get_alternative config/images "${1}" || ptxd_bailout "could not find config file ${1}" + cfg="${ptxd_reply}" + tmp="${PTXDIST_TEMPDIR}/$(basename "${1}")" + + eval \ + "${image_env}" \ + IMAGE="$(basename "${image_image}")" \ + ptxd_replace_magic "${cfg}" > "${tmp}" && + + genimage_configs[${#genimage_configs[@]}]="${tmp}" && + echo "${image_image}: \$(call genimage/config, ${1})" >> "${pkg_genimage_deps}" + + includes=( $(sed -n "s/.*\<include(['\"]\(.*\)['\"]).*/\1/p" "${tmp}") ) && + sed -i "s:\(.*\<include(['\"]\)\(.*\)\(['\"]).*\):\1${PTXDIST_TEMPDIR}/\2\3:" "${tmp}" && + for inc in "${includes[@]}"; do + ptxd_make_image_genimage_config "${inc}" + done +} +export -f ptxd_make_image_genimage_config + +# # extract ipkg an generate a tgz image # ptxd_make_image_genimage_impl() { local tmpdir config file - config="$(mktemp "${PTXDIST_TEMPDIR}/genimage.config.XXXXXX")" + local -a genimage_configs tmpdir="$(mktemp -d "${PTXDIST_TEMPDIR}/genimage.XXXXXX")" ptxd_make_image_init && - [ -r "${1}" ] || ptxd_bailout "could not find config file $1" - - eval \ - "${image_env}" \ - IMAGE="$(basename "${image_image}")" \ - ptxd_replace_magic "${1}" > "${config}" && + pkg_genimage_deps="${ptx_state_dir}/${pkg_pkg}.deps" && + rm -f "${pkg_genimage_deps}" && + ptxd_make_image_genimage_config "${1}" && rm -rf "${pkg_dir}" && mkdir -p "${pkg_dir}" && @@ -36,7 +66,8 @@ ptxd_make_image_genimage_impl() { --rootpath "${pkg_dir}" \ --tmppath "${tmpdir}" \ --outputpath "$(dirname "${image_image}")" \ - --config "${config}" && + --inputpath "${ptx_image_dir}" \ + --config "${genimage_configs}" && rm -r "${pkg_dir}" } |