summaryrefslogtreecommitdiffstats
path: root/scripts
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 /scripts
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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/ptxd_make_world_execute.sh73
1 files changed, 73 insertions, 0 deletions
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