|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
# . ./build.vars and set -o errexit -o noglob are assumed.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
# See warning at the top of build.vars.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cpu_get_fnames() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
case "${cu_url}" in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
*://github.com/*)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
_cpugf_uname="${cu_url#*/github.com/}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
_cpugf_uname="${_cpugf_uname%%/*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
_cpugf_pname="${cu_url#*/github.com/${_cpu_uname}/}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
_cpugf_pname="${_cpugf_pname%%/*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_url_index="https://github.com/${_cpugf_uname%%/*}/${_cpugf_pname%%/*}/releases/";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
unset _cpu_uname _cpu_pname;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fnames="$(wget ${WGET_ARGS} -qO- ${cu_url_index} |\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
sed -n '//s/^.*\([a-zA-Z]\+-\|v\|\)\(.\+\)<\/span>.*$/\2/p')";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fname_base="${cu_name}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fname_ext="${cu_fname#v${cu_version}.}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
*)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_url_index="${cu_url%/*}/";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fnames="$(wget ${WGET_ARGS} -qO- "${cu_url_index}" |\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
sed -n '/href="[^"]\+"/s/^.*href="\([^"]\+\)".*$/\1/p')";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
esac;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
: ${cu_fname:="${cu_url##*/}"};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
: ${cu_fname_base:="${cu_fname%%-*}"};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
: ${cu_fname_ext:="${cu_fname#${cu_fname_base}-${cu_version}.}"};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cpu_get_version() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
case "${cu_url}" in
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
*://github.com/*)
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fname_version="${cu_fname}"; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
*) if ! [ "${cu_fname#${cu_fname_base}-}" = "${cu_fname}" ]\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
&& ! [ "${cu_fname%.${cu_fname_ext}}" = "${cu_fname}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fname_version="${cu_fname#${cu_fname_base}-}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fname_version="${cu_fname_version%.${cu_fname_ext}}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
esac;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
check_pkg_updates() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_name="${1}"; cu_version="${2}"; cu_url="${3}"; cu_url_type="${4}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
if match_list "${CHECK_UPDATES_SKIP}" " " "${cu_name}"; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg vnfo "Skipping \`${cu_name}' (set in \${CHECK_UPDATES_SKIP}.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
elif [ "${cu_url_type}" = "git" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg vnfo "Skipping \`${cu_name}' (URL_TYPE is Git.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
elif [ -z "${cu_version}" -o -z "${cu_url}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg fail "Zero-length \${cu_version} and/or \${cu_url} for \`${cu_name}' (ignored.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg vnfo "Checking ${cu_name} v${cu_version} for updates.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cpu_get_fnames; _cpu_versions="";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
for cu_fname in ${cu_fnames}; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_fname="${cu_fname##*/}"; cpu_get_version;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
if [ -z "${cu_fname_version}" ] \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
|| ! echo "${cu_fname_version}" | grep -Eq '^[-_.0-9a-zA-Z]+$' \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
|| echo "${cu_fname_version}" | grep -Eq '^[_.a-zA-Z]+'; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg varn "Skipping \`${cu_fname_version}' (empty/invalid version.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
_cpu_versions="${_cpu_versions:+${_cpu_versions} }${cu_fname_version}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
if [ -z "${_cpu_versions}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg warn "No versions available for \`${cu_name}' (Filename URL: ${cu_url}, index URL: ${cu_url_index}).";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
_cpu_versions="$(echo "${_cpu_versions}" |\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
sed 's/ /\n/g' | sort -rV | uniq |\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
head -n${CHECK_UPDATES_SHOW_NEW:-6} |\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
paste -d" " -s)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
if [ "${_cpu_versions%% *}" != "${cu_version}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg info "New release(s) available for ${cu_name} v${cu_version}: ${_cpu_versions}.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
log_msg vnfo "${cu_name} v${cu_version} is up to date.";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
unset cu_fname cu_fname_base cu_fname_ext cu_fnames cu_fname_version \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_name cu_url cu_url_fname cu_url_fname_base cu_url_fname_ext \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
02175d |
cu_url_index cu_url_type cu_version _cpu_versions;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
47c5cd |
# vim:filetype=sh
|