|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
# . ./build.vars and set -o errexit -o noglob are assumed.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
# See warning at the top of build.vars.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
is_build_script_done() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
if [ "${1}" = "clean" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
if match_list "${ARG_RESTART}" , ${BUILD_PACKAGE_LC} \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
&& [ -n "${ARG_RESTART_AT}" ] \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
&& match_list "${ARG_RESTART_AT}" , "${1}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
35633f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
return 0; # Skip
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
elif [ "${ARG_RESTART}" = "ALL" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ea7997 |
elif match_list "${ARG_RESTART}" , ${BUILD_PACKAGE_LC}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
if [ -n "${ARG_RESTART_AT}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
if [ "${ARG_RESTART_AT}" = "ALL" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
elif match_list "${ARG_RESTART_AT}" , "${1}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
return 0; # Skip
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a0561a |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
elif [ -f ${WORKDIR}/.${2:-${BUILD_PACKAGE_LC}}.${1} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
return 0; # Skip
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_env_vars() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_msg info "Variables for this ${1:-build}:"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
while [ ${_lev_nvar:=0} -lt ${#} ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_lev_arg="$(eval echo \${${_lev_nvar}})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_lev_arg="${_lev_arg%%=*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ ${#_lev_arg} -gt ${_lev_arg_len_max:=0} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_lev_arg_len_max=${#_lev_arg};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi; : $((_lev_nvar+=1));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done; unset _lev_nvar _lev_arg;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_msg info "$(printf \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
"%${_lev_arg_len_max}.${_lev_arg_len_max}s=%s" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
"${1%%=*}" "$(get_var_unsafe ${1#*=})")";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done; unset _lev_arg_len_max;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
parse_with_pkg_name() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
PKG_NAME=${1}; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_pwpn_pkg_name_uc=$(echo ${PKG_NAME} | tr a-z A-Z);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
if [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URL)" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
03a637 |
&& [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URLS_GIT)" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
570129 |
&& [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_VERSION)" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
unset _pwpn_pkg_name_uc;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
for _pwpn_vname in ${PKG_BUILD_VARS}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ -n "$(get_var_unsafe DEFAULT_${_pwpn_vname})" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
952e33 |
set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe DEFAULT_${_pwpn_vname})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ -n "$(get_var_unsafe ${BUILD_TARGET}_${_pwpn_vname})" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
952e33 |
set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe ${BUILD_TARGET}_${_pwpn_vname})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ "${BUILD}" = "debug" ] \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
&& [ -n "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_DEBUG)" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
952e33 |
set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_DEBUG)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
elif [ "${BUILD}" = "release" ] \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
&& [ -n "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_RELEASE)" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
952e33 |
set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_RELEASE)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
elif [ -n "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname})" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
952e33 |
set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done; unset _pwpn_vname;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
[ -z "${PKG_FNAME}" ] && PKG_FNAME=${PKG_URL##*/};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
[ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR=${PKG_FNAME%%.tar*};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
[ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
952e33 |
for _pwpn_env_var in $(set); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
952e33 |
if [ "${_pwpn_env_var#PKG_${_pwpn_pkg_name_uc}}" != "${_pwpn_env_var}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_pwpn_env_vars="${_pwpn_env_vars:+${_pwpn_env_vars} }${_pwpn_env_var%%=*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ -n "${_pwpn_env_vars}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_env_vars "build" ${_pwpn_env_vars};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi; unset _pwpn_pkg_name_uc _pwpn_env_var _pwpn_env_vars;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
run_cmd_unsplit() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_rcu_cmd=${1}; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
[ -n "${1}" ] &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_rcu_cmdline="${_rcu_cmdline:+${_rcu_cmdline}:}${1}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
push_IFS :; ${_rcu_cmd} ${_rcu_cmdline}; _rcu_rc=$?; pop_IFS;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
set_build_script_done() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_sbsd_script_fname=${BUILD_PACKAGE_LC};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
while [ $# -ge 1 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
if [ "${1#-}" != "${1}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
secure_rm ${_sbsd_done_fname}.${1#-};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
touch ${_sbsd_done_fname}.${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
log_msg info "Finished build step ${1} of \`${_sbsd_script_fname}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
fi; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done; unset _sbsd_script_fname _sbsd_done_fname;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
set_env_vars_with_sep() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
_sevws_sep=${1}; shift; push_IFS ${_sevws_sep}; set -- ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
export "${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
done; unset _sevws_sep; pop_IFS;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
59765f |
# vim:filetype=sh
|