1 |
Introduce a new out-of-source-utils.eclass to carry run_in_build_dir() |
2 |
helper function. This function used to be defined in multibuild.eclass |
3 |
and indirectly exposed through the eclasses using it. However, it is |
4 |
used rather rarely and it is technically also useful for |
5 |
out-of-source.eclass, so it makes more sense for it to be standalone. |
6 |
In the end, eclasses are cheap. |
7 |
|
8 |
Signed-off-by: Michał Górny <mgorny@g.o> |
9 |
--- |
10 |
eclass/out-of-source-utils.eclass | 43 +++++++++++++++++++++++++++++++ |
11 |
1 file changed, 43 insertions(+) |
12 |
create mode 100644 eclass/out-of-source-utils.eclass |
13 |
|
14 |
diff --git a/eclass/out-of-source-utils.eclass b/eclass/out-of-source-utils.eclass |
15 |
new file mode 100644 |
16 |
index 000000000000..450237b224b3 |
17 |
--- /dev/null |
18 |
+++ b/eclass/out-of-source-utils.eclass |
19 |
@@ -0,0 +1,43 @@ |
20 |
+# Copyright 2022 Gentoo Authors |
21 |
+# Distributed under the terms of the GNU General Public License v2 |
22 |
+ |
23 |
+# @ECLASS: out-of-source-utils.eclass |
24 |
+# @MAINTAINER: |
25 |
+# Michał Górny <mgorny@g.o> |
26 |
+# @AUTHOR: |
27 |
+# Michał Górny <mgorny@g.o> |
28 |
+# @SUPPORTED_EAPIS: 6 7 8 |
29 |
+# @BLURB: Utility functions for building packages out-of-source |
30 |
+# @DESCRIPTION: |
31 |
+# This eclass provides a run_in_build_dir() helper that can be used |
32 |
+# to execute specified command inside BUILD_DIR. |
33 |
+ |
34 |
+case ${EAPI} in |
35 |
+ 6|7|8) ;; |
36 |
+ *) die "${ECLASS}: EAPI ${EAPI} unsupported." |
37 |
+esac |
38 |
+ |
39 |
+if [[ ! ${_OUT_OF_SOURCE_UTILS_ECLASS} ]]; then |
40 |
+_OUT_OF_SOURCE_UTILS_ECLASS=1 |
41 |
+ |
42 |
+# @FUNCTION: run_in_build_dir |
43 |
+# @USAGE: <argv>... |
44 |
+# @DESCRIPTION: |
45 |
+# Run the given command in the directory pointed by BUILD_DIR. |
46 |
+run_in_build_dir() { |
47 |
+ debug-print-function ${FUNCNAME} "${@}" |
48 |
+ local ret |
49 |
+ |
50 |
+ [[ ${#} -eq 0 ]] && die "${FUNCNAME}: no command specified." |
51 |
+ [[ -z ${BUILD_DIR} ]] && die "${FUNCNAME}: BUILD_DIR not set." |
52 |
+ |
53 |
+ mkdir -p "${BUILD_DIR}" || die |
54 |
+ pushd "${BUILD_DIR}" >/dev/null || die |
55 |
+ "${@}" |
56 |
+ ret=${?} |
57 |
+ popd >/dev/null || die |
58 |
+ |
59 |
+ return ${ret} |
60 |
+} |
61 |
+ |
62 |
+fi |
63 |
-- |
64 |
2.39.0 |