summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2019-02-18 09:04:57 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2019-02-19 07:33:03 +0100
commitf4f03806e9d2f027627db89ceae9fa545925504f (patch)
treecb0989e41bdde76ad3f41181902c1711941cc523
parent03aeed8262a53476bc4a60c47cb2a67e4ee2ed94 (diff)
downloadptxdist-f4f03806e9d2f027627db89ceae9fa545925504f.tar.gz
ptxdist-f4f03806e9d2f027627db89ceae9fa545925504f.tar.xz
introduce 'world/execute' and 'execute' macros
With these, arbitrary commands can be executed in the build stages. They habe the advantage that the environment is identical to the default build stages. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--doc/ref_manual.rst30
-rw-r--r--rules/post/ptxd_make_world_execute.make28
-rw-r--r--scripts/lib/ptxd_make_world_execute.sh73
3 files changed, 127 insertions, 4 deletions
diff --git a/doc/ref_manual.rst b/doc/ref_manual.rst
index 7365b01a5..96274ac97 100644
--- a/doc/ref_manual.rst
+++ b/doc/ref_manual.rst
@@ -552,12 +552,34 @@ Usage:
.. code-block:: make
- $(call compile, <PKG>, <build args>)
+ $(call compile, <PKG>, <build arguments>)
This macro is very similar to ``world/compile``. The only differences is
-that is uses the specified ``build args`` instead of ``<PKG>_MAKE_OPT``.
-This is usefull if ``make`` needs to be called more than once in the
-compile stage.
+that is uses the specified ``build arguments`` instead of
+``<PKG>_MAKE_OPT``. This is usefull if ``make`` needs to be called more
+than once in the compile stage.
+
+world/execute, execute
+~~~~~~~~~~~~~~~~~~~~~~
+
+Usage:
+
+.. code-block:: make
+
+ $(call execute, <PKG>, <command with arguments>)
+ $(call world/execute, <PKG>, <command with arguments>)
+
+These macros make it possible to execute arbitrary commands during the
+build stages. This is usefull because the environment is identical to the
+default build commands ``world/*``.
+
+``world/execute`` also handles the generic setup handled in the current
+build stage. For ``prepare`` this means that, for out ot tree builds, the
+build directory is deleted prior to executing the specified command.
+For ``install`` the package directory is deleted.
+
+When ``--verbose`` is used then the full command is logged. With
+``--quiet`` both stdout and stderr are redirected to the logfile.
install_copy
~~~~~~~~~~~~~
diff --git a/rules/post/ptxd_make_world_execute.make b/rules/post/ptxd_make_world_execute.make
new file mode 100644
index 000000000..a60bfdef5
--- /dev/null
+++ b/rules/post/ptxd_make_world_execute.make
@@ -0,0 +1,28 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2019 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# world/execute
+#
+world/execute = \
+ $(call world/env, $(1)) \
+ pkg_execute_cmd="$(call ptx/escape,$(2))" \
+ ptxd_make_world_execute
+
+#
+# execute
+#
+execute = \
+ $(call world/env, $(1)) \
+ pkg_execute_cmd="$(call ptx/escape,$(2))" \
+ ptxd_make_execute
+
+
+# vim: syntax=make
diff --git a/scripts/lib/ptxd_make_world_execute.sh b/scripts/lib/ptxd_make_world_execute.sh
new file mode 100644
index 000000000..5ff1f726f
--- /dev/null
+++ b/scripts/lib/ptxd_make_world_execute.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+ptxd_make_execute_impl() {
+ local -a cmd
+ if [ "${pkg_stage}" != "install" -o \
+ ! -e "${ptx_state_dir}/host-fakeroot.install.post" ]; then
+ local echo="eval"
+ local fakeroot="cat"
+ fi
+
+ if [ -z "${pkg_execute_cmd}" ]; then
+ ptxd_bailout "execute: missing command"
+ fi
+
+ cmd=( \
+ cd "${pkg_build_dir}" '&&' \
+ "${pkg_path}" \
+ "${pkg_env}" \
+ )
+ case "${pkg_stage}" in
+ prepare)
+ cmd[${#cmd[@]}]="${pkg_conf_env}"
+ ;;
+ compile)
+ cmd[${#cmd[@]}]="${pkg_make_env}"
+ ;;
+ install)
+ cmd[${#cmd[@]}]="${pkg_make_env}"
+ cmd[${#cmd[@]}]="${pkg_install_env}"
+ ;;
+ esac
+ cmd[${#cmd[@]}]="${pkg_execute_cmd}"
+
+
+ ptxd_verbose "executing:" "${cmd[@]}
+" &&
+ "${echo:-echo}" \
+ "${cmd[@]}" \
+ | "${fakeroot:-fakeroot}" "${fakeargs[@]}" --
+ check_pipe_status
+}
+export -f ptxd_make_execute_impl
+
+ptxd_make_execute() {
+ ptxd_make_world_init &&
+ ptxd_make_execute_impl
+}
+export -f ptxd_make_execute
+
+
+ptxd_make_world_execute() {
+ ptxd_make_world_init &&
+
+ case "${pkg_stage}" in
+ prepare)
+ ptxd_make_world_prepare_init
+ ;;
+ install)
+ ptxd_make_world_install_prepare
+ ;;
+ esac &&
+
+ ptxd_make_execute_impl
+}
+export -f ptxd_make_world_execute