summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh19
-rw-r--r--etc/build.usage7
-rw-r--r--subr/check_updates.subr77
-rw-r--r--vars/build.vars3
4 files changed, 101 insertions, 5 deletions
diff --git a/build.sh b/build.sh
index 694ac0aa..e649295c 100755
--- a/build.sh
+++ b/build.sh
@@ -14,6 +14,7 @@ check_cpuinfo;
while [ ${#} -gt 0 ]; do
case ${1} in
-c) ARG_CLEAN=1; ;;
+-C) ARG_CHECK_UPDATES=1; ;;
-n) ARG_DRYRUN=1 ARG_VERBOSE=1; ;;
-N) ARG_OFFLINE=1; ;;
-t*) ARG_TARBALL=1; [ "${1#-t.}" != "${1}" ] && TARBALL_SUFFIX=${1#-t.}; ;;
@@ -62,7 +63,23 @@ for BUILD_TARGET_LC in $(subst_tgts ${BUILD_TARGETS_META}); do
fi;
: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
fi;
- elif is_build_script_done finish "${BUILD_PACKAGE_LC}"; then
+ fi;
+ if [ ${ARG_CHECK_UPDATES:-0} -eq 1 ]\
+ && [ "${BUILD_PACKAGE#*.*}" = "${BUILD_PACKAGE}" ]; then
+ if [ ${ARG_DRYRUN:-0} -eq 1 ]; then
+ echo check_pkg_updates "${BUILD_PACKAGE_LC}" \
+ "$(get_var_unsafe PKG_${BUILD_PACKAGE}_VERSION)" \
+ "$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL)" \
+ "$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL_TYPE)";
+ else
+ check_pkg_updates "${BUILD_PACKAGE_LC}" \
+ "$(get_var_unsafe PKG_${BUILD_PACKAGE}_VERSION)" \
+ "$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL)" \
+ "$(get_var_unsafe PKG_${BUILD_PACKAGE}_URL_TYPE)";
+ fi;
+ 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;
diff --git a/etc/build.usage b/etc/build.usage
index ecfd16ba..9fd45407 100644
--- a/etc/build.usage
+++ b/etc/build.usage
@@ -1,11 +1,12 @@
-usage: ./build.sh [-x] [-a nt32|nt64] [-b debug|release] [-c] [-h] [-n]
- [-N] [-r package[,...][:step]] [-t[.gz|.bz2|.xz] [-v]
- [<target>[ ...]]
+usage: ./build.sh [-x] [-a nt32|nt64] [-b debug|release] [-c] [-C] [-h]
+ [-n] [-N] [-r package[,...][:step]] [-t[.gz|.bz2|.xz]
+ [-v] [<target>[ ...]]
-x Set the xtrace sh(1)ell option for debugging purposes.
-a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64.
-b debug|release Selects debug or release build; defaults to debug.
This currently only controls CFLAGS.
-c Clean ${PREFIX} before processing build scripts.
+ -C Check package(s) for updates upstream.
-h Show this screen.
-n Perform dry run.
-N Offline mode: no {wget,git-{clone,pull}}(1) calls.
diff --git a/subr/check_updates.subr b/subr/check_updates.subr
new file mode 100644
index 00000000..8122624a
--- /dev/null
+++ b/subr/check_updates.subr
@@ -0,0 +1,77 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+# 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}.)";
+ fi;
+ 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;
+ 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.)";
+ 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}")"
+ 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;
+ 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;
+ fi;
+ done;
+ if [ -z "${_cnpv_versions}" ]; then
+ log_msg warn "No versions available for \`${_cnpv_name}' (URL: ${_cnpv_url}).";
+ else
+ _cnpv_versions="$(echo "${_cnpv_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}.";
+ else
+ log_msg info "${_cnpv_name} v${_cnpv_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;
+};
+
+# vim:filetype=sh
diff --git a/vars/build.vars b/vars/build.vars
index 1088340a..aded37ab 100644
--- a/vars/build.vars
+++ b/vars/build.vars
@@ -40,11 +40,12 @@ fi;
: ${BUILD_LOG_FNAME:=${PREFIX}/build.log};
: ${BUILD_LOG_LAST_FNAME:=${PREFIX}/build.log.last};
: ${BUILD_STATUS_IN_PROGRESS_FNAME:=${PREFIX}/BUILD_IN_PROGRESS};
-: ${CHECK_PREREQ_CMDS:="aclocal autoconf autopoint awk basename bunzip2 find flex gcc git groff gunzip install ld libtool lzma make makeinfo msgfmt nl nroff openssl patch python sed sha256sum sort tar tee tic tr uname wget xz"};
+: ${CHECK_PREREQ_CMDS:="aclocal autoconf autopoint awk basename bunzip2 find flex gcc git groff gunzip install ld libtool lzma make makeinfo msgfmt nl nroff openssl paste patch python sed sha256sum sort tar tee tic tr uname wget xz"};
: ${CHECK_PREREQ_FILES:="/usr/include/gmpxx.h /usr/include/mpc.h /usr/include/mpfr.h"};
: ${CHECK_PREREQ_FILES_DYNAMIC:='/usr/share/groff/$(groff -v 2>/dev/null | awk '\''/^GNU groff version /{print $NF}'\'')/tmac/e.tmac'};
: ${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"};
: ${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}};