|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
#
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
# set +o errexit -o noglob -o nounset is assumed.
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
#
|
|
Lucio Andrés Illanes Albornoz |
6c3660 |
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
buildp_init_args() {
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
local _group="" _last_pkg="" _pkg_names_unknown="" _rc=0; _status="";
|
|
Lucio Andrés Illanes Albornoz |
9b5d49 |
if [ -z "${BUILD_HNAME:-}" ]\
|
|
Lucio Andrés Illanes Albornoz |
9b5d49 |
&& ! BUILD_HNAME="$(hostname)"; then
|
|
Lucio Andrés Illanes Albornoz |
9b5d49 |
_rc=1; _status="Error: failed to obtain hostname.";
|
|
Lucio Andrés Illanes Albornoz |
9b5d49 |
elif [ "${ARG_DUMP_ON_ABORT:-0}" -eq 1 ]\
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
&& [ "${ARG_RELAXED:-0}" -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
_rc=1; _status="Error: --dump-on-abort excludes -R.";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
elif [ "${ARG_AS_NEEDED:-0}" -eq 1 ]\
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
&& [ -e "${PREFIX}/build.gitref" ]\
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
&& [ "$(git rev-parse HEAD)" = "$(cat "${PREFIX}/build.gitref")" ]; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
_rc=0; _status="Git repository has not changed since last build and --as-needed was specified.";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
else case "${ARG_FETCH_FORCE}" in
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
ipv4) DEFAULT_GIT_ARGS="$(rtl_lconcat "-4" "${DEFAULT_GIT_ARGS}")";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
DEFAULT_WGET_ARGS="$(rtl_lconcat "-4" "${DEFAULT_GIT_ARGS}")"; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
ipv6) DEFAULT_GIT_ARGS="$(rtl_lconcat "-6" "${DEFAULT_GIT_ARGS}")";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
DEFAULT_WGET_ARGS="$(rtl_lconcat "-6" "${DEFAULT_GIT_ARGS}")"; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
case "${ARG_RESTART}" in
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
\*\*\*[a-zA-Z]*)
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
ARG_RESTART="${ARG_RESTART#\*\*\*}"; ARG_RESTART_RECURSIVE=3; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
\*\*[a-zA-Z]*) ARG_RESTART="${ARG_RESTART#\*\*}"; ARG_RESTART_RECURSIVE=2; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
\*[a-zA-Z]*) ARG_RESTART="${ARG_RESTART#\*}"; ARG_RESTART_RECURSIVE=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
ALL) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=2; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
LAST) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=0;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]\
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
&& [ -e "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
_last_pkg="$(cat "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}")";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
rtl_state_clear "${BUILD_WORKDIR}" "${_last_pkg}";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
ARG_RESTART="${_last_pkg}";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
else
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
_rc=1; _status="Error: cannot rebuild last failed package.";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
if [ "${_rc:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
case "${ARG_RESTART}" in
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
*:*) ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="$(rtl_llift "${ARG_RESTART%%:*}" "," " ")"; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
*) ARG_RESTART="$(rtl_llift "${ARG_RESTART}" "," " ")"; ARG_RESTART_AT=ALL; ;;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if ! ex_pkg_load_groups; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
_rc=1; _status="Error: failed to load build groups.";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
else if ! rtl_lmatch "${ARG_DIST}" "rpm" ","; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
EX_PKG_BUILD_GROUPS="$(rtl_lfilter "${EX_PKG_BUILD_GROUPS}" "host_deps_rpm")";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ -z "${BUILD_GROUPS}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
BUILD_GROUPS="${EX_PKG_BUILD_GROUPS}";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
else for _group in ${BUILD_GROUPS}; do
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if ! rtl_lmatch "${EX_PKG_BUILD_GROUPS}" "${_group}"; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
_rc=1; _status="Error: unknown build group \`${_group}'."; break;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
done;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ "${_rc:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ -n "${ARG_DIST}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
BUILD_GROUPS="$(rtl_lconcat "$(rtl_lfilter "${BUILD_GROUPS}" "dist")" "dist")";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ -n "${ARG_RESTART}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
for _pkg_name in ${ARG_RESTART}; do
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if ! ex_pkg_find_package "${BUILD_GROUPS}" "${_pkg_name}" >/dev/null; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
_pkg_names_unknown="$(rtl_lconcat "${_pkg_names_unknown}" "${_pkg_name}")";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
done;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
case "$(rtl_llength "${_pkg_names_unknown}")" in
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
0) ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
1) _rc=1; _status="Error: unknown package \`${_pkg_names_unknown}'."; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
*) _rc=1; _status="Error: unknown packages: $(rtl_subst "${_pkg_names_unknown}" " " ", ")"; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ "${_rc}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
case "${ARG_VERBOSE:-0}" in
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
0) rtl_fileop_set_log 0; rtl_log_set_lvl 0; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
1) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
2) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
3) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
4) rtl_fileop_set_log 1; rtl_log_set_lvl 3; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
*) _rc=1; _status="Error: invalid verbosity level (max. -vvvv)"; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi; return "${_rc}";
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
};
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
buildp_init_env() {
|
|
Lucio Andrés Illanes Albornoz |
9d2842 |
local _fname="" _rc=0; _status="";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
if ! cd "${0%/*}"; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
printf "Error: failed to change working directory to \`${0%/*}'." >&2; exit 1;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
elif ! umask 022; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
printf "Error: failed to set umask(2).\n" >&2; exit 1;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
elif ! BUILD_USER="$(id -nu)"; then
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
printf "Error: failed to obtain username." >&2; exit 1;
|
|
Lucio Andrés Illanes Albornoz |
6d9a3c |
else for _fname in $(find subr -name *.subr); do
|
|
Lucio Andrés Illanes Albornoz |
6d9a3c |
if ! . "${_fname}"; then
|
|
Lucio Andrés Illanes Albornoz |
6d9a3c |
printf "Error: failed to source \`%s'.\n" "${_fname}"; exit 1;
|
|
Lucio Andrés Illanes Albornoz |
6d9a3c |
fi;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
done;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi; return "${_rc}";
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
};
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
buildp_init_files() {
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
local _log_last_fname="" _log_last_num=1 _rc=0; _status=""
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
if ! rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}"\
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
|| rtl_lmatch "${ARG_DIST}" "rpm" ","\
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
&& ! rtl_fileop mkdir "${PREFIX_RPM}"; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
_rc=1; _status="Error: cannot create build directories.";
|
|
Lucio Andrés Illanes Albornoz |
2b85d0 |
elif [ -e "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
_rc=1; _status="Error: another build targeting this architecture and build type is currently in progress.";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
elif ! rtl_clean_env "${DEFAULT_CLEAR_ENV_VARS_EXCEPT}"; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
_rc=1; _status="Error: failed to clean environment.";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
elif ! rtl_check_path_vars "${DEFAULT_CHECK_PATH_VARS}"; then
|
|
Lucio Andrés Illanes Albornoz |
8a27f9 |
_rc=1; _status="${_status}";
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
else touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
while [ -e "${DEFAULT_BUILD_LOG_FNAME}.${_log_last_num}" ]; do
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
: $((_log_last_num+=1));
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
done;
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
_log_last_fname="${DEFAULT_BUILD_LOG_FNAME}.${_log_last_num}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME}" "${_log_last_fname}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fileop ln_symbolic "${_log_last_fname}" "${DEFAULT_BUILD_LOG_LAST_FNAME}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
rtl_fileop touch "${DEFAULT_BUILD_LOG_FNAME}"; rtl_log_set_fname "${DEFAULT_BUILD_LOG_FNAME}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
if rtl_lmatch "${ARG_CLEAN_BUILDS}" "prefix" ","; then
|
|
Lucio Andrés Illanes Albornoz |
0a3032 |
trap "rm -f \"${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}\" 2>/dev/null; rtl_log_msg fatalexit \"Build aborted.\"" HUP INT TERM USR1 USR2;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_log_msg info "-C prefix specified, cleaning prefix...";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
if ! rtl_fileop rm "${PREFIX}/${_pname}"; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
_rc=1; _status="Error: failed to remove \`${PREFIX}/${_pname}'."; break;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
done;
|
|
Lucio Andrés Illanes Albornoz |
144d63 |
trap - HUP INT TERM USR1 USR2;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
return "${_rc}";
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
};
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
buildp_init_getopts() {
|
|
Lucio Andrés Illanes Albornoz |
487c40 |
local _arg="" _opt="" _rc=0 _shiftfl=0 OPTIND=0; _status="";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
: ${ARCH:="nt64"}; : ${BUILD:="debug"};
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
ARG_AS_NEEDED=0; ARG_CLEAN_BUILDS=""; ARG_DEBUG_MINIPIX=0; ARG_DIST=1; ARG_DUMP_IN="";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
ARG_DUMP_ON_ABORT=0; ARG_FETCH_FORCE=0; ARG_PARALLEL=1; ARG_RELAXED=0; ARG_RESTART="";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
ARG_RESTART_AT=""; ARG_RESTART_RECURSIVE=""; ARG_VERBOSE=0;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
while [ "${#}" -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
case "${1}" in
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
--as-needed) ARG_AS_NEEDED=1; _shiftfl=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
f243be |
--dump-in) if [ "${#}" -ge 2 ]; then
|
|
Lucio Andrés Illanes Albornoz |
f243be |
ARG_DUMP_IN="${2}"; ARG_DUMP_ON_ABORT=1; _shiftfl=2;
|
|
Lucio Andrés Illanes Albornoz |
f243be |
else
|
|
Lucio Andrés Illanes Albornoz |
f243be |
_rc=1; _status="Error: missing argument to option --dump-in.";
|
|
Lucio Andrés Illanes Albornoz |
f243be |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
8a27f9 |
--dump-on-abort)
|
|
Lucio Andrés Illanes Albornoz |
8a27f9 |
ARG_DUMP_ON_ABORT=1; _shiftfl=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
--debug-minipx) ARG_DEBUG_MINIPIX=1; _shiftfl=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
-v*) _opt="${1#-}"; while [ -n "${_opt}" ]; do
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
: $((ARG_VERBOSE+=1)); _opt="${_opt#?}";
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
done; _shiftfl=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
*) _shiftfl=0; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
f243be |
if [ "${_rc}" -ne 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
f243be |
break;
|
|
Lucio Andrés Illanes Albornoz |
f243be |
elif [ "${_shiftfl}" -gt 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
shift "${_shiftfl}"; continue;
|
|
Lucio Andrés Illanes Albornoz |
8f50a3 |
elif getopts a:b:C:D:Fhp:Pr:R _opt; then
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
case "${_opt}" in
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
a) ARCH="${OPTARG}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
b) BUILD="${OPTARG}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
C) ARG_CLEAN_BUILDS="${OPTARG}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
D) ARG_DIST="${OPTARG}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
F) ARG_FETCH_FORCE=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
h) cat etc/build.usage; exit 0; ;;
|
|
Lucio Andrés Illanes Albornoz |
8f50a3 |
p) ARG_PARALLEL="${OPTARG}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
73f6c6 |
P) ARG_PARALLEL="auto";
|
|
Lucio Andrés Illanes Albornoz |
73f6c6 |
if [ -n "${2:-}" ]\
|
|
Lucio Andrés Illanes Albornoz |
73f6c6 |
&& rtl_isnumber "${2}"; then
|
|
Lucio Andrés Illanes Albornoz |
73f6c6 |
_rc=1; _status="Error: maximum parallelisation job count is set with the \`-p jobs' option."; break
|
|
Lucio Andrés Illanes Albornoz |
73f6c6 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
r) ARG_RESTART="${OPTARG}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
R) ARG_RELAXED=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
*) cat etc/build.usage; exit 1; ;;
|
|
Lucio Andrés Illanes Albornoz |
8f50a3 |
esac; shift $((${OPTIND}-1)); OPTIND=1;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
else
|
|
Lucio Andrés Illanes Albornoz |
c240c2 |
break;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
done;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
if [ "${_rc:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
if [ "${1#=}" != "${1}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
BUILD_GROUPS_INHIBIT_DEPS=1; _arg="${1#=}";
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
else
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
_arg="${1}";
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
case "${_arg}" in
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
*=*) rtl_set_var_unsafe "${_arg%%=*}" "${_arg#*=}"; ;;
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
[^a-zA-Z]*) _rc=1; _status="Error: build group names must start with [a-zA-Z] (in argument \`${_arg}'.)"; ;;
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
*[^_a-zA-Z]*) _rc=1; _status="Error: build group names must not contain [^_a-zA-Z] (in argument \`${_arg}'.)"; ;;
|
|
Lucio Andrés Illanes Albornoz |
5f8a15 |
*) BUILD_GROUPS="$(rtl_lconcat "${BUILD_GROUPS}" "${_arg}")"; ;;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
esac; shift;
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
done;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ "${_rc:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
case "${ARG_PARALLEL}" in
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
auto) if ! ARG_PARALLEL="$(rtl_get_cpu_count)"; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
_rc=1; _status="Error: failed to get CPU count.";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
else
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
ARG_PARALLEL=$((${ARG_PARALLEL}/2));
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
"") ARG_PARALLEL=1; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
*) if ! rtl_isnumber "${ARG_PARALLEL}"; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
_rc=1; _status="Error: invalid jobs count \`${ARG_PARALLEL}'.";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
esac;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
if [ "${_rc:-0}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
DEFAULT_BUILD_CPUS="${ARG_PARALLEL}";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
8f50a3 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
ae3ff0 |
return "${_rc}";
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
};
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
buildp_init_getopts_help() {
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
local _opt="";
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
while getopts a:b:C:D:Fhp:Pr:R _opt 2>/dev/null; do
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
case "${_opt}" in
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
h) cat etc/build.usage; exit 0; ;;
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
esac; done; shift $((${OPTIND}-1));
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
};
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
|
|
Lucio Andrés Illanes Albornoz |
9d2842 |
buildp_init_prereqs() {
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
if ! rtl_check_prereqs \
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
awk bunzip2 bzip2 cat chmod cmake cp date find flock \
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
g++ gcc git grep gunzip gzip hostname id install kill \
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
ln lzip make mkdir mkfifo mktemp mv paste patch perl \
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
pgrep pkill printf readlink rm sed sha256sum sort \
|
|
Lucio Andrés Illanes Albornoz |
b03d3c |
stat tail tar test touch tr uniq wget xz zip; then
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
printf "%s\n" "${_status}" >&2; exit 1;
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
elif ! (FNAME="$(mktemp)" && { trap "rm -f \"\${FNAME}\"" EXIT; \
|
|
Lucio Andrés Illanes Albornoz |
0d1c4f |
sed -i'' -e '' "${FNAME}" >/dev/null 2>&1; }); then
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
printf "Error: sed(1) in \${PATH} does not support the \`-i' option.\n" >&2; exit 1;
|
|
Lucio Andrés Illanes Albornoz |
9d2842 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
9d2842 |
};
|
|
Lucio Andrés Illanes Albornoz |
9d2842 |
|
|
Lucio Andrés Illanes Albornoz |
c3bcd7 |
build_init() {
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
local _rc=0; _status="";
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
if ! buildp_init_env \
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
|| ! buildp_init_getopts_help "${@}" \
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
|| ! buildp_init_prereqs \
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
|| ! buildp_init_getopts "${@}" \
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
|| ! ex_pkg_load_vars \
|
|
Lucio Andrés Illanes Albornoz |
11ef38 |
|| ! buildp_init_args \
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
|| ! buildp_init_files; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
_rc=1; _status="${_status}";
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
fi; return "${_rc}";
|
|
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
|