|
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) |
59765f |
# Clear the environment.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
# Source subroutine scripts.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
# Source the build variables file and its local overrides, if any.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# Process command line arguments.
|
|
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) |
59765f |
check_cpuinfo; source_vars; clear_env;
|
|
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) |
59765f |
-c) export ARG_CLEAN=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
-n) export ARG_DRYRUN=1 ARG_VERBOSE=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
35633f |
-N) export ARG_OFFLINE=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f42965 |
-t*) export ARG_TARBALL=1; [ "${1#-t.}" != "${1}" ] && TARBALL_SUFFIX=${1#-t.}; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f42965 |
-v) export ARG_VERBOSE=1; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
-x) export ARG_XTRACE=1; set -o xtrace; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
-a) [ -z "${2}" ] && exec cat etc/build.usage || export ARCH=${2}; shift; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
-b) [ -z "${2}" ] && exec cat etc/build.usage || export 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) |
59765f |
export ARG_RESTART=${2};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
export ARG_RESTART=${2%:*} ARG_RESTART_AT=${2#*:};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi; shift; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
host_toolchain|native_toolchain|runtime|lib_packages|leaf_packages|devroot|world)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
export 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) |
59765f |
if [ -z "${BUILD_TARGETS_META}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
BUILD_TARGETS_META=world;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# Check whether the pathnames in build.vars contain non-empty valid values.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# Check whether all prerequisite command names resolve.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# Check whether all prerequisite pathnames resolve.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b66e01 |
# Check whether all prerequisite Perl modules exist.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# Clean ${PREFIX} if requested.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# Create directory hierarchy and usr -> . symlinks.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
check_paths; clean_prefix; create_dirs;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
init_build_log; init_build_progress_file;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
{(init_build_vars;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_env_vars "build (global)" ${LOG_ENV_VARS};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
for BUILD_TARGET_LC in $(subst_tgts ${BUILD_TARGETS_META}); 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) |
59765f |
if [ -n "${ARG_RESTART}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if ! match_list ${ARG_RESTART} , ${BUILD_PACKAGE_LC}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_msg info "Skipped \`${BUILD_PACKAGE_LC}' (-r specified.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
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) |
59765f |
elif is_build_script_done finish "${BUILD_PACKAGE_LC}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_msg info "Skipped \`${BUILD_PACKAGE_LC}' (already built.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ -e scripts/${BUILD_PACKAGE_LC}.build ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
BUILD_SCRIPT_FNAME=scripts/${BUILD_PACKAGE_LC}.build;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
BUILD_SCRIPT_FNAME=scripts/pkg.build;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_msg info "Invoking build script \`${BUILD_SCRIPT_FNAME}'${ARG_RESTART:+ (forcibly)} for package \`${BUILD_PACKAGE_LC}'.";
|
|
lalbornoz |
340f4c |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
(set -o errexit -o noglob;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
export MIDIPIX_BUILD_PWD=$(pwd) \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
PKG_BUILD=${BUILD} PKG_TARGET=${TARGET} \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
PKG_PREFIX=$(get_vars_unsafe ${BUILD_TARGET}_PREFIX \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
PKG_${BUILD_PACKAGE%.*}_PREFIX) \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
PREFIX PREFIX_CROSS PREFIX_MIDIPIX PREFIX_NATIVE PREFIX_ROOT;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
cd ${WORKDIR}; source_scripts);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
BUILD_SCRIPT_RC=${?}; 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) |
59765f |
do_strip; do_tarballs; fini_build_vars;
|
|
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) |
59765f |
fini_build_progress_file;
|
|
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) |
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
|