|
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) |
59765f |
for __ in subr/*.subr; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
. ./${__};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done;
|
|
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) |
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) |
6e313c |
-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) |
6e313c |
-a) [ -z "${2}" ] && exec cat etc/build.usage || ARCH=${2}; shift; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e313c |
-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) |
6e313c |
ARG_RESTART=${2};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e313c |
ARG_RESTART=${2%:*}; ARG_RESTART_AT=${2#*:};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
if [ -z "${ARG_RESTART_AT}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
ARG_RESTART_AT=ALL;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi; shift; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e5b9d8 |
host_toolchain|native_toolchain|runtime|lib_packages|leaf_packages|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) |
59765f |
esac; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
if [ -z "${BUILD_CPUS}" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
&& [ -e /proc/cpuinfo ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/build.vars; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
[ -e ${__} ] && . ${__};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
if ! match_list "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
unset "${__}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
done;
|
|
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) |
d1adc7 |
pre_prereqs;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d1adc7 |
pre_subdirs;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
if [ -e ${BUILD_LOG_FNAME} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
touch ${BUILD_STATUS_IN_PROGRESS_FNAME};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
BUILD_DATE_START="$(date %Y-%m-%d-%H-%M-%S)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
BUILD_TIMES_SECS=$(command date +%s);
|
|
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) |
44046a |
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) |
59765f |
BUILD_TARGET=$(echo ${BUILD_TARGET_LC} | tr a-z A-Z);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
for BUILD_PACKAGE_LC in $(get_var_unsafe ${BUILD_TARGET}_PACKAGES); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
BUILD_PACKAGE=$(echo ${BUILD_PACKAGE_LC} | tr a-z A-Z);
|
|
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) |
e5b9d8 |
if [ "${BUILD_TARGET}" != "INVARIANTS" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e5b9d8 |
&& [ -n "${ARG_RESTART}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ea7997 |
if [ "${ARG_RESTART}" != "ALL" ] &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ea7997 |
! match_list ${ARG_RESTART} , ${BUILD_PACKAGE_LC}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg vnfo "Skipped \`${BUILD_PACKAGE_LC}' (-r specified.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
if [ ${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) |
bd97b6 |
mode_check_pkg_updates "${BUILD_PACKAGE_LC}" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_VERSION)" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL)" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL_TYPE)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
continue;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e5b9d8 |
if [ "${BUILD_TARGET}" != "INVARIANTS" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e5b9d8 |
&& [ -z "${ARG_RESTART}" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
413df3 |
&& is_build_script_done finish "${BUILD_PACKAGE_LC}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg vnfo "Skipped \`${BUILD_PACKAGE_LC}' (already built.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
elif [ -n "${ARG_RESTART}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
log_msg vnfo "Forcing package \`${BUILD_PACKAGE_LC}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
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) |
59765f |
(set -o errexit -o noglob;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
PKG_PREFIX=$(get_vars_unsafe ${BUILD_TARGET}_PREFIX PKG_${BUILD_PACKAGE%%.*}_PREFIX);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
parse_with_pkg_name ${BUILD_PACKAGE_LC%.*};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
for __ in ${BUILD_STEPS}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
case ${__#*:} in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
abstract)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
if test_cmd pkg_${PKG_NAME}_${__%:*}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
pkg_${PKG_NAME}_${__%:*}; exit 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
always) pkg_${__%:*}; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
main) if ! is_build_script_done ${__%:*}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
if test_cmd pkg_${PKG_NAME}_${__%:*}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
pkg_${PKG_NAME}_${__%:*};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
pkg_${__%:*};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
esac;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
set_build_script_done finish); BUILD_SCRIPT_RC=${?};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
case ${BUILD_SCRIPT_RC} in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
0) log_msg succ "Finished \`${BUILD_PACKAGE_LC}' build.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
: $((BUILD_NFINI+=1)); continue; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
*) log_msg fail "Build failed in \`${BUILD_PACKAGE_LC}' (last return code ${BUILD_SCRIPT_RC}.).";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
: $((BUILD_NFAIL+=1)); break; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
esac;
|
|
lalbornoz |
340f4c |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
if [ ${BUILD_SCRIPT_RC:-0} -ne 0 ]; then
|
|
lalbornoz |
340f4c |
break;
|
|
lalbornoz |
340f4c |
fi;
|
|
lalbornoz |
340f4c |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
post_copy_etc; post_strip; post_tarballs;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
: $((BUILD_TIMES_SECS=$(command date +%s)-${BUILD_TIMES_SECS}));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
: $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
: $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
: $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
|
|
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) |
ce047e |
if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
bd97b6 |
build_fileop rm ${BUILD_STATUS_IN_PROGRESS_FNAME};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ce047e |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
exit ${BUILD_SCRIPT_RC})} 2>&1 | tee ${BUILD_LOG_FNAME} &
|
|
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) |
e2a4f2 |
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
|