|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e940c |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
31dc75 |
# . ./build.vars and set -o errexit are assumed.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# See warning at the top of build.vars.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e940c |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e940c |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
date() { command date +"${1:-${TIMESTAMP_FMT}}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
get_basename() { set -- $(get_name_without_slash ${1}); echo "${1##*/}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
get_var_dyn() { ${1}; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
get_var_unsafe() { eval echo \${${1}}; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
set_var_dyn() { eval ${1}\(\) \{ echo \"${2}\"\; \}; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
set_var_unsafe() { eval ${1}=\"${2}\"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ba5d3 |
get_name_without_slash() { while [ "${1%/}" != ${1} ]; do set -- ${1%/}; done; echo ${1}; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
get_postfix_lrg() { echo "${1##*${2}}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
get_prefix_lrg() { echo "${1%%${2}*}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
get_postfix() { echo "${1#*${2}}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
get_prefix() { echo "${1%${2}*}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ba5d3 |
match_any() { [ "${1#*${2}*}" != "${1}" ]; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
41d5cc |
match_uname_any() { set -- ${1} $(uname -s); [ "${2#*${1}*}" != "${2}" ]; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
push_IFS() { _pI_IFS="${IFS}"; IFS="${1}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
pop_IFS() { IFS="${_pI_IFS}"; unset _pI_IFS; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
set_build_dir() { PKG_BUILD_DIR=${1}-${2}-${TARGET}; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
split() { push_IFS "${1}"; set -- ${2}; pop_IFS; echo "${*}"; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
test_cmd() { command -v "${1}" >/dev/null; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
unsplit() { push_IFS "${1}"; shift; set -- "${@}"; echo "${*}"; pop_IFS; };
|
|
lalbornoz |
340f4c |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
build_times_init() { BUILD_TIMES_SECS=$(command date +%s); };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
build_times_get() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
: $((BUILD_TIMES_SECS=$(command date +%s)-${BUILD_TIMES_SECS}));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
: $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
: $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
: $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
clean_prefix() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
log_msg info "-c specified, cleaning prefix...";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
set -- bin include lib lib64 libexec native share x86_64-nt64-midipix;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
while [ ${#} -gt 0 ]; do rm -rf ${PREFIX}/${1}; shift; done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
7c6f2c |
for _cp_pname in $(find ${PREFIX}/tmp -mindepth 1 -maxdepth 1 -not -iname \*.tar\*) \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
7c6f2c |
$(find ${PREFIX}/tmp -mindepth 1 -maxdepth 1 -type f -iname .\*); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
7c6f2c |
rm_if_exists ${_cp_pname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
done; unset _cp_pname;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b94746 |
clean_build_status() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
95bf77 |
[ "${1}" = abort ] && _cbs_abort=1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b94746 |
set -- BUILD_STATUS_IN_PROGRESS_FNAME BUILD_STATUS_PROGRESS_FNAME BUILD_STATUS_TARBALL_PROGRESS_FNAME;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b94746 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b8dc4b |
rm -f $(get_var_unsafe ${1}); shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
75cb84 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
95bf77 |
if [ ${_cbs_abort:-0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
unset _cbs_abort;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
75cb84 |
touch ${PREFIX}/BUILD_ABORTED_AT_$(date %Y-%m-%d-%H-%M-%S);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
75cb84 |
log_msg fail "Build aborted at $(date %Y-%m-%d-%H-%M-%S).";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
fi; unset _cbs_abort;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b94746 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b94746 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
export_vars_subst() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_evs_pfx=${1}; _evs_pfx_new=${2}; shift 2;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
if [ -n "${_evs_vval:=$(get_var_unsafe ${_evs_pfx}${1})}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
export "${_evs_pfx_new}${1}=${_evs_vval}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
fi; unset _evs_vval; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; unset _evs_pfx _evs_pfx_new;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
fetch_git() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
75cb84 |
[ ${ARG_NO_DOWNLOAD:-0} -eq 1 ] && return;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
75cb84 |
rm_if_exists ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
[ -d ${1} ] && (cd ${1} && git pull origin main)\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
|| git clone ${3} ${2} ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
find_with_no_paths() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
for _fwnp_not_path in ${1}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
_fwnp_args="${_fwnp_args:+${_fwnp_args} }-not -path ./${_fwnp_not_path} -not -path ./${_fwnp_not_path}/*";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
done; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
set -f; find "${@}" ${_fwnp_args}; _rc=${?}; set +f;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
unset _fwnp_args _fwnp_not_path; return ${_rc};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
4e7360 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
rm_if_exists() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
[ -z "${1#-m}" ] && { _rie_arg_m=1; shift; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
[ -z "${1#-c}" ] && { _rie_arg_c=1; shift; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
if [ -d ${1} -o -f ${1} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
log_msg warn "Removing directory or file \`${1}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
if [ ${ARG_PEDANTIC:-0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
printf "Confirm deletion (y|N) ";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
read _rie_prompt; case "${_rie_prompt}" in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
[yY]) rm -rf ${1}; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
*) log_msg warn "Skipping removal of \`${1}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
_rie_arg_m=0; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
esac;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
rm -rf ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
[ ${_rie_arg_m:-0} -eq 1 ] && {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
log_msg warn "Making directory \`${1}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
mkdir ${1}; unset _rie_arg_m; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
[ ${_rie_arg_c:-0} -eq 1 ] && { cd ${1}; unset _rie_arg_c; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
rotate_files() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
set -- $(find ${PREFIX} -mindepth 1 -maxdepth 1 -type f -iname "${1}" |\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
sort | sed -n $((${2}+1)),\$p);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
rm -f "${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
set_env_vars() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_sev_val_new="${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
while [ ${#} -gt 1 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
[ -z "${_sev_val_new}" ] && unset ${1} ||\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
export "${1}=${_sev_val_new}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; unset _sev_val_new;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
50fadd |
set_env_vars_with_sep() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
50fadd |
_sevws_sep=${1}; shift; push_IFS ${_sevws_sep}; set -- ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
50fadd |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
50fadd |
export "${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
50fadd |
done; unset _sevws_sep; pop_IFS;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
50fadd |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
50fadd |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# Download GNU bash-style patch sets into ${2}-patches-extra and
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# apply them to ${2} in the correct order.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
apply_patches() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
(rm_if_exists -m -c ${2}-patches-extra;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
wget -c -nd -np -r -R \*.htm\* -R \*.sig ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
for _ap_patch_fname in \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
$(find . -type f -not -iname \*.sig | sort); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
patch -b -d ../${2} -p0 < ${_ap_patch_fname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; unset _ap_patch_fname);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# Check whether all supplied arguments contain non-empty valid values.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
check_path_vars() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
if [ -z "${_cpv_val:=$(get_var_unsafe "${1}")}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
log_msg failexit "Error: variable \`${1}' is empty or unset.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
elif match_any "${_cpv_val}" " "; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
log_msg failexit "Error: variable \`${1}' contains one or more whitespace characters.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
unset _cpv_val;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# Check whether all supplied command names resolve.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f5eeee |
check_prereqs() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
if ! command -v ${1} >/dev/null; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
log_msg failexit "Error: missing prerequisite command \`${1}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
fi; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f5eeee |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f5eeee |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# Clear the environment by unsetting each exported variable except
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# for those named by the caller.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
clear_env_with_except() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_cewe_vfilter="${*}"; _cewe_unset_cmds="$(mktemp -q)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
export | while read _cewe_vspec; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
set -- ${_cewe_vspec}; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ba5d3 |
[ "${1#*[^\"\'=a-zA-Z0-9_]}" != "${1}" ] && continue;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
if ! match_list "${_cewe_vfilter}" " " \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
$(get_prefix_lrg ${1} =); then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
echo unset $(get_prefix_lrg ${1} =) >> ${_cewe_unset_cmds};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; . "${_cewe_unset_cmds}"; rm -f "${_cewe_unset_cmds}" 2>/dev/null;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
unset _cewe_vfilter _cewe_vspec;
|
|
lalbornoz |
340f4c |
};
|
|
lalbornoz |
340f4c |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a41d08 |
# N.B. URLs ($1) may contain `?' or '&' characters.
|
|
lalbornoz |
340f4c |
fetch() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
75cb84 |
[ ${ARG_NO_DOWNLOAD:-0} -eq 1 ] && return;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
75cb84 |
rm_if_exists $(get_basename ${1});
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
a41d08 |
wget ${WGET_ARGS} "${1}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
if [ ${#} -eq 2 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
set -- $(get_basename ${1}) "$(compare_hash $(get_basename ${1}) ${2})" ${2};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
if [ -n "${2}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
log_msg failexit "Error: hash mismatch for URL \`${1}' (is: ${2}, should be: ${3}.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
fi;
|
|
lalbornoz |
340f4c |
fi;
|
|
lalbornoz |
340f4c |
};
|
|
lalbornoz |
340f4c |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e940c |
compare_hash() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# Push the output of dgst(1SSL) and the caller-supplied hash
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# value to compare the former with on the pseudo-stack and
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# shift off# all but the last two positional parameters.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# This corresponds to the hash output and caller-supplied
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
# hash values.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
set -- $(openssl dgst -sha256 ${1}) ${2}; shift $((${#}-2));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ba5d3 |
[ "${1}" = "${2}" ] || echo "${1}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e940c |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
compare_hash_manifest() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
if ! compare_hash ${1} ${2}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
log_msg failexit "Error: hash mismatch for patch file \`${1}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
fi; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
done; return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f9c386 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e940c |
|
|
lalbornoz |
340f4c |
is_build_script_done() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e48a0 |
if [ -n "${ARG_RESTART_SCRIPT_AT}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
if [ "${1}" = clean ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
&& [ -z "${ARG_RESTART_SCRIPT_AT#ALL}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
return 0; # Skip
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
elif [ "${1}" = finish ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e48a0 |
|| [ -z "${ARG_RESTART_SCRIPT_AT#ALL}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e48a0 |
elif ! match_list ${ARG_RESTART_SCRIPT_AT} , ${1}; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
return 0; # Skip
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
elif [ -f ${WORKDIR}/.${2:-$(get_basename ${SCRIPT_FNAME%.build})}.${1} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
return 0; # Skip
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f5eeee |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
return 1; # Build
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
f5eeee |
fi;
|
|
lalbornoz |
340f4c |
};
|
|
lalbornoz |
340f4c |
set_build_script_done() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_sbsd_script_fname=${SCRIPT_FNAME##*/};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname%.build};
|
|
lalbornoz |
340f4c |
while [ $# -ge 1 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ba5d3 |
if [ "${1#-}" != "${1}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
rm -f ${_sbsd_done_fname}.${1#-};
|
|
lalbornoz |
340f4c |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
touch ${_sbsd_done_fname}.${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
log_msg info "Finished build step ${1} of build script \`${_sbsd_script_fname}'.";
|
|
lalbornoz |
340f4c |
fi; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; unset _sbsd_script_fname _sbsd_done_fname;
|
|
lalbornoz |
340f4c |
};
|
|
lalbornoz |
340f4c |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
log_env_vars() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
log_msg info "Variables for this ${1:-build}:"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
while [ ${_lev_nvar:=0} -lt ${#} ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_lev_arg="$(eval echo \${${_lev_nvar}})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_lev_arg="${_lev_arg%%=*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
if [ ${#_lev_arg} -gt ${_lev_arg_len_max:=0} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_lev_arg_len_max=${#_lev_arg};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
fi; : $((_lev_nvar+=1));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; unset _lev_nvar _lev_arg;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
log_msg info "$(printf \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
"%${_lev_arg_len_max}.${_lev_arg_len_max}s=%s" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
"${1%%=*}" "$(get_var_unsafe ${1#*=})")";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; unset _lev_arg_len_max;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
};
|
|
lalbornoz |
340f4c |
log_msg() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_lm_lvl=${1}; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
case ${_lm_lvl} in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
failexit) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
31dc75 |
fail) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
31dc75 |
info) printf "\033[${LOG_MSG_INFO_COLOUR}m"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
31dc75 |
succ) printf "\033[${LOG_MSG_SUCC_COLOUR}m"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d824e1 |
warn) printf "\033[${LOG_MSG_WARN_COLOUR}m"; ;;
|
|
lalbornoz |
340f4c |
esac;
|
|
lalbornoz |
340f4c |
if [ $# -gt 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
printf "==> %s %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}" "$*";
|
|
lalbornoz |
340f4c |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
d30b8f |
printf "==> %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
fi; [ ${_lm_lvl} = failexit ] && exit 1 || unset _lm_lvl;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
match_list() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_ml_cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ba5d3 |
if [ "${1}" = "${_ml_cmp}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
unset _ml_cmp; return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
fi; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done; unset _ml_cmp; return 1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
1d0876 |
|
|
lalbornoz |
340f4c |
parse_with_pkg_name() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
PKG_LVL=${1}; PKG_NAME=${2}; shift 2;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
while [ ${#} -ge 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9ba5d3 |
if [ "${PKG_NAME}" = ${1} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
export_vars_subst PKG_LVL${PKG_LVL}_ PKG_ ${PKG_BUILD_VARS};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
export_vars_subst PKG_$(echo ${PKG_NAME} | tr a-z A-Z)_ PKG_ ${PKG_BUILD_VARS};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
[ -z "${PKG_URL}" ] && return 1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
[ -z "${PKG_FNAME}" ] && PKG_FNAME=${PKG_URL##*/};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
[ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR=${PKG_FNAME%%.tar*};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
[ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
export PKG_PREFIX=$(get_var_unsafe PREFIX_LVL${PKG_LVL});
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
for _pwpn_env_var in $(export); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
if [ "${_pwpn_env_var#PKG_}" != "${_pwpn_env_var}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
_pwpn_env_vars="${_pwpn_env_vars:+${_pwpn_env_vars} }${_pwpn_env_var%%=*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
if [ -n "${_pwpn_env_vars}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
log_env_vars "build script" ${_pwpn_env_vars};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
fi; unset _pwpn_env_var _pwpn_env_vars;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c49754 |
fi; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c49754 |
done; return 1;
|
|
lalbornoz |
340f4c |
};
|
|
lalbornoz |
340f4c |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
run_cmd_unsplit() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
_rcu_cmd=${1}; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
[ -n "${1}" ] &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
_rcu_cmdline="${_rcu_cmdline:+${_rcu_cmdline}:}${1}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
c288df |
push_IFS :; ${_rcu_cmd} ${_rcu_cmdline}; _rcu_rc=$?; pop_IFS;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
392fef |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
update_build_status() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
case ${1} in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
build_start)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
5bb93b |
if [ -f ${BUILD_STATUS_IN_PROGRESS_FNAME} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
5bb93b |
log_msg failexit "Error: build already in progress.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
5bb93b |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
5bb93b |
touch ${BUILD_STATUS_IN_PROGRESS_FNAME};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
5bb93b |
touch ${BUILD_STATUS_PROGRESS_FNAME:=${PREFIX}/BUILD_STARTED_AT_${BUILD_DATE_START:=$(date %Y-%m-%d-%H-%M-%S)}};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
5bb93b |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
build_finish)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b8dc4b |
if [ -f ${BUILD_STATUS_PROGRESS_FNAME} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b8dc4b |
_ubs_bsp_fname=${BUILD_STATUS_PROGRESS_FNAME};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b8dc4b |
unset BUILD_STATUS_PROGRESS_FNAME;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b8dc4b |
rm -f ${_ubs_bsp_fname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b8dc4b |
unset _ubs_bsp_fname;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b8dc4b |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
touch ${BUILD_STATUS_FINISHED_AT_FNAME:=${PREFIX}/BUILD_FINISHED_AT_$(date ${TIMESTAMP_FMT_STATUS_FILES})};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
rotate_files BUILD_FINISHED_AT_\* 8;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
ln -sf ${BUILD_STATUS_FINISHED_AT_FNAME}\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
${BUILD_STATUS_FINISHED_AT_CURRENT_FNAME}; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
tarball_start)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
rotate_files midipix.\*.tar.bz2 8;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
touch ${BUILD_STATUS_TARBALL_PROGRESS_FNAME:=${PREFIX}/TARBALL_STARTED_AT_$(date ${TIMESTAMP_FMT_STATUS_FILES})};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
tarball_finish)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
[ -f ${BUILD_STATUS_TARBALL_PROGRESS_FNAME} ] &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
rm -f ${BUILD_STATUS_TARBALL_PROGRESS_FNAME}; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
finish)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
[ -f ${BUILD_STATUS_IN_PROGRESS_FNAME} ] &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
esac; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
|
|
lalbornoz |
340f4c |
# vim:filetype=sh
|