|
lalbornoz |
340f4c |
#!/bin/sh
|
|
|
185480 |
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de>
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
|
|
|
e9fa07 |
# {{{ buildp_ast($_param)
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
buildp_ast() {
|
|
|
e9fa07 |
local _bpa_param="${1}" \
|
|
|
e9fa07 |
_bpa_cmd="" _bpa_pids="" _bpa_pids_new="" \
|
|
|
3294d1 |
_bpa_pids_niter=0 _bpa_pkg_name="" _bpa_signal="";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
for _bpa_cmd in \
|
|
|
e9fa07 |
rtl_fileop rtl_kill_tree rtl_lconcat \
|
|
|
4243a1 |
rtl_log_msgV rtl_uniq rtl_state_clear;
|
|
|
e9fa07 |
do
|
|
|
e9fa07 |
if ! command -v "${_bpa_cmd}" >/dev/null 2>&1; then
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
done;
|
|
|
e9fa07 |
|
|
|
989546 |
trap '' HUP INT TERM USR1 USR2;
|
|
|
989546 |
|
|
|
e9fa07 |
if [ "${_bpa_param}" = "abort" ]; then
|
|
|
4243a1 |
rtl_log_msgV "fatalexit" "${MSG_build_aborted}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
|
e9fa07 |
|
|
|
3294d1 |
for _bpa_signal in "TERM" "KILL"; do
|
|
|
3294d1 |
_bpa_pids_niter=0;
|
|
|
3294d1 |
while [ "${_bpa_pids_niter}" -lt 8 ]; do
|
|
|
3294d1 |
rtl_lconcat \$_bpa_pids "${_bpa_pids_new}";
|
|
|
3294d1 |
_bpa_pids_new="";
|
|
|
3294d1 |
if ! rtl_kill_tree \$_bpa_pids_new "${$}" "${_bpa_signal}"\
|
|
|
3294d1 |
|| [ "${_bpa_pids_new:+1}" != 1 ]; then
|
|
|
3294d1 |
break;
|
|
|
3294d1 |
else
|
|
|
3294d1 |
: $((_bpa_pids_niter+=1));
|
|
|
3294d1 |
fi;
|
|
|
3294d1 |
done;
|
|
Lucio Andrés Illanes Albornoz |
647a12 |
done;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${_bpa_pids:+1}" = 1 ]; then
|
|
|
4243a1 |
rtl_log_msgV "verbose" "${MSG_build_killed_pids}" "$(rtl_uniq ${_bpa_pids})";
|
|
Lucio Andrés Illanes Albornoz |
a97175 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${BUILD_PKG_WAIT:+1}" = 1 ]\
|
|
Lucio Andrés Illanes Albornoz |
370e98 |
&& [ "${ARG_RESET_PKG}" -eq 1 ]; then
|
|
|
e9fa07 |
for _bpa_pkg_name in ${BUILD_PKG_WAIT}; do
|
|
|
e9fa07 |
rtl_state_clear "${BUILD_WORKDIR}" "${_bpa_pkg_name}";
|
|
Lucio Andrés Illanes Albornoz |
725770 |
done;
|
|
|
4243a1 |
rtl_log_msgV "verbose" "${MSG_build_reset_pkg_state}" "${BUILD_PKG_WAIT}";
|
|
Lucio Andrés Illanes Albornoz |
725770 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME:+1}" = 1 ]; then
|
|
Lucio Andrés Illanes Albornoz |
8cae5b |
rtl_fileop rm "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
|
|
Lucio Andrés Illanes Albornoz |
8cae5b |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
|
|
|
e9fa07 |
# {{{ buildp_init($_rstatus)
|
|
|
e9fa07 |
buildp_init() {
|
|
|
e9fa07 |
local _bi_rstatus="${1#\$}" \
|
|
|
e9fa07 |
_bi_args_long="--as-needed --debug-minipx --reset-state" \
|
|
|
e9fa07 |
_bi_name_base="build" \
|
|
|
e9fa07 |
_bi_optstring="a:b:C:D:F:hp:Pr:RxvV:" \
|
|
|
e9fa07 |
_bi_rc=0 _bi_status="";
|
|
|
e9fa07 |
shift;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if ! . "${0%/*}/subr.ex/ex_init.subr"; then
|
|
|
e9fa07 |
_bi_rc=1;
|
|
|
e9fa07 |
_bi_status='failed to source \`'"${0%/*}/subr/ex_init.subr"\';
|
|
|
e9fa07 |
eval ${_bi_rstatus}=\"${_bi_status}\";
|
|
|
e9fa07 |
elif ! ex_init_help \
|
|
|
e9fa07 |
"${_bi_rstatus}" "${_bi_args_long}" \
|
|
|
e9fa07 |
"${_bi_name_base}" "${_bi_optstring}" "${@}" \
|
|
|
e9fa07 |
|| ! ex_init_env "${_bi_rstatus}" \
|
|
|
e9fa07 |
\$BUILD_HNAME \$BUILD_USER "${_bi_name_base}" \
|
|
|
e9fa07 |
|| ! ex_init_getopts \
|
|
|
e9fa07 |
"${_bi_rstatus}" "buildp_init_getopts_fn" \
|
|
|
e9fa07 |
"${_bi_optstring}" "${@}" \
|
|
|
d982c0 |
|| ! ex_init_theme \
|
|
|
d982c0 |
"${_bi_rstatus}" "${BUILD_HNAME}" \
|
|
|
d982c0 |
"${_bi_name_base}" "${ARG_THEME:-}" \
|
|
|
e9fa07 |
|| ! ex_init_logging "${_bi_rstatus}" \$ARG_VERBOSE_TAGS "${ARG_VERBOSE}" \
|
|
|
1aa81c |
|| ! ex_pkg_load_vars "${_bi_rstatus}" \$ARCH \$BUILD_KIND \
|
|
|
1cbe20 |
|| ! buildp_init_args_ccache "${_bi_rstatus}" \
|
|
|
e9fa07 |
|| ! ex_init_prereqs "${_bi_rstatus}" "${DEFAULT_PREREQS}" \
|
|
|
e9fa07 |
|| ! buildp_init_args "${_bi_rstatus}" \
|
|
|
e9fa07 |
|| ! ex_init_files \
|
|
|
e9fa07 |
"${_bi_rstatus}" \
|
|
|
e9fa07 |
\$ARG_CLEAN_BUILDS \$ARG_DIST \
|
|
|
e9fa07 |
"${DEFAULT_BUILD_LOG_FNAME}" \
|
|
|
e9fa07 |
"${DEFAULT_BUILD_LOG_LAST_FNAME}" \
|
|
|
e9fa07 |
"${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" \
|
|
|
e9fa07 |
"${DEFAULT_CHECK_PATH_VARS}" \
|
|
|
e9fa07 |
"${DEFAULT_CLEAR_ENV_VARS_EXCEPT}" \
|
|
|
e9fa07 |
"${DEFAULT_CLEAR_PREFIX_PATHS}" \
|
|
|
ab21e5 |
"${DEFAULT_RPM_JOBS_SEMAPHORE}" \
|
|
|
e9fa07 |
"${BUILD_DLCACHEDIR}" "${PREFIX}" \
|
|
|
e9fa07 |
"${PREFIX_RPM}" "${BUILD_WORKDIR}";
|
|
|
e9fa07 |
then
|
|
|
e9fa07 |
_bi_rc=1;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
return "${_bi_rc}";
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
# {{{ buildp_init_args($_rstatus)
|
|
|
e9fa07 |
buildp_init_args() {
|
|
|
e9fa07 |
local _bpia_rstatus="${1#\$}" \
|
|
|
e9fa07 |
_bpia_foundfl=0 _bpia_group="" _bpia_groups="" _bpia_groups_noauto="" \
|
|
|
e9fa07 |
_bpia_pkg_names="" _bpia_pkg_names_unknown="" _bpia_pkg_names_unknown_count=0 \
|
|
|
e9fa07 |
_bpia_rc=0;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${ARG_FETCH_FORCE}" in
|
|
|
e9fa07 |
ipv4) rtl_lconcat \$DEFAULT_GIT_ARGS "-4";
|
|
|
e9fa07 |
rtl_lconcat \$DEFAULT_WGET_ARGS "-4"; ;;
|
|
|
e9fa07 |
ipv6) rtl_lconcat \$DEFAULT_GIT_ARGS "-6";
|
|
|
e9fa07 |
rtl_lconcat \$DEFAULT_WGET_ARGS "-6"; ;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${ARG_AS_NEEDED:-0}" -eq 1 ]\
|
|
|
e9fa07 |
&& [ -e "${PREFIX}/build.gitref" ]\
|
|
|
e9fa07 |
&& [ "$(git rev-parse HEAD)" = "$(cat "${PREFIX}/build.gitref")" ]; then
|
|
|
e9fa07 |
_bpia_rc=0;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpia_rstatus}" 'Git repository has not changed since last build and --as-needed was specified.';
|
|
|
e9fa07 |
elif ! ex_pkg_process_restart_spec "${_bpia_rstatus}" \$ARG_RESTART \$ARG_RESTART_AT \$ARG_RESTART_RECURSIVE; then
|
|
|
e9fa07 |
_bpia_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpia_rstatus}" 'failed to process -r specification: ${'"${_bpia_rstatus}"'}.';
|
|
|
6a630d |
elif ! ex_pkg_load_groups \$_bpia_groups \$_bpia_groups_noauto; then
|
|
|
e9fa07 |
_bpia_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpia_rstatus}" 'failed to load build groups.';
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
if ! rtl_lmatch \$ARG_DIST:- "rpm" ","; then
|
|
|
e9fa07 |
rtl_lfilter \$_bpia_groups "host_deps_rpm";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${BUILD_GROUPS:+1}" != 1 ]; then
|
|
|
e9fa07 |
BUILD_GROUPS="${_bpia_groups}";
|
|
|
e9fa07 |
else _bpia_foundfl=0; for _bpia_group in ${BUILD_GROUPS}; do
|
|
|
e9fa07 |
if rtl_lmatch \$_bpia_groups "${_bpia_group}"; then
|
|
|
e9fa07 |
_bpia_foundfl=1; break;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
done;
|
|
|
e9fa07 |
if [ "${_bpia_foundfl}" -eq 0 ]; then
|
|
|
e9fa07 |
_bpia_foundfl=0; for _bpia_group in ${BUILD_GROUPS}; do
|
|
|
e9fa07 |
if rtl_lmatch \$_bpia_groups "${_bpia_group}"; then
|
|
|
e9fa07 |
_bpia_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpia_rstatus}" 'unknown build group \`'"${_bpia_group}'"'.';
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
done;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${_bpia_rc:-0}" -eq 0 ]; then
|
|
|
e9fa07 |
if rtl_lmatch \$ARG_DIST "zipdist" ","\
|
|
|
e9fa07 |
&& ! rtl_lmatch \$ARG_DIST "minipix" ","; then
|
|
|
e9fa07 |
rtl_lconcat \$ARG_DIST "minipix" ",";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${ARG_DIST:+1}" = 1 ]; then
|
|
|
e9fa07 |
rtl_lfilter \$BUILD_GROUPS "dist";
|
|
|
e9fa07 |
rtl_lconcat \$BUILD_GROUPS "dist";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${ARG_RESTART:+1}" = 1 ]\
|
|
|
e9fa07 |
&& ! rtl_lmatch \$ARG_RESTART "ALL LAST"; then
|
|
|
e9fa07 |
for _bpia_pkg_name in ${ARG_RESTART}; do
|
|
|
e9fa07 |
if ! ex_pkg_find_package \$_bpia_pkg_names "${BUILD_GROUPS}" "${_bpia_pkg_name}" >/dev/null; then
|
|
|
e9fa07 |
rtl_lconcat \$_bpia_pkg_names_unknown "${_bpia_pkg_name}";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
done;
|
|
|
e9fa07 |
rtl_llength \$_bpia_pkg_names_unknown_count \$_bpia_pkg_names_unknown;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${_bpia_pkg_names_unknown_count}" in
|
|
|
e9fa07 |
0) ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
1) _bpia_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpia_rstatus}" 'unknown package \`'"${_bpia_pkg_names_unknown}'"'.';
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
*) rtl_subst \$_bpia_pkg_names_unknown " " ", ";
|
|
|
e9fa07 |
_bpia_rc=1
|
|
|
e9fa07 |
rtl_setrstatus "${_bpia_rstatus}" 'unknown packages: '"${_bpia_pkg_names_unknown}'"'.';
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return "${_bpia_rc}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
1b1772 |
# {{{ buildp_init_args_ccache($_rstatus)
|
|
|
1b1772 |
buildp_init_args_ccache() {
|
|
|
1b1772 |
local _bpiac_rstatus="${1#\$}" \
|
|
|
1b1772 |
_bpiac_target="";
|
|
|
1b1772 |
|
|
|
4ad93e |
if [ "${ARG_CCACHE:+1}" = 1 ]; then
|
|
|
1b1772 |
for _bpiac_target in CROSS HOST NATIVE SOFORT_NATIVE; do
|
|
|
4ad93e |
eval "DEFAULT_${_bpiac_target}_CC"=\"${ARG_CCACHE} \${DEFAULT_${_bpiac_target}_CC}\";
|
|
|
4ad93e |
eval "DEFAULT_${_bpiac_target}_CXX"=\"${ARG_CCACHE} \${DEFAULT_${_bpiac_target}_CXX}\";
|
|
|
1b1772 |
done;
|
|
|
1b1772 |
fi;
|
|
|
1b1772 |
|
|
|
1b1772 |
return 0;
|
|
|
1b1772 |
};
|
|
|
1b1772 |
# }}}
|
|
|
e9fa07 |
# {{{ buildp_init_getopts_fn(...)
|
|
|
e9fa07 |
buildp_init_getopts_fn() {
|
|
|
e9fa07 |
local _bpigf_rc=0 _bpigf_shiftfl=0;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${1}" in
|
|
|
e9fa07 |
init)
|
|
|
e9fa07 |
local _bpigf_verb="${1}" _bpigf_rstatus="${2#\$}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
: ${ARCH:="nt64"};
|
|
|
e9fa07 |
: ${BUILD_KIND:="debug"};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
ARG_AS_NEEDED=0; ARG_CLEAN_BUILDS=""; ARG_DEBUG_MINIPIX=0; ARG_DIST="";
|
|
|
e9fa07 |
ARG_FETCH_FORCE=""; ARG_PARALLEL=1; ARG_RELAXED=0; ARG_RESET_PKG=0;
|
|
|
e9fa07 |
ARG_RESTART=""; ARG_RESTART_AT=""; ARG_RESTART_RECURSIVE=""; ARG_VERBOSE=0;
|
|
|
e9fa07 |
ARG_VERBOSE_TAGS="";
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
longopt)
|
|
|
e9fa07 |
local _bpigf_verb="${1}" _bpigf_rstatus="${2#\$}" _bpigf_opt="${3}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${_bpigf_opt}" in
|
|
|
e9fa07 |
--as-needed) ARG_AS_NEEDED=1; _bpigf_shiftfl=1; ;;
|
|
|
4ad93e |
--ccache) ARG_CCACHE="ccache"; _bpigf_shiftfl=1; ;;
|
|
|
e9fa07 |
--debug-minipx) ARG_DEBUG_MINIPIX=1; _bpigf_shiftfl=1; ;;
|
|
|
e9fa07 |
--help) _bpigf_shiftfl=1; ;;
|
|
|
e9fa07 |
--reset-state) ARG_RESET_PKG=1; _bpigf_shiftfl=1; ;;
|
|
|
3a7f9a |
--theme) shift 3;
|
|
|
3a7f9a |
if [ "${#}" != 1 ]; then
|
|
|
3a7f9a |
rtl_setrstatus "${_bpigf_rstatus}" 'missing argument to --theme option';
|
|
|
3a7f9a |
return 1;
|
|
|
3a7f9a |
else
|
|
|
3a7f9a |
ARG_THEME="${1:-}"; _bpigf_shiftfl=2;
|
|
|
3a7f9a |
fi;
|
|
|
3a7f9a |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
# {{{ --roar
|
|
|
e9fa07 |
--roar) printf "%s\n" '
|
|
|
e9fa07 |
?[40m?[37m ?[40m?[34m▃▃▃▃?[0m
|
|
|
e9fa07 |
?[40m?[37m ?[40m?[34m▟?[44m?[94m ?[40m?[34m▙?[0m
|
|
|
e9fa07 |
?[40m?[35m▟▙▃▟▙ ?[44m?[34m ?[44m?[33m/\?[34m?[34m ?[34m?[33m/\?[34m?[34m ?[40m?[37m ?[40m?[97mroar!?[0m
|
|
|
e9fa07 |
?[40m?[35m▜?[40m?[95m▒▓▒?[40m?[35m▛ ?[104m?[94m ?[103m?[94m▛ ?[103m?[33m""" ?[103m?[94m▜?[104m?[34m ?[40m?[37m ?[40m?[97m/?[0m
|
|
|
2c100a |
?[40m?[37m ?[40m?[35m▜?[45m?[35m ?[40m?[35m▛ ?[104m?[94m ?[103m?[30m ^ _ ^ ?[104m?[94m ?[40m?[37m ?[40m?[97m/?[0m
|
|
|
2c100a |
?[40m?[37m ?[40m?[35m▀ ?[46m?[36m ?[103m?[33m (__?[103m?[30my?[103m?[33m_)?[103m?[30m ?[46m?[36m ?[0m
|
|
|
2c100a |
?[40m?[37m ?[40m?[93m▟▙ ▁▂▃▟?[103m?[36m▐?[40m?[36m▙?[40m?[93m▜?[103m?[33m`\_/?[40m?[93m▛?[40m?[36m▟▌?[0m
|
|
|
e9fa07 |
?[40m?[37m ?[40m?[93m▟▙ ▟?[103m?[30m ?[103m?[36m▓▓▓?[103m?[30m| |?[40m?[93m▍?[40m?[36m▓▓▓?[0m
|
|
|
e9fa07 |
?[40m?[37m ?[40m?[93m▜?[103m?[30m\?[40m?[93m▙ ▟?[103m?[30m ?[103m?[36m▓▓▓▓▓?[103m?[30m |?[40m?[36m▓▓▓▓▓?[0m
|
|
|
e9fa07 |
?[40m?[37m ?[40m?[93m▜?[103m?[30m\\ \ ?[103m?[36m▒▒▒?[103m?[30m|?[103m?[33m ?[103m?[30m|?[40m?[37m ?[40m?[36m▒▒▒?[0m
|
|
|
e9fa07 |
?[40m?[37m ?[40m?[93m▜?[103m?[30m\ ) ?[103m?[36m▒?[103m?[30m_|?[103m?[33m ?[103m?[30m|?[40m?[93m▙ ?[40m?[36m▒?[0m
|
|
|
e9fa07 |
?[40m?[37m ?[103m?[30m(?[4m / ))))))?[0m';
|
|
|
e9fa07 |
exit 0;
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
|
|
|
e9fa07 |
*) _bpigf_shiftfl=0; ;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
opt)
|
|
|
e9fa07 |
local _bpigf_verb="${1}" _bpigf_rstatus="${2#\$}" \
|
|
|
e9fa07 |
_bpigf_opt="${3}" _bpigf_optarg="${4:-}";
|
|
|
e9fa07 |
shift 4;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${_bpigf_opt}" in
|
|
|
e9fa07 |
a) ARCH="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
b) BUILD_KIND="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
C) ARG_CLEAN_BUILDS="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
D) ARG_DIST="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
F) ARG_FETCH_FORCE="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
h) _bpigf_shiftfl=1; ;;
|
|
|
e9fa07 |
p) ARG_PARALLEL="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
P) ARG_PARALLEL="auto";
|
|
|
e9fa07 |
if [ "${2:+1}" = 1 ]\
|
|
|
e9fa07 |
&& rtl_isnumber "${2}"; then
|
|
|
e9fa07 |
_bpigf_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpigf_rstatus}" 'maximum parallelisation job count is set with the \`-p jobs'\'' option.';
|
|
|
e9fa07 |
break;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
_bpigf_shiftfl=1;
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
r) ARG_RESTART="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
R) ARG_RELAXED=1; _bpigf_shiftfl=1; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
x) ARG_VERBOSE_TAGS="${ARG_VERBOSE_TAGS:+${ARG_VERBOSE_TAGS},}xtrace";
|
|
|
e9fa07 |
_bpigf_shiftfl=1; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
v) ARG_VERBOSE=1; _bpigf_shiftfl=1; ;;
|
|
|
e9fa07 |
V) ARG_VERBOSE_TAGS="${_bpigf_optarg}"; _bpigf_shiftfl=2; ;;
|
|
|
e9fa07 |
*) cat etc/build.usage.short; exit 1; ;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
nonopt)
|
|
|
f6f7f2 |
local _bpigf_verb="${1}" _bpigf_rstatus="${2#\$}" \
|
|
|
f6f7f2 |
_bpigf_vname="" _bpigf_vval="";
|
|
|
e9fa07 |
shift 2;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if rtl_match "${1}" "=*"; then
|
|
|
e9fa07 |
BUILD_GROUPS_INHIBIT_DEPS=1; _bpigf_arg="${1#=}";
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
_bpigf_arg="${1}";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${_bpigf_arg}" in
|
|
|
4243a1 |
*=*) rtl_set_var_from_spec "${_bpigf_rstatus}" "${_bpigf_arg}";
|
|
|
f6f7f2 |
_bpigf_rc="${?}";
|
|
|
f6f7f2 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
[!a-zA-Z]*) _bpigf_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpigf_rstatus}" 'build group names must start with [a-zA-Z] (in argument \`'"${_bpigf_arg}"''\''.)';
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
*[!_bpigf_a-zA-Z]*)
|
|
|
e9fa07 |
_bpigf_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpigf_rstatus}" 'build group names must not contain [!_a-zA-Z] (in argument \`'"${_bpigf_arg}"''\''.)';
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
*) rtl_lconcat \$BUILD_GROUPS "${_bpigf_arg}"; ;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${_bpigf_rc}" -ne 0 ]; then
|
|
|
e9fa07 |
return "${_bpigf_rc}";
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
_bpigf_shiftfl=1;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
done)
|
|
|
e9fa07 |
local _bpigf_verb="${1}" _bpigf_rstatus="${2#\$}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
|
|
|
e9fa07 |
case "${ARG_PARALLEL}" in
|
|
|
e9fa07 |
auto) if ! rtl_get_cpu_count "${_bpigf_rstatus}" \$ARG_PARALLEL; then
|
|
|
e9fa07 |
_bpigf_rc=1;
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
ARG_PARALLEL=$((${ARG_PARALLEL}/2));
|
|
|
e9fa07 |
fi; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
max) if ! rtl_get_cpu_count "${_bpigf_rstatus}" \$ARG_PARALLEL; then
|
|
|
e9fa07 |
_bpigf_rc=1;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
fi; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
"") ARG_PARALLEL=1; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
*) if ! rtl_isnumber "${ARG_PARALLEL}"; then
|
|
|
e9fa07 |
_bpigf_rc=1;
|
|
|
e9fa07 |
rtl_setrstatus "${_bpigf_rstatus}" 'invalid jobs count \`'"${ARG_PARALLEL}"''\''.';
|
|
|
e9fa07 |
fi; ;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${_bpigf_rc}" -eq 0 ]; then
|
|
|
e9fa07 |
DEFAULT_BUILD_CPUS="${ARG_PARALLEL}";
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
return "${_bpigf_rc}";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
*)
|
|
|
e9fa07 |
return 1;
|
|
|
e9fa07 |
;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${_bpigf_shiftfl}" -ge 1 ]; then
|
|
|
e9fa07 |
return "$((${_bpigf_shiftfl} + 1))";
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return "${_bpigf_rc}";
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
|
|
|
e9fa07 |
# {{{ buildp_dispatch($_msg)
|
|
|
e9fa07 |
buildp_dispatch() {
|
|
|
e9fa07 |
local _bpd_msg="${1}"; shift;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${_bpd_msg}" in
|
|
|
e9fa07 |
disabled_pkg|finish_pkg|missing_pkg|msg_pkg|skipped_pkg|start_pkg|start_pkg_child|step_pkg)
|
|
|
e9fa07 |
buildp_dispatch_pkg_state "${_bpd_msg}" "${@}"; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
finish_group|start_group)
|
|
|
e9fa07 |
buildp_dispatch_group_state "${_bpd_msg}" "${@}"; ;;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
*) if command -v "buildp_dispatch_${_bpd_msg}" >/dev/null 2>&1; then
|
|
|
e9fa07 |
"buildp_dispatch_${_bpd_msg}" "${@}";
|
|
|
e9fa07 |
fi; ;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
# {{{ buildp_dispatch_fail_pkg($_group_name, $_pkg_name)
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
buildp_dispatch_fail_pkg() {
|
|
|
e9fa07 |
local _bpdfp_group_name="${1}" _bpdfp_pkg_name="${2}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
: $((BUILD_NFAIL+=1))
|
|
|
e9fa07 |
rtl_lconcat \$BUILD_PKGS_FAILED "${_bpdfp_pkg_name}";
|
|
|
e9fa07 |
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
if [ "${ARG_RELAXED:-0}" -eq 0 ]; then
|
|
|
4243a1 |
rtl_log_msgV "fatal" "${MSG_pkg_stderrout_log}" "${BUILD_WORKDIR}" "${_bpdfp_pkg_name}";
|
|
|
e9fa07 |
cat "${BUILD_WORKDIR}/${_bpdfp_pkg_name}_stderrout.log";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME:+1}" = 1 ]; then
|
|
|
e9fa07 |
printf "%s\n" "${_bpdfp_pkg_name}" > "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
|
e9fa07 |
|
|
|
4243a1 |
rtl_log_msgV "fatal" "${MSG_build_failed_in}" "${_bpdfp_pkg_name}" "${BUILD_WORKDIR}/${_bpdfp_pkg_name}_stderrout.log";
|
|
|
e9fa07 |
else
|
|
|
4243a1 |
rtl_log_msgV "warning" "${MSG_build_failed_in}" "${_bpdfp_pkg_name}" "${BUILD_WORKDIR}/${_bpdfp_pkg_name}_stderrout.log";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
# {{{ buildp_dispatch_group_state($_msg, $_group_name)
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
buildp_dispatch_group_state() {
|
|
|
e9fa07 |
local _bpdgs_msg="${1}" _bpdgs_group_name="${2}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${_bpdgs_msg}" in
|
|
|
4243a1 |
finish_group) rtl_log_msgV "group_finish" "${MSG_group_finish}" "${6}" "${4}" "${5}" "${_bpdgs_group_name}"; ;;
|
|
|
4243a1 |
start_group) rtl_log_msgV "group_begin" "${MSG_group_begin}" "${6}" "${4}" "${5}" "${_bpdgs_group_name}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
esac;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
fc9417 |
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
# {{{ buildp_dispatch_pkg_state($_msg, $_group_name, $_pkg_name)
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
buildp_dispatch_pkg_state() {
|
|
|
e9fa07 |
local _bpdps_msg="${1}" _bpdps_group_name="${2}" _bpdps_pkg_name="${3}" \
|
|
|
e9fa07 |
_bpdps_var="" _bpdps_vars="";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
case "${_bpdps_msg}" in
|
|
|
4243a1 |
disabled_pkg) : $((BUILD_NSKIP+=1)); rtl_log_msgV "pkg_skip" "${MSG_pkg_skip_disabled}" "${_bpdps_pkg_name}"; ;;
|
|
|
4243a1 |
missing_pkg) rtl_log_msgV "fatalexit" "${MSG_pkg_skip_unknown}" "${_bpdps_pkg_name}"; ;;
|
|
|
4243a1 |
msg_pkg) shift 3; rtl_log_msgV "${MSG_pkg_msg}" "${_bpdps_group_name}" "${_bpdps_pkg_name}" "${*}"; ;;
|
|
|
4243a1 |
skipped_pkg) : $((BUILD_NSKIP+=1)); rtl_log_msgV "pkg_skip" "${MSG_pkg_skip_finished}" "${_bpdps_pkg_name}"; ;;
|
|
|
4243a1 |
start_pkg) rtl_log_msgV "pkg_begin" "${MSG_pkg_begin}" "${7}" "${6}" "${4}" "${5}" "${_bpdps_pkg_name}"; ;;
|
|
|
4243a1 |
step_pkg) rtl_log_msgV "pkg_step" "${MSG_pkg_step}" "${4}" "${_bpdps_pkg_name}"; ;;
|
|
|
e9fa07 |
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
finish_pkg)
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
: $((BUILD_NFINI+=1));
|
|
|
e9fa07 |
if rtl_lmatch \$ARG_VERBOSE_TAGS "build" ","; then
|
|
|
e9fa07 |
cat "${BUILD_WORKDIR}/${_bpdps_pkg_name}_stderrout.log";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
|
4243a1 |
rtl_log_msgV "pkg_finish" "${MSG_pkg_finish}" "${7}" "${6}" "${4}" "${5}" "${_bpdps_pkg_name}"; ;;
|
|
|
e9fa07 |
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
start_pkg_child)
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
if [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then
|
|
|
e9fa07 |
for _bpdps_var in ${DEFAULT_BUILD_VARS}; do
|
|
|
e9fa07 |
if eval [ \"\${PKG_${_bpdps_var}:+1}\" = 1 ]; then
|
|
|
e9fa07 |
_bpdps_vars="${_bpdps_vars:+${_bpdps_vars} }PKG_${_bpdps_var}";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
done;
|
|
|
e9fa07 |
rtl_log_env_vars "info" "build" ${_bpdps_vars};
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
|
e9fa07 |
if rtl_lmatch \$ARG_VERBOSE_TAGS "xtrace" ","; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
set -o xtrace;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
esac;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
fc9417 |
|
|
|
e9fa07 |
return 0;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
};
|
|
|
e9fa07 |
# }}}
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
|
e9fa07 |
# {{{ buildp_time_init()
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
buildp_time_init() {
|
|
|
e9fa07 |
rtl_date \$BUILD_DATE_START "%Y-%m-%d-%H-%M-%S";
|
|
|
e9fa07 |
rtl_date \$_build_time_secs "%s";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
};
|
|
|
e9fa07 |
# }}}
|
|
|
e9fa07 |
# {{{ buildp_time_update()
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
buildp_time_update() {
|
|
|
e9fa07 |
local _bptu_date;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
rtl_date \$_bptu_date "%s";
|
|
|
e9fa07 |
: $((_build_time_secs=${_bptu_date}-${_build_time_secs}));
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
: $((_build_time_hours=${_build_time_secs}/3600));
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
: $((_build_time_minutes=(${_build_time_secs}%3600)/60));
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
: $((_build_time_secs=(${_build_time_secs}%3600)%60));
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
};
|
|
|
e9fa07 |
# }}}
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
build() {
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
local _build_time_hours=0 _build_time_mins=0 _build_time_secs=0 _pkg_name="" _rc=0 _status="" \
|
|
Lucio Andrés Illanes Albornoz |
bbb50c |
BUILD_DATE_START="" BUILD_GROUPS="" BUILD_GROUPS_INHIBIT_DEPS=0 BUILD_HNAME BUILD_IS_PARENT=1 \
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
BUILD_NFAIL=0 BUILD_NFINI=0 BUILD_NSKIP=0 BUILD_PKGS_FAILED="" BUILD_TARGET="" BUILD_USER="" \
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
DEFAULT_BUILD_CPUS=1 DEFAULT_BUILD_LAST_FAILED_PKG_FNAME="" DEFAULT_BUILD_LOG_FNAME="" \
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
DEFAULT_BUILD_STEPS="" DEFAULT_BUILD_VARS="" DEFAULT_CLEAR_PREFIX_PATHS="" DEFAULT_GIT_ARGS="" \
|
|
Lucio Andrés Illanes Albornoz |
7bede2 |
DEFAULT_GITROOT_HEAD="${DEFAULT_GITROOT_HEAD:-}" DEFAULT_LOG_ENV_VARS="" DEFAULT_MIRRORS="" \
|
|
Lucio Andrés Illanes Albornoz |
7bede2 |
DEFAULT_TARGET="" DEFAULT_WGET_ARGS="" MIDIPIX_BUILD_PWD="";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
BUILD_PKG_WAIT="";
|
|
|
e9fa07 |
DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME="";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
trap "buildp_ast exit" EXIT; trap "buildp_ast abort" HUP INT TERM USR1 USR2;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if ! buildp_init \$_status "${@}"; then
|
|
|
e9fa07 |
_rc=0;
|
|
|
f6f7f2 |
_status="Error: ${_status}";
|
|
|
e9fa07 |
else
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
buildp_time_init;
|
|
|
4243a1 |
rtl_log_msgV "build_begin" "${MSG_build_begin}" "${BUILD_USER}" "${BUILD_HNAME}" "${BUILD_DATE_START}";
|
|
Lucio Andrés Illanes Albornoz |
b1d432 |
rtl_log_env_vars "build_vars" "build (global)" ${DEFAULT_LOG_ENV_VARS};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
ex_pkg_dispatch \
|
|
|
e9fa07 |
\$BUILD_PKG_WAIT "${DEFAULT_BUILD_STEPS}" "${DEFAULT_BUILD_VARS}" \
|
|
|
dad549 |
"${ARG_RELAXED}" buildp_dispatch "${BUILD_GROUPS}" \
|
|
|
dad549 |
"${BUILD_GROUPS_INHIBIT_DEPS}" "${ARG_PARALLEL}" \
|
|
|
dad549 |
"${BUILD_WORKDIR}/build.fifo" "${ARG_RESTART}" "${ARG_RESTART_AT}" \
|
|
|
dad549 |
"${ARG_RESTART_RECURSIVE}" "${BUILD_WORKDIR}";
|
|
|
e9fa07 |
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
buildp_time_update;
|
|
|
4243a1 |
rtl_log_msgV "build_finish" "${MSG_build_finish}" "${BUILD_NFINI:-0}" "${BUILD_NSKIP:-0}" "${BUILD_NFAIL:-0}";
|
|
|
4243a1 |
rtl_log_msgV "build_finish_time" "${MSG_build_finish_time}" "${_build_time_hours:-0}" "${_build_time_minutes:-0}" "${_build_time_secs:-0}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${BUILD_PKGS_FAILED:+1}" = 1 ]; then
|
|
|
e9fa07 |
_rc=1;
|
|
|
e9fa07 |
_status="Build script failure(s) in: ${BUILD_PKGS_FAILED}.";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
|
e9fa07 |
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
if [ "${_rc}" -ne 0 ]; then
|
|
|
4243a1 |
rtl_log_enable_tagsV "${LOG_TAGS_all}";
|
|
|
4243a1 |
rtl_log_msgV "fatalexit" "0;${_status}";
|
|
|
e9fa07 |
elif [ "${_status:+1}" = 1 ]; then
|
|
|
4243a1 |
rtl_log_enable_tagsV "${LOG_TAGS_all}";
|
|
|
4243a1 |
rtl_log_msgV "info" "0;${_status}";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz |
e493dc |
set +o errexit -o noglob -o nounset; build "${@}";
|
|
lalbornoz |
340f4c |
|
|
Lucio Andrés Illanes Albornoz |
fc9bdb |
# vim:filetype=sh textwidth=0
|