|
lalbornoz |
340f4c |
#!/bin/sh
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
# Copyright (c) 2016 Lucio Andrés Illanes Albornoz <l.illanes@gmx.de>
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d1adc7 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
for __ in subr/*.subr; do . "${__}"; done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
set -o noglob;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e48a0 |
case ${1} in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f3562b |
-4) ARG_IPV4_ONLY=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f3562b |
-6) ARG_IPV6_ONLY=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e313c |
-c) ARG_CLEAN=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
-C) ARG_CHECK_UPDATES=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e313c |
-N) ARG_OFFLINE=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
-i) ARG_IGNORE_SHA256SUMS=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0f521 |
-R) ARG_RELAXED=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
7b01b5 |
--debug-minipix)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
7b01b5 |
ARG_DEBUG_MINIPIX=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
-t*) ARG_TARBALL=1; [ "${1#-t.}" != "${1}" ] && TARBALL_SUFFIX="${1#-t.}"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e313c |
-v) ARG_VERBOSE=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e313c |
-x) ARG_XTRACE=1; set -o xtrace; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
-a) [ -z "${2}" ] && exec cat etc/build.usage || ARCH="${2}"; shift; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
-b) [ -z "${2}" ] && exec cat etc/build.usage || BUILD="${2}"; shift; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
-r) if [ -z "${2}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49ffbe |
exec cat build.usage;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
elif [ "${2%:*}" = "${2}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
ARG_RESTART="${2}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
ARG_RESTART="${2%:*}"; ARG_RESTART_AT="${2#*:}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
BUILD_PACKAGES_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
shift; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
7b01b5 |
host_toolchain|native_toolchain|runtime|lib_packages|leaf_packages|minipix|devroot|world)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e313c |
BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
*=*) set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
*) exec cat etc/build.usage; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
esac; shift; done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
pre_setup_env; pre_prereqs; pre_subdirs; pre_build_files;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
{(
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
if [ "${ARG_CHECK_UPDATES:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0bb2fe |
log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
44046a |
log_env_vars "build (global)" ${LOG_ENV_VARS};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0bb2fe |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0bb2fe |
log_msg info "Version check run started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
44046a |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
for BUILD_TARGET_LC in $(subst_tgts invariants ${BUILD_TARGETS_META:-world}); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
BUILD_TARGET="$(echo ${BUILD_TARGET_LC} | tr a-z A-Z)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
BUILD_PACKAGES="$(get_var_unsafe ${BUILD_TARGET}_PACKAGES)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
if [ "${BUILD_TARGET}" != "INVARIANTS" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
&& [ -n "${BUILD_PACKAGES_RESTART}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
BUILD_PACKAGES="$(lfilter "${BUILD_PACKAGES}" "${BUILD_PACKAGES_RESTART}")";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
for PKG_NAME in ${BUILD_PACKAGES}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b834f8 |
unset PKG_NAME_PARENT;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
48549b |
if [ "${PKG_NAME#*_flavour_*}" != "${PKG_NAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
48549b |
PKG_NAME_PARENT="${PKG_NAME%_flavour_*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
48549b |
elif [ "${ARG_CHECK_UPDATES:-0}" -eq 1 ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
&& [ "${BUILD_PACKAGE#*.*}" = "${BUILD_PACKAGE}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
(mode_check_pkg_updates "${PKG_NAME}" "${BUILD_PACKAGE}");
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
continue;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
unset BUILD_SCRIPT_RC;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
dc3ef5 |
(set -o errexit -o noglob;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
if [ -n "${BUILD_PACKAGES_RESTART}" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
300736 |
|| [ "${BUILD_TARGET}" = "INVARIANTS" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
|| ! is_build_script_done "${PKG_NAME}" finish; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
dc3ef5 |
PKG_BUILD_STEPS="$(get_var_unsafe PKG_$(echo ${PKG_NAME} | tr a-z A-Z)_BUILD_STEPS)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
set -- ${PKG_BUILD_STEPS:-${BUILD_STEPS}};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
36ab93 |
_pkg_step_cmds=""; _pkg_step_cmd_args="";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
dc3ef5 |
case "${1#*:}" in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
36ab93 |
abstract) _pkg_step_cmds="pkg_${PKG_NAME}_${1%:*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
_pkg_step_cmd_args="${ARG_RESTART_AT:-ALL}"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
always) _pkg_step_cmds="pkg_${1%:*}"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
300736 |
main) if [ "${BUILD_TARGET}" = "INVARIANTS" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
300736 |
_pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
300736 |
elif [ -n "${BUILD_PACKAGES_RESTART}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
if [ -z "${ARG_RESTART_AT}" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
51fbc3 |
|| lmatch "${ARG_RESTART_AT}" , "${1%:*}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
_pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
8ee843 |
elif ! is_build_script_done "${PKG_NAME}" "${1%:*}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
_pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
optional)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
51fbc3 |
if lmatch "${ARG_RESTART_AT}" "," "${1%:*}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
_pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
esac;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
for __ in ${_pkg_step_cmds}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
dc3ef5 |
if test_cmd "${__}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
test_cmd "pkg_${PKG_NAME}_${1%:*}_pre" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
&& "pkg_${PKG_NAME}_${1%:*}_pre"
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
36ab93 |
"${__}" ${_pkg_step_cmd_args};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
test_cmd "pkg_${PKG_NAME}_${1%:*}_post" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
&& "pkg_${PKG_NAME}_${1%:*}_post"
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
if [ "${1#*:}" != "always" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
&& [ ${#} -ge 2 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
set_build_script_done "${PKG_NAME}" "${1%:*}" "-${2#*:}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
set_build_script_done "${PKG_NAME}" "${1%:*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d5afb4 |
fi; break;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
shift; done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
fi);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
case "${BUILD_SCRIPT_RC:=${?}}" in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
0) log_msg succ "Finished \`${PKG_NAME}' build.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
: $((BUILD_NFINI+=1)); continue; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
*) log_msg fail "Build failed in \`${PKG_NAME}' (last return code ${BUILD_SCRIPT_RC}.).";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0f521 |
: $((BUILD_NFAIL+=1));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
if [ ${ARG_RELAXED:-0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${PKG_NAME}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
continue;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
break;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
esac;
|
|
lalbornoz |
340f4c |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
if [ "${BUILD_SCRIPT_RC:-0}" -ne 0 ]; then
|
|
lalbornoz |
340f4c |
break;
|
|
lalbornoz |
340f4c |
fi;
|
|
lalbornoz |
340f4c |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
if [ "${BUILD_SCRIPT_RC:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
378fac |
post_copy_etc; post_sha256sums; post_tarballs;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0981c3 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
802215 |
post_build_files;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
96b309 |
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s).";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
if [ ${ARG_RELAXED:-0} -eq 1 ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
&& [ -n "${BUILD_PKGS_FAILED}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
log_msg info "Build script failure(s) in: ${BUILD_PKGS_FAILED}.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ceeb88 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1fb552 |
exit "${BUILD_SCRIPT_RC}")} 2>&1 | tee "${BUILD_LOG_FNAME}" & TEE_PID="${!}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2a4f2 |
trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2a4f2 |
log_msg fail \"Build aborted.\"; \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2a4f2 |
echo kill ${TEE_PID}; \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2a4f2 |
kill ${TEE_PID}" HUP INT TERM USR1 USR2;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2a4f2 |
wait;
|
|
lalbornoz |
340f4c |
|
|
lalbornoz |
340f4c |
# vim:filetype=sh
|