blob: c19c11de4eddcecf8a7aa987fa2831e75c8b0573 (
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
|
#!/bin/sh
# Copyright (c) 2016 Lucio Andrés Illanes Albornoz <l.illanes@gmx.de>
#
#
# Clear the environment.
# Source subroutine scripts.
# Source the build variables file and its local overrides, if any.
# Process command line arguments.
for __ in subr/*.subr; do
. ./${__};
done;
check_cpuinfo;
while [ ${#} -gt 0 ]; do
case ${1} in
-c) ARG_CLEAN=1; ;;
-C) ARG_CHECK_UPDATES=1; ;;
-n) ARG_DRYRUN=1 ARG_VERBOSE=1; ;;
-N) ARG_OFFLINE=1; ;;
-i) ARG_IGNORE_SHA256SUMS=1; ;;
-t*) ARG_TARBALL=1; [ "${1#-t.}" != "${1}" ] && TARBALL_SUFFIX=${1#-t.}; ;;
-v) ARG_VERBOSE=1; ;;
-x) ARG_XTRACE=1; set -o xtrace; ;;
-a) [ -z "${2}" ] && exec cat etc/build.usage || ARCH=${2}; shift; ;;
-b) [ -z "${2}" ] && exec cat etc/build.usage || BUILD=${2}; shift; ;;
-r) if [ -z "${2}" ]; then
exec cat build.usage;
elif [ "${2%:*}" = "${2}" ]; then
ARG_RESTART=${2};
else
ARG_RESTART=${2%:*}; ARG_RESTART_AT=${2#*:};
fi;
if [ -z "${ARG_RESTART_AT}" ]; then
ARG_RESTART_AT=ALL;
fi; shift; ;;
host_toolchain|native_toolchain|runtime|lib_packages|leaf_packages|devroot|world)
BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;;
*=*) set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
*) exec cat etc/build.usage; ;;
esac; shift;
done;
source_vars; clear_env;
if [ -z "${BUILD_TARGETS_META}" ]; then
BUILD_TARGETS_META=world;
fi;
#
# Check whether the pathnames in build.vars contain non-empty valid values.
# Check whether all prerequisite command names resolve.
# Check whether all prerequisite pathnames resolve.
# Check whether all prerequisite Perl modules exist.
# Clean ${PREFIX} if requested.
# Create directory hierarchy and usr -> . symlinks.
check_paths; clean_prefix; create_dirs;
init_build_log; init_build_progress_file;
{(init_build_vars;
if [ ${ARG_CHECK_UPDATES:-0} -eq 0 ]; then
log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
log_env_vars "build (global)" ${LOG_ENV_VARS};
else
log_msg info "Version check run started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
fi;
for BUILD_TARGET_LC in $(subst_tgts ${BUILD_TARGETS_META}); do
BUILD_TARGET=$(echo ${BUILD_TARGET_LC} | tr a-z A-Z);
for BUILD_PACKAGE_LC in $(get_var_unsafe ${BUILD_TARGET}_PACKAGES); do
BUILD_PACKAGE=$(echo ${BUILD_PACKAGE_LC} | tr a-z A-Z);
if [ -n "${ARG_RESTART}" ]; then
if [ "${ARG_RESTART}" != "ALL" ] &&\
! match_list ${ARG_RESTART} , ${BUILD_PACKAGE_LC}; then
log_msg vnfo "Skipped \`${BUILD_PACKAGE_LC}' (-r specified.)";
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
fi;
fi;
if [ ${ARG_CHECK_UPDATES:-0} -eq 1 ]\
&& [ "${BUILD_PACKAGE#*.*}" = "${BUILD_PACKAGE}" ]; then
if [ ${ARG_DRYRUN:-0} -eq 1 ]; then
echo check_pkg_updates "${BUILD_PACKAGE_LC}" \
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_VERSION)" \
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL)" \
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL_TYPE)";
else
check_pkg_updates "${BUILD_PACKAGE_LC}" \
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_VERSION)" \
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL)" \
"$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL_TYPE)";
fi;
continue;
fi;
if [ -z "${ARG_RESTART}" ]\
&& is_build_script_done finish "${BUILD_PACKAGE_LC}"; then
log_msg vnfo "Skipped \`${BUILD_PACKAGE_LC}' (already built.)";
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
fi;
if [ -e build/${BUILD_PACKAGE_LC}.build ]; then
BUILD_SCRIPT_FNAME=build/${BUILD_PACKAGE_LC}.build;
else
BUILD_SCRIPT_FNAME=build/pkg.build;
fi;
log_msg vnfo "Invoking build script \`${BUILD_SCRIPT_FNAME}'${ARG_RESTART:+ (forcibly)} for package \`${BUILD_PACKAGE_LC}'.";
(set -o errexit -o noglob;
MIDIPIX_BUILD_PWD=$(pwd); PKG_BUILD=${BUILD}; PKG_TARGET=${TARGET};
PKG_PREFIX=$(get_vars_unsafe ${BUILD_TARGET}_PREFIX \
PKG_${BUILD_PACKAGE%.*}_PREFIX);
cd ${WORKDIR}; source_scripts);
BUILD_SCRIPT_RC=${?}; case ${BUILD_SCRIPT_RC} in
0) log_msg succ "Finished \`${BUILD_PACKAGE_LC}' build.";
: $((BUILD_NFINI+=1)); continue; ;;
*) log_msg fail "Build failed in \`${BUILD_PACKAGE_LC}' (last return code ${BUILD_SCRIPT_RC}.).";
: $((BUILD_NFAIL+=1)); break; ;;
esac;
done;
if [ ${BUILD_SCRIPT_RC:-0} -ne 0 ]; then
break;
fi;
done;
copy_etc; do_strip; do_tarballs; fini_build_vars;
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s).";
fini_build_progress_file;
exit ${BUILD_SCRIPT_RC})} 2>&1 | tee ${BUILD_LOG_FNAME} &
TEE_PID=${!};
trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; \
log_msg fail \"Build aborted.\"; \
echo kill ${TEE_PID}; \
kill ${TEE_PID}" HUP INT TERM USR1 USR2;
wait;
# vim:filetype=sh
|