summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/ref_make_macros.rst27
-rw-r--r--rules/post/ptxd_make_world_clean.make7
-rw-r--r--rules/post/ptxd_make_world_targetinstall.make12
-rw-r--r--scripts/lib/ptxd_make_install_image.sh48
-rw-r--r--scripts/lib/ptxd_make_world_clean.sh22
5 files changed, 116 insertions, 0 deletions
diff --git a/doc/ref_make_macros.rst b/doc/ref_make_macros.rst
index 730687daf..684390089 100644
--- a/doc/ref_make_macros.rst
+++ b/doc/ref_make_macros.rst
@@ -150,6 +150,33 @@ When ``--verbose`` is used then the full command is logged. With
.. _install_copy:
+ptx/image-install, ptx/image-install-link, world/image-clean
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Usage:
+
+.. code-block:: make
+
+ @$(call world/image-clean, <PKG>)
+ @$(call ptx/image-install, <PKG>, $(<PKG>_BUILD_DIR)/<source-image-name>[, <image-name>])
+ @$(call ptx/image-install-link, <PKG>, <link-target>, <link-name>)
+
+These macros are used to install files to ``|ptxdistPlatformDir|/images``.
+They are only allowed in the *targetinstall* stage. They are used by
+packages that produce files that are not part of a filesystem. Bootloaders
+are typical packages that do this.
+
+``world/image-clean`` will remove the files that were created by the other
+two macros in a previous run of the *targetinstall* stage. This also
+happens implicitly when the package is cleaned.
+
+``ptx/image-install`` copies a file. The source must be an absolute path.
+The destination must be relative to the image directory. If the destination
+file name is the source file without the path, then this argument can be
+omitted.
+
+``ptx/image-install-link`` creates a symlink in the image directory.
+
install_copy
~~~~~~~~~~~~~
diff --git a/rules/post/ptxd_make_world_clean.make b/rules/post/ptxd_make_world_clean.make
index 30236e964..b5e063feb 100644
--- a/rules/post/ptxd_make_world_clean.make
+++ b/rules/post/ptxd_make_world_clean.make
@@ -28,4 +28,11 @@ world/clean = \
clean_pkg = \
$(call world/clean, $(1))
+#
+# image-clean
+#
+world/image-clean = \
+ $(call world/image/env, $(1)) \
+ ptxd_make_world_image_clean
+
# vim: syntax=make
diff --git a/rules/post/ptxd_make_world_targetinstall.make b/rules/post/ptxd_make_world_targetinstall.make
index d199c2280..8c55671ce 100644
--- a/rules/post/ptxd_make_world_targetinstall.make
+++ b/rules/post/ptxd_make_world_targetinstall.make
@@ -14,4 +14,16 @@ $(STATEDIR)/%.targetinstall.post:
@$(call targetinfo)
@$(call touch)
+ptx/image-install = \
+ $(call world/env, $(1)) \
+ pkg_file="$(strip $(2))" \
+ pkg_image="$(strip $(3))" \
+ ptxd_make_image_install
+
+ptx/image-install-link = \
+ $(call world/env, $(1)) \
+ pkg_file="$(strip $(2))" \
+ pkg_image="$(strip $(3))" \
+ ptxd_make_image_install_link
+
# vim: syntax=make
diff --git a/scripts/lib/ptxd_make_install_image.sh b/scripts/lib/ptxd_make_install_image.sh
new file mode 100644
index 000000000..c447d8c47
--- /dev/null
+++ b/scripts/lib/ptxd_make_install_image.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+
+ptxd_make_image_install_record() {
+ (
+ if [ -e "${pkg_image_stamp}" ]; then
+ grep -v "^${pkg_image}$" "${pkg_image_stamp}"
+ fi
+ echo "${pkg_image}"
+ ) > "${pkg_image_stamp}.tmp" &&
+ mv "${pkg_image_stamp}.tmp" "${pkg_image_stamp}"
+}
+export -f ptxd_make_image_install_record
+
+ptxd_make_image_install() {
+ ptxd_make_world_init || return
+ local pkg_image_stamp="${ptx_state_dir}/${pkg_label}.images"
+
+ if [ -z "${pkg_image}" ]; then
+ pkg_image="$(basename "${pkg_file}")"
+ fi
+ pkg_image="${ptx_image_dir}/${pkg_image}"
+
+ echo "Installing '$(ptxd_print_path "${pkg_file}")' to '$(ptxd_print_path "${pkg_image}")'"
+
+ install -D -m644 "${pkg_file}" "${pkg_image}" &&
+ ptxd_make_image_install_record
+}
+export -f ptxd_make_image_install
+
+ptxd_make_image_install_link() {
+ ptxd_make_world_init || return
+ local pkg_image_stamp="${ptx_state_dir}/${pkg_label}.images"
+
+ pkg_image="${ptx_image_dir}/${pkg_image}"
+
+ echo "Linking '${pkg_file}' to '$(ptxd_print_path "${pkg_image}")'"
+
+ ln -sf "${pkg_file}" "${pkg_image}" &&
+ ptxd_make_image_install_record
+}
+export -f ptxd_make_image_install_link
diff --git a/scripts/lib/ptxd_make_world_clean.sh b/scripts/lib/ptxd_make_world_clean.sh
index 2fc8170e7..fa54be600 100644
--- a/scripts/lib/ptxd_make_world_clean.sh
+++ b/scripts/lib/ptxd_make_world_clean.sh
@@ -32,6 +32,27 @@ ptxd_make_world_clean_sysroot() {
}
export -f ptxd_make_world_clean_sysroot
+ptxd_make_world_image_clean_impl() {
+ local pkg_image_stamp="${ptx_state_dir}/${pkg_label}.images"
+
+ if [ -e "${pkg_image_stamp}" ]; then
+ echo "Deleting images:"
+ while read file; do
+ echo "${file}"
+ rm "${file}" || break
+ done < "${pkg_image_stamp}"
+ rm "${pkg_image_stamp}"
+ echo
+ fi
+}
+export -f ptxd_make_world_image_clean_impl
+
+ptxd_make_world_image_clean() {
+ ptxd_make_world_init &&
+ ptxd_make_world_image_clean_impl
+}
+export -f ptxd_make_world_image_clean
+
#
# clean
#
@@ -46,6 +67,7 @@ ptxd_make_world_clean() {
done
echo
fi
+ ptxd_make_world_image_clean_impl
if [ -n "$(ls "${ptx_state_dir}/${pkg_label}".* 2> /dev/null)" ]; then
echo "Deleting stage files:"
if [ -e "${pkg_xpkg_map}" ]; then