blob: f20c5c38055166dd10dfdd92661b35441e33a607 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#
# set +o errexit -o noglob -o nounset is assumed.
#
exp_pkg_exec_filter_vars_fn() {
local _vname="${1}";
case "${_vname}" in
DEFAULT|PKG_*)
return 0; ;;
BUILD_DLCACHEDIR|BUILD_WORKDIR|MIDIPIX_BUILD_PWD)
return 0; ;;
CONFIG_CACHE_GNULIB)
return 0; ;;
PREFIX|PREFIX_CROSS|PREFIX_MINGW32|PREFIX_MINIPIX|PREFIX_NATIVE|PREFIX_RPM)
return 0; ;;
*) return 1; ;;
esac;
};
#
# exp_pkg_exec_pre() - XXX
# @_group_name: build group name
# @_pkg_name: single package name
# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL or LAST
#
# Return: zero (0) on success, non-zero (>0) on failure
#
exp_pkg_exec_pre() {
local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}";
if [ -z "${PKG_URL:-}" ]\
&& [ -z "${PKG_URLS_GIT:-}" ]\
&& [ -z "${PKG_VERSION:-}" ]\
&& ! rtl_test_cmd "pkg_${_pkg_name}_all"; then
"${_dispatch_fn}" missing_pkg "${_group_name}" "${_pkg_name}";
return 1;
elif ! ex_pkg_state_test "${_pkg_name}" "start" "${_restart_at}"; then
if [ "${PKG_NO_CLEAN_BASE_DIR:-0}" -eq 0 ]\
&& ! rtl_fileop rm "${PKG_BASE_DIR}" "${PKG_BUILD_DIR}" "${PKG_DESTDIR}" "${PKG_DESTDIR_HOST}"\
|| ! rtl_fileop mkdir "${PKG_BASE_DIR}"; then
return 1;
fi;
if ! rtl_fileop mkdir "${PKG_BUILD_DIR}" "${PKG_DESTDIR}"\
|| ! ex_pkg_state_set "${_pkg_name}" "start"; then
return 1;
fi;
fi;
rtl_fileop cd "${PKG_BUILD_DIR}";
};
#
# exp_pkg_exec_step() - XXX
# @_group_name: build group name
# @_pkg_name: single package name
# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL or LAST
# @_step: build step to execute
#
# Return: zero (0) on success, non-zero (>0) on failure
#
exp_pkg_exec_step() {
local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}" _step="${4}" \
_fn_name="" _pkg_step_fn="" _rc=0;
if rtl_test_cmd "pkg_${_pkg_name}_${_step}"; then
_pkg_step_fn="pkg_${_pkg_name}_${_step}";
else
_pkg_step_fn="pkg_${_step}";
fi;
for _fn_name in \
"pkg_${_pkg_name}_${_step}_pre" \
"${_pkg_step_fn}" \
"pkg_${_pkg_name}_${_step}_post"; do
if rtl_test_cmd "${_fn_name}"\
&& ! "${_fn_name}" "${_group_name}" "${_pkg_name}" "${_restart_at}"; then
_rc=1; break;
fi;
done;
return "${_rc}";
};
#
# exp_pkg_exec() - XXX
# @_dispatch_fn: top-level dispatch function name
# @_group_name: build group name
# @_pkg_name: single package name
# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL or LAST
#
# Return: zero (0) on success, non-zero (>0) on failure
#
ex_pkg_exec() {
local _dispatch_fn="${1}" _group_name="${2}" _pkg_name="${3}" _restart_at="${4}" \
_build_step_last="" _rc=0 _step="";
if ! exp_pkg_exec_pre "${_group_name}" "${_pkg_name}" "${_restart_at}"\
|| ! "${_dispatch_fn}" start_pkg_child "${_group_name}" "${_pkg_name}"; then
_rc=1;
elif rtl_test_cmd "pkg_${_pkg_name}_all"; then
"pkg_${_pkg_name}_all" "${_restart_at}"; _rc="${?}";
else set -- ${PKG_BUILD_STEPS};
while [ ${#} -gt 0 ]; do
_step="${1}"; shift;
if [ "${#_restart_at}" -gt 0 ]\
&& [ "${_restart_at}" != "ALL" ]\
&& [ "${_restart_at}" != "LAST" ]\
&& ! rtl_lmatch "${_restart_at}" "${_step}" ","; then
continue;
fi;
if [ "${_step}" = "${ARG_DUMP_IN}" ]; then
printf "" > "${BUILD_WORKDIR}/${_pkg_name}.dump";
rtl_filter_vars exp_pkg_exec_filter_vars_fn >> "${BUILD_WORKDIR}/${_pkg_name}.dump";
export >> "${BUILD_WORKDIR}/${_pkg_name}.dump"; exit 1;
elif [ "${_step}" = "finish" ]; then
ex_pkg_state_set "${_pkg_name}" finish; break;
elif [ "${PKG_FORCE:-0}" -eq 0 ]\
&& ex_pkg_state_test "${_pkg_name}" "${_step}" "${_restart_at}"; then
continue;
elif ! exp_pkg_exec_step "${_group_name}" "${_pkg_name}" "${_restart_at}" "${_step}"; then
_rc=1; break;
else printf "step %s %s %s\n" "${_group_name}" "${_pkg_name}" "${_step}" >&3;
ex_pkg_state_set "${_pkg_name}" "${_step}" "${@}";
fi;
done;
fi;
if [ "${_rc:-0}" -ne 0 ]\
&& [ "${ARG_DUMP_ON_ABORT:-0}" -eq 1 ]; then
printf "" > "${BUILD_WORKDIR}/${_pkg_name}.dump";
rtl_filter_vars exp_pkg_exec_filter_vars_fn >> "${BUILD_WORKDIR}/${_pkg_name}.dump";
export >> "${BUILD_WORKDIR}/${_pkg_name}.dump";
fi;
return "${_rc}";
};
# vim:filetype=sh
|