|
Lucio Andrés Illanes Albornoz (arab, vxp) |
6e940c |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# . ./build.vars and set -o errexit -o noglob 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) |
090fd4 |
get_var_unsafe() { eval echo \${${1}}; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
090fd4 |
set_var_unsafe() { eval ${1}=\"${2}\"; };
|
|
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) |
820be1 |
compare_hash() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# Push the output of dgst(1SSL) and the caller-supplied hash
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# value to compare the former with on the pseudo-stack and
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# shift off# all but the last two positional parameters.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# This corresponds to the hash output and caller-supplied
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# hash values.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
set -- $(openssl dgst -sha256 ${1}) ${2}; shift $((${#}-2));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ "${1}" = "${2}" ] || echo "${1}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b94746 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
b94746 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
# N.B. URLs ($1) may contain `?' or '&' characters.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fetch() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
_f_url="${1}"; _f_sha256sum_src="${2}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
_f_url_dst="${DLCACHEDIR}/$(basename "${_f_url}")";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
wget ${WGET_ARGS} -c -O ${_f_url_dst} "${_f_url}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -n "${_f_sha256sum_src}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
_f_sha256sum_dst="$(compare_hash ${_f_url_dst} ${_f_sha256sum_src})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -n "${_f_sha256sum_dst}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
set -- "${_f_url}" ${_f_sha256sum_dst} ${_f_sha256sum_src};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
unset _f_url _f_url_dst _f_sha256sum_src _f_sha256sum_dst;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_msg failexit "Error: hash mismatch for URL \`${1}' (is: ${2}, should be: ${3}.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi; unset _f_sha256sum_dst;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi; unset _f_url _f_url_dst _f_sha256sum_src;
|
|
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) |
3243be |
[ -z "${1}" ] && return 1;
|
|
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) |
3243be |
insert_build_script_link() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
_ibsl_fname=${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
_ibsl_level=${_ibsl_fname%%.*};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
_ibsl_name=${_ibsl_fname#*.}; _ibsl_name=${_ibsl_name%.build};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
if [ -z "${_ibsl_fname}" -o -z "${_ibsl_level}" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
-o -z "${_ibsl_name}" ] \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
|| ! isnumber ${_ibsl_level} \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
|| [ ${#_ibsl_level} != 3 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
log_msg failexit "Error: invalid or empty build script filename/level/name.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
cb0470 |
elif [ -e ${_ibsl_fname} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
cb0470 |
log_msg failexit "Error: build script \`${_ibsl_fname}' already exists.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
elif [ -z "$(find -maxdepth 1 -name ${_ibsl_level}.\* -printf '%P\n' -quit)" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
echo ln -s -- pkg.build ${_ibsl_fname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
ln -s -- pkg.build ${_ibsl_fname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
unset _ibsl_fname _ibsl_level _ibsl_name;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
_ibsl_levels="$(find -maxdepth 1 -name \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
${_ibsl_level%[0-9][0-9]}\[0-9\]\[0-9\].\* \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
-printf '%P\n' | sort -nk1)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
for _ibsl_fname_cur in ${_ibsl_levels}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
if [ \( ${_ibsl_changed:=0} -eq 0 \) -a \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
\( "${_ibsl_fname_cur%%.*}" -eq ${_ibsl_level} \) ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
echo ln -s -- pkg.build ${_ibsl_fname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
ln -s -- pkg.build ${_ibsl_fname};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
_ibsl_changed=1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
if [ ${_ibsl_changed:=0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
if [ -z "$(find -maxdepth 1 -name $((${_ibsl_fname_cur%%.*}+1)).\* \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
-printf '%P\n' -quit)" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
_ibsl_last=1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
echo mv -- ${_ibsl_fname_cur} \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
$((${_ibsl_fname_cur%%.*}+1)).${_ibsl_fname_cur#*.};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
mv -- ${_ibsl_fname_cur} \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
$((${_ibsl_fname_cur%%.*}+1)).${_ibsl_fname_cur#*.};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
if [ ${_ibsl_last:-0} -eq 1 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
break;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
if [ ${_ibsl_changed:=0} -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
log_msg failexit "Error: build level ${_ibsl_level} not in \`${_ibsl_levels}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
unset _ibsl_levels _ibsl_fname_cur _ibsl_changed _ibsl_last;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
unset _ibsl_fname _ibsl_level _ibsl_name;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
isnumber() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
[ -z "${1}" ] && return 1 || _i_num=${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
while [ -n "${_i_num}" ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
if [ "${_i_num#[0-9]}" = "${_i_num}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
return 1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
_i_num="${_i_num#[0-9]}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
done; unset _i_num; return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
|
|
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) |
820be1 |
elif [ -f "${WORKDIR}/.${2:-$(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) |
820be1 |
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) |
820be1 |
_pwpn_pkg_NAME=$(echo ${PKG_NAME} | tr a-z A-Z);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_NAME}_URL)" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
unset _pwpn_pkg_NAME;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
for _pwpn_vname in ${PKG_BUILD_VARS}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -n "$(get_var_unsafe DEFAULT_${_pwpn_vname})" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
export "PKG_${_pwpn_vname}=$(get_var_unsafe DEFAULT_${_pwpn_vname})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -n "$(get_var_unsafe PKG_LVL${PKG_LVL}_${_pwpn_vname})" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
export "PKG_${_pwpn_vname}=$(get_var_unsafe PKG_LVL${PKG_LVL}_${_pwpn_vname})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -n "$(get_var_unsafe PKG_${_pwpn_pkg_NAME}_${_pwpn_vname})" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
export "PKG_${_pwpn_vname}=$(get_var_unsafe PKG_${_pwpn_pkg_NAME}_${_pwpn_vname})";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
done; unset _pwpn_vname;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ -z "${PKG_FNAME}" ] && PKG_FNAME=${PKG_URL##*/};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR=${PKG_FNAME%%.tar*};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
for _pwpn_env_var in $(export); do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ "${_pwpn_env_var#PKG_}" != "${_pwpn_env_var}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
_pwpn_env_vars="${_pwpn_env_vars:+${_pwpn_env_vars} }${_pwpn_env_var%%=*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
3243be |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -n "${_pwpn_env_vars}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_env_vars "build script" ${_pwpn_env_vars};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi; unset _pwpn_pkg_NAME _pwpn_env_var _pwpn_env_vars;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
set_env_vars_with_sep() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
_sevws_sep=${1}; shift; push_IFS ${_sevws_sep}; set -- ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
export "${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
done; unset _sevws_sep; pop_IFS;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
rm_if_exists() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ -z "${1#-m}" ] && { _rie_arg_m=1; shift; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ -z "${1#-c}" ] && { _rie_arg_c=1; shift; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ -z "${1}" ] && return 1;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
if [ -d ${1} -o -f ${1} ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_msg warn "Removing directory or file \`${1}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
rm -rf -- ${1};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ ${_rie_arg_m:-0} -eq 1 ] && {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
log_msg warn "Making directory \`${1}'.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
mkdir -- ${1}; unset _rie_arg_m; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ ${_rie_arg_c:-0} -eq 1 ] && { cd ${1}; unset _rie_arg_c; };
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
return 0;
|
|
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) |
820be1 |
set_env_vars() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
_sev_val_new="${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
while [ ${#} -gt 1 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
[ -z "${_sev_val_new}" ] && unset ${1} ||\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
export "${1}=${_sev_val_new}"; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
820be1 |
done; unset _sev_val_new;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
0724e5 |
|
|
lalbornoz |
340f4c |
# vim:filetype=sh
|