summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-11-17 17:27:26 +0100
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-11-17 19:39:10 +0100
commit02175d8ad5011d39d1364c1214bb4353d6d87c55 (patch)
tree7ee7084cc9b61fb83358a30c58b880043920aad1
parent47c5cde0345cac95fddf57ddf806c41004be9c9d (diff)
downloadmidipix_build-02175d8ad5011d39d1364c1214bb4353d6d87c55.tar.bz2
midipix_build-02175d8ad5011d39d1364c1214bb4353d6d87c55.tar.xz
subr/check_updates.subr: support https?://github.com/<uname>/<pname>/...-style ${PKG_URL}s; general cleanup.
-rwxr-xr-xbuild.sh12
-rw-r--r--subr/check_updates.subr120
-rw-r--r--subr/rtl.subr15
-rw-r--r--subr/strip.subr4
-rw-r--r--vars/build.vars1
5 files changed, 79 insertions, 73 deletions
diff --git a/build.sh b/build.sh
index e649295c..108d1c7d 100755
--- a/build.sh
+++ b/build.sh
@@ -58,9 +58,7 @@ for BUILD_TARGET_LC in $(subst_tgts ${BUILD_TARGETS_META}); do
BUILD_PACKAGE=$(echo ${BUILD_PACKAGE_LC} | tr a-z A-Z);
if [ -n "${ARG_RESTART}" ]; then
if ! match_list ${ARG_RESTART} , ${BUILD_PACKAGE_LC}; then
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg info "Skipped \`${BUILD_PACKAGE_LC}' (-r specified.)";
- fi;
+ log_msg vnfo "Skipped \`${BUILD_PACKAGE_LC}' (-r specified.)";
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
fi;
fi;
@@ -80,9 +78,7 @@ for BUILD_TARGET_LC in $(subst_tgts ${BUILD_TARGETS_META}); do
continue;
fi;
if is_build_script_done finish "${BUILD_PACKAGE_LC}"; then
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg info "Skipped \`${BUILD_PACKAGE_LC}' (already built.)";
- fi;
+ log_msg vnfo "Skipped \`${BUILD_PACKAGE_LC}' (already built.)";
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
fi;
if [ -e build/${BUILD_PACKAGE_LC}.build ]; then
@@ -90,9 +86,7 @@ for BUILD_TARGET_LC in $(subst_tgts ${BUILD_TARGETS_META}); do
else
BUILD_SCRIPT_FNAME=build/pkg.build;
fi;
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg info "Invoking build script \`${BUILD_SCRIPT_FNAME}'${ARG_RESTART:+ (forcibly)} for package \`${BUILD_PACKAGE_LC}'.";
- fi;
+ log_msg vnfo "Invoking build script \`${BUILD_SCRIPT_FNAME}'${ARG_RESTART:+ (forcibly)} for package \`${BUILD_PACKAGE_LC}'.";
(set -o errexit -o noglob;
MIDIPIX_BUILD_PWD=$(pwd); PKG_BUILD=${BUILD}; PKG_TARGET=${TARGET};
PKG_PREFIX=$(get_vars_unsafe ${BUILD_TARGET}_PREFIX \
diff --git a/subr/check_updates.subr b/subr/check_updates.subr
index 8122624a..62f3c53c 100644
--- a/subr/check_updates.subr
+++ b/subr/check_updates.subr
@@ -3,75 +3,85 @@
# See warning at the top of build.vars.
#
-check_pkg_updates() {
- _cnpv_name="${1}"; _cnpv_version="${2}"; _cnpv_url="${3}"; _cnpv_url_type="${4}";
- if match_list "${CHECK_UPDATES_SKIP}" " " "${_cnpv_name}"; then
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg info "Skipping \`${_cnpv_name}' (set in \${CHECK_UPDATES_SKIP}.)";
+cpu_get_fnames() {
+ case "${cu_url}" in
+ *://github.com/*)
+ _cpugf_uname="${cu_url#*/github.com/}";
+ _cpugf_uname="${_cpugf_uname%%/*}";
+ _cpugf_pname="${cu_url#*/github.com/${_cpu_uname}/}";
+ _cpugf_pname="${_cpugf_pname%%/*}";
+ cu_url_index="https://github.com/${_cpugf_uname%%/*}/${_cpugf_pname%%/*}/releases/";
+ unset _cpu_uname _cpu_pname;
+ cu_fnames="$(wget ${WGET_ARGS} -qO- ${cu_url_index} |\
+ sed -n '/<span class="tag-name">/s/^.*<span class="tag-name">\([a-zA-Z]\+-\|v\|\)\(.\+\)<\/span>.*$/\2/p')";
+ cu_fname_base="${cu_name}";
+ cu_fname_ext="${cu_fname#v${cu_version}.}";
+ ;;
+ *)
+ cu_url_index="${cu_url%/*}/";
+ cu_fnames="$(wget ${WGET_ARGS} -qO- "${cu_url_index}" |\
+ sed -n '/href="[^"]\+"/s/^.*href="\([^"]\+\)".*$/\1/p')";
+ ;;
+ esac;
+ : ${cu_fname:="${cu_url##*/}"};
+ : ${cu_fname_base:="${cu_fname%%-*}"};
+ : ${cu_fname_ext:="${cu_fname#${cu_fname_base}-${cu_version}.}"};
+};
+
+cpu_get_version() {
+ case "${cu_url}" in
+ *://github.com/*)
+ cu_fname_version="${cu_fname}"; ;;
+ *) if ! [ "${cu_fname#${cu_fname_base}-}" = "${cu_fname}" ]\
+ && ! [ "${cu_fname%.${cu_fname_ext}}" = "${cu_fname}" ]; then
+ cu_fname_version="${cu_fname#${cu_fname_base}-}";
+ cu_fname_version="${cu_fname_version%.${cu_fname_ext}}";
fi;
+ ;;
+ esac;
+};
+
+check_pkg_updates() {
+ cu_name="${1}"; cu_version="${2}"; cu_url="${3}"; cu_url_type="${4}";
+ if match_list "${CHECK_UPDATES_SKIP}" " " "${cu_name}"; then
+ log_msg vnfo "Skipping \`${cu_name}' (set in \${CHECK_UPDATES_SKIP}.)";
return 0;
- elif [ "${_cnpv_url_type}" = "git" ]; then
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg info "Skipping \`${_cnpv_name}' (URL_TYPE is Git.)";
- fi;
+ elif [ "${cu_url_type}" = "git" ]; then
+ log_msg vnfo "Skipping \`${cu_name}' (URL_TYPE is Git.)";
return 0;
- elif [ -z "${_cnpv_version}" -o -z "${_cnpv_url}" ]; then
- log_msg fail "Zero-length \${_cnpv_version} and/or \${_cnpv_url} for \`${_cnpv_name}' (ignored.)";
+ elif [ -z "${cu_version}" -o -z "${cu_url}" ]; then
+ log_msg fail "Zero-length \${cu_version} and/or \${cu_url} for \`${cu_name}' (ignored.)";
return 0;
else
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg info "Checking ${_cnpv_name} v${_cnpv_version} for updates.";
- fi;
- _cnpv_url_base="${_cnpv_url%/*}/"
- _cnpv_url_fname="${_cnpv_url#${_cnpv_url_base}}";
- _cnpv_url_fname_base="${_cnpv_url_fname%%-*}";
- _cnpv_url_fname_ext="${_cnpv_url_fname#${_cnpv_url_fname_base}-${_cnpv_version}.}";
- _cnpv_url_data="$(wget ${WGET_ARGS} -q -O- "${_cnpv_url_base}")"
+ log_msg vnfo "Checking ${cu_name} v${cu_version} for updates.";
+ cpu_get_fnames; _cpu_versions="";
fi;
- _cnpv_versions="";
- for _cnpv_fname in $(echo "${_cnpv_url_data}" |\
- sed -n '/href="[^"]\+"/s/^.*href="\([^"]\+\)".*$/\1/p'); do
- _cnpv_fname="${_cnpv_fname##*/}";
- if [ "${_cnpv_fname#${_cnpv_url_fname_base}-}" = "${_cnpv_fname}" ]; then
- continue;
- elif [ "${_cnpv_fname%.${_cnpv_url_fname_ext}}" = "${_cnpv_fname}" ]; then
- continue;
+ for cu_fname in ${cu_fnames}; do
+ cu_fname="${cu_fname##*/}"; cpu_get_version;
+ if [ -z "${cu_fname_version}" ] \
+ || ! echo "${cu_fname_version}" | grep -Eq '^[-_.0-9a-zA-Z]+$' \
+ || echo "${cu_fname_version}" | grep -Eq '^[_.a-zA-Z]+'; then
+ log_msg varn "Skipping \`${cu_fname_version}' (empty/invalid version.)";
else
- _cnpv_fname_version="${_cnpv_fname#${_cnpv_url_fname_base}-}";
- _cnpv_fname_version="${_cnpv_fname_version%.${_cnpv_url_fname_ext}}";
- if [ -z "${_cnpv_fname_version}" ]; then
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg warn "Skipping \`${_cnpv_fname_version}' (empty version.)";
- fi;
- continue;
- elif ! echo "${_cnpv_fname_version}" | grep -Eq '^[_.0-9a-zA-Z]+$' \
- || echo "${_cnpv_fname_version}" | grep -Eq '^[_.a-zA-Z]+$'; then
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- log_msg warn "Skipping \`${_cnpv_fname_version}' (invalid version.)";
- fi;
- continue;
- else
- _cnpv_versions="${_cnpv_versions:+${_cnpv_versions} }${_cnpv_fname_version}";
- fi;
+ _cpu_versions="${_cpu_versions:+${_cpu_versions} }${cu_fname_version}";
fi;
done;
- if [ -z "${_cnpv_versions}" ]; then
- log_msg warn "No versions available for \`${_cnpv_name}' (URL: ${_cnpv_url}).";
+ if [ -z "${_cpu_versions}" ]; then
+ log_msg warn "No versions available for \`${cu_name}' (Filename URL: ${cu_url}, index URL: ${cu_url_index}).";
else
- _cnpv_versions="$(echo "${_cnpv_versions}" |\
+ _cpu_versions="$(echo "${_cpu_versions}" |\
sed 's/ /\n/g' | sort -rV | uniq |\
- head -n3 | paste -d" " -s)";
- if [ "${_cnpv_versions%% *}" != "${_cnpv_version}" ]; then
- log_msg info "New release(s) available for ${_cnpv_name} v${_cnpv_version}: ${_cnpv_versions}.";
+ head -n${CHECK_UPDATES_SHOW_NEW:-6} |\
+ paste -d" " -s)";
+ if [ "${_cpu_versions%% *}" != "${cu_version}" ]; then
+ log_msg info "New release(s) available for ${cu_name} v${cu_version}: ${_cpu_versions}.";
else
- log_msg info "${_cnpv_name} v${_cnpv_version} is up to date.";
+ log_msg vnfo "${cu_name} v${cu_version} is up to date.";
fi;
fi;
- unset _cnpv_versions _cnpv_fname_version _cnpv_fname \
- _cnpv_url_data _cnpv_url_fname_ext \
- _cnpv_url_fname_base _cnpv_url_fname \
- _cnpv_url_base _cnpv_url_type _cnpv_url \
- _cnpv_version _cnpv_name;
+ unset cu_fname cu_fname_base cu_fname_ext cu_fnames cu_fname_version \
+ cu_name cu_url cu_url_fname cu_url_fname_base cu_url_fname_ext \
+ cu_url_index cu_url_type cu_version _cpu_versions;
};
# vim:filetype=sh
diff --git a/subr/rtl.subr b/subr/rtl.subr
index 5d1dd97a..d9ea0823 100644
--- a/subr/rtl.subr
+++ b/subr/rtl.subr
@@ -24,12 +24,18 @@ get_vars_unsafe() {
log_msg() {
_lm_lvl=${1}; shift;
+ if [ "${_lm_lvl#v}" != "${_lm_lvl}" ]\
+ && [ ${ARG_VERBOSE:-0} -eq 0 ]; then
+ return;
+ fi;
case ${_lm_lvl} in
failexit) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
fail) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
info) printf "\033[0m\033[${LOG_MSG_INFO_COLOUR}m"; ;;
+ vnfo) printf "\033[0m\033[${LOG_MSG_INFO_COLOUR}m"; ;;
succ) printf "\033[0m\033[${LOG_MSG_SUCC_COLOUR}m"; ;;
warn) printf "\033[0m\033[${LOG_MSG_WARN_COLOUR}m"; ;;
+ varn) printf "\033[0m\033[${LOG_MSG_WARN_COLOUR}m"; ;;
esac;
if [ $# -gt 1 ]; then
printf "==> %s %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}" "$*";
@@ -43,8 +49,7 @@ insecure_mkdir() {
if [ -z "${1}" ]; then
return 1;
elif [ ! -e "${1}" ]; then
- [ "${ARG_VERBOSE:-0}" -eq 1 ] &&\
- log_msg warn "Making directory \`${1}'.";
+ log_msg varn "Making directory \`${1}'.";
mkdir -p -- "${1}";
fi; shift;
done;
@@ -66,8 +71,7 @@ secure_cd() {
(cd "${1}"; [ "${PWD#${PREFIX_ROOT}}" = "${PWD}" ] &&\
return 1 || return 0);
if [ ${?} -eq 0 ]; then
- [ "${ARG_VERBOSE:-0}" -eq 1 ] &&\
- log_msg warn "Changing working directory to \`${1}'.";
+ log_msg varn "Changing working directory to \`${1}'.";
cd -- "${1}";
else
log_msg failexit "secure_cd() called with pathname \`${1}' not below \${PREFIX_ROOT} (${PREFIX_ROOT}). This is a bug.";
@@ -89,8 +93,7 @@ secure_rm() {
return 1 || return 0);
if [ ${?} -eq 0 ]; then
unset _sr_pname_check;
- [ "${ARG_VERBOSE:-0}" -eq 1 ] &&\
- log_msg warn "Removing directory or file \`${1}'.";
+ log_msg varn "Removing directory or file \`${1}'.";
rm -rf -- "${1}";
else
log_msg failexit "secure_rm() called with pathname \`${1}' not below \${PREFIX_ROOT} (${PREFIX_ROOT}). This is a bug.";
diff --git a/subr/strip.subr b/subr/strip.subr
index c4e17a3e..64060228 100644
--- a/subr/strip.subr
+++ b/subr/strip.subr
@@ -7,9 +7,7 @@ do_strip() {
&& [ "${BUILD}" = release ]; then
for __ in $(find ${PREFIX_NATIVE}/bin -perm -0100 \( -type f -or -type l \)); do
if objdump -sj .debug_info >/dev/null 2>&1; then
- if [ ${ARG_VERBOSE:-0} -eq 1 ]; then
- echo ${PKG_TARGET}-strip ${__};
- fi;
+ log_msg vnfo "${PKG_TARGET}-strip ${__}";
set +o errexit; ${PKG_TARGET}-strip ${__}; set -o errexit;
fi;
done;
diff --git a/vars/build.vars b/vars/build.vars
index aded37ab..26081da7 100644
--- a/vars/build.vars
+++ b/vars/build.vars
@@ -46,6 +46,7 @@ fi;
: ${CHECK_PREREQ_PERL_MODULES:="autodie ExtUtils::MakeMaker"};
: ${CHECK_PATH_VARS:="PREFIX PREFIX_NATIVE PREFIX_CROSS DLCACHEDIR WORKDIR"};
: ${CHECK_UPDATES_SKIP:="psxtypes pemagine dalist ntcon ntapi psxscl psxscl_strace ntctty ptycon"};
+: ${CHECK_UPDATES_SHOW_NEW:=6};
: ${CLEAR_ENV_VARS_EXCEPT:="ARG_TARBALL ARG_VERBOSE HOME PATH SHELL TERM USER"};
: ${CLEAR_PREFIX_DIRS:="bin i686-nt32-midipix include lib lib64 libexec minipix native share tmp x86_64-nt64-midipix"};
: ${DEFAULT_MAKEFLAGS_BUILD:=-j${BUILD_CPUS:=1}};