|
Lucio Andrés Illanes Albornoz |
6c3660 |
build_ast() {
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
local _param="${1}" _pids_killed="";
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
rm -f "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
case "${_param}" in
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
abort) ex_rtl_log_msg failexit "Build aborted."; ;;
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
a5a093 |
ex_rtl_kill_tree "${$}";
|
|
Lucio Andrés Illanes Albornoz |
a5a093 |
if [ -n "${_pids_killed}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
a5a093 |
ex_rtl_log_msg vnfo "Killed PIDs ${_pids_killed}";
|
|
Lucio Andrés Illanes Albornoz |
a5a093 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
};
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
build_fini() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
: $((BUILD_TIMES_SECS=$(ex_rtl_date %s)-${BUILD_TIMES_SECS}));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
: $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
: $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
: $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -f "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_fileop rm ${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
build_init() {
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
local __="" _env_vars="" _env_vars_except="" _env_var="" _log_last_fname="" _log_last_ts="" _vname="" _vname_val="";
|
|
Lucio Andrés Illanes Albornoz |
12508d |
umask 022;
|
|
Lucio Andrés Illanes Albornoz |
b8d594 |
if ! awk -V 2>/dev/null | grep -q "^GNU Awk "; then
|
|
Lucio Andrés Illanes Albornoz |
0ecf7d |
ex_rtl_log_msg failexit "Error: awk(1) in \$PATH must be GNU Awk.";
|
|
Lucio Andrés Illanes Albornoz |
0ecf7d |
fi;
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
if ! which pgrep >/dev/null 2>&1; then
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
ex_rtl_log_msg failexit "Error: missing pgrep.";
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d01c02 |
if [ -z "${DEFAULT_BUILD_CPUS}" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
&& [ -e /proc/cpuinfo ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d01c02 |
DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
cbc8e0 |
if [ "${ARG_PARALLEL}" = auto ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
cbc8e0 |
ARG_PARALLEL="${DEFAULT_BUILD_CPUS}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
cbc8e0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
: ${ARCH:=nt64}; : ${BUILD:=debug};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
if [ "${ARCH}" = nt32 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
DEFAULT_TARGET="i686-nt32-midipix";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
elif [ "${ARCH}" = nt64 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
DEFAULT_TARGET="x86_64-nt64-midipix";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
if [ "${BUILD}" != debug ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
&& [ "${BUILD}" != release ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_log_msg failexit "Error: unknown build type \`${BUILD}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_log_msg failexit "Error: invalid architecture \`${ARCH}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
12508d |
for __ in ${HOME}/midipix_build.vars ${HOME}/.midipix_build.vars ../midipix_build.vars ./vars/env.vars; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
[ -e ${__} ] && . ${__};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
done;
|
|
Lucio Andrés Illanes Albornoz |
12508d |
for __ in $(find ./groups -name *.group | sort); do
|
|
Lucio Andrés Illanes Albornoz |
12508d |
. "${__}"; __="${__##*/}"; __="${__%.group}";
|
|
Lucio Andrés Illanes Albornoz |
12508d |
if [ "${__#[0-9][0-9][0-9].*}" != "${__}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
12508d |
GROUPS_DEFAULT="${GROUPS_DEFAULT:+${GROUPS_DEFAULT} }${__#*.}";
|
|
Lucio Andrés Illanes Albornoz |
12508d |
fi;
|
|
Lucio Andrés Illanes Albornoz |
12508d |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ad97c |
if [ "${ARG_AS_NEEDED:-0}" -eq 1 ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ad97c |
&& [ -e "${PREFIX}/build.gitref" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ad97c |
&& [ "$(git rev-parse HEAD)" = "$(cat "${PREFIX}/build.gitref")" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ad97c |
ex_rtl_log_msg info "Git repository has not changed since last build and --as-needed was specified.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ad97c |
exit 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ad97c |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
49b460 |
export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
if [ "${ARG_FETCH_FORCE}" = "ipv4" ]; then
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
DEFAULT_GIT_ARGS="-4${DEFAULT_GIT_ARGS:+ ${DEFAULT_GIT_ARGS}}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d01c02 |
DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
elif [ "${ARG_FETCH_FORCE}" = "ipv6" ]; then
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
DEFAULT_GIT_ARGS="-6${DEFAULT_GIT_ARGS:+ ${DEFAULT_GIT_ARGS}}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d01c02 |
DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f3562b |
fi;
|
|
Lucio Andrés Illanes Albornoz |
3b73c7 |
_env_vars="$(export | sed -ne '/^export/{s/^export //;s/=.*$//p}')";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3bb0a6 |
_env_vars_except="${DEFAULT_CLEAR_ENV_VARS_EXCEPT}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3bb0a6 |
for _env_var in ${_env_vars}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
26a97e |
if [ "${_env_var#DEFAULT_}" != "${_env_var}" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
26a97e |
|| [ "${_env_var#PKG_}" != "${_env_var}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3bb0a6 |
_env_vars_except="${_env_vars_except:+${_env_vars_except} }${_env_var}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3bb0a6 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3bb0a6 |
done;
|
|
Lucio Andrés Illanes Albornoz |
8a04de |
ex_rtl_unset_vars $(ex_rtl_lfilter "${_env_vars}" "${_env_vars_except}");
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}";
|
|
Lucio Andrés Illanes Albornoz |
0eaee4 |
if ex_rtl_lmatch "${ARG_DIST}" , rpm; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
64e589 |
ex_rtl_fileop mkdir "${PREFIX_RPM}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
64e589 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -e "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_log_msg failexit "Error: another build targeting this architecture and build type is currently in progress.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
75df43 |
_log_last_ts="$(stat -c %Y "${DEFAULT_BUILD_LOG_FNAME}")";
|
|
Lucio Andrés Illanes Albornoz |
75df43 |
_log_last_ts="$(awk 'BEGIN {printf(strftime("%Y-%m-%d-%H-%M-%S", '"${_log_last_ts}"'))}')";
|
|
Lucio Andrés Illanes Albornoz |
75df43 |
_log_last_fname="${DEFAULT_BUILD_LOG_FNAME}.${_log_last_ts}";
|
|
Lucio Andrés Illanes Albornoz |
75df43 |
ex_rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME}" "${_log_last_fname}";
|
|
Lucio Andrés Illanes Albornoz |
75df43 |
ex_rtl_fileop ln_symbolic "${_log_last_fname}" "${DEFAULT_BUILD_LOG_LAST_FNAME}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a43dbf |
ex_rtl_fileop touch "${DEFAULT_BUILD_LOG_FNAME}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a43dbf |
BUILD_IS_PARENT=1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
BUILD_DATE_START="$(ex_rtl_date %Y-%m-%d-%H-%M-%S)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
BUILD_NFINI="${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
BUILD_TIMES_SECS="$(ex_rtl_date %s)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
BUILD_PKGS_FAILED="";
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
trap "build_ast abort" HUP INT TERM USR1 USR2; trap "build_ast exit" EXIT;
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
for _vname in ${DEFAULT_CHECK_PATH_VARS}; do
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
_vname_val="$(ex_rtl_get_var_unsafe "${_vname}")";
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
if [ -z "${_vname_val}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
ex_rtl_log_msg failexit "Error: variable \`${_vname}' is empty or unset.";
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
elif [ "${_vname_val#* *}" != "${_vname_val}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
ex_rtl_log_msg failexit "Error: variable \`${_vname}' contains one or more whitespace characters.";
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
done;
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
if ex_rtl_lmatch "${ARG_CLEAN_BUILDS}" , prefix; then
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
ex_rtl_log_msg info "-C prefix specified, cleaning prefix...";
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
ex_rtl_fileop rm "${PREFIX}/${_pname}";
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
done;
|
|
Lucio Andrés Illanes Albornoz |
ed4109 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
e2fea1 |
# vim:filetype=sh
|