Path: blob/main/Tools/scripts/checknewver.sh
16462 views
#!/bin/sh1#2# checknewver3# Check for availability of the newest distfiles4#5# ----------------------------------------------------------------------------6# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):7# Maxim Sobolev <[email protected]> wrote this file. As long as you retain8# this notice you can do whatever you want with this stuff. If we meet some9# day, and you think this stuff is worth it, you can buy me a beer in return.10#11# Maxim Sobolev12# ----------------------------------------------------------------------------13#14# MAINTAINER= [email protected]1516display_warn () {17if [ x"${SILENT}" != x"yes" ]; then18echo "WARN: ${@}" >&219fi20}2122display_err () {23if [ x"${SILENT}" != x"yes" ]; then24echo "ERROR: ${@}" >&225fi26exit 127}2829display_msg () {30if [ x"${SILENT}" != x"yes" ]; then31echo "${@}" >&232fi33}3435while getopts "s" COMMAND_LINE_ARGUMENT ; do36case "${COMMAND_LINE_ARGUMENT}" in37s)38SILENT=yes39;;40esac41done4243if [ x`which ftpls` = x"" ]; then44display_err "Couldn't find ftpls program, which is part of" \45"ports/ftp/ftpcopy port. Please make sure that it is installed" \46"and try again."47fi4849if [ ! -e Makefile ]; then50display_err "Couldn't find Makefile here."51fi5253PORTNAME=`make -V PORTNAME 2>/dev/null`54PORTVERSION=`make -V PORTVERSION 2>/dev/null`55DISTFILES=`make -V DISTFILES 2>/dev/null`56if [ x"${PORTNAME}" = x"" -o x"${PORTVERSION}" = x"" -o x"${DISTFILES}" = x"" ]; then57display_err "Either PORTNAME, PORTVERSION or DISTFILES is undefined in Makefile."58fi5960MASTER_SITES=`env MASTER_SITE_BACKUP=\"\" make master-sites-all 2>/dev/null | xargs -n1 echo | grep ^ftp://`61if [ x"${MASTER_SITES}" = x"" ]; then62display_err "Either MASTER_SITES is undefined in Makefile or it doesn't contain any ftp sites."63fi6465display_msg "Checking for updated version of ${PORTNAME}..."66PV_PATR=`echo ${PORTVERSION} | sed 's=\.=\\\\.=g'`67for DISTNAME in ${DISTFILES}; do68DF_PATR=`echo ${DISTNAME} | sed "s=${PV_PATR}=.*=" | \69sed 's=\.=\\\\.=g ; s=\\\.\*=.*='`70DF_CHECK=`echo ${DISTNAME} | sed 's=\.=\\\\.=g'`71if [ x"${DF_PATR}" = x"${DF_CHECK}" ]; then72display_warn "Couldn't construct searching pattern - ${DISTNAME} ignored."73else74DF_PATRNS="${DF_PATRNS} ${DF_PATR}"75F_DISTFILES="${F_DISTFILES} ${DISTNAME}"76fi77done7879if [ x"${F_DISTFILES}" = x"" ]; then80display_warn "Nothing to check - exiting."81exit 082fi8384DISTFILES="${F_DISTFILES}"8586for MASTER_SITE in ${MASTER_SITES}; do87display_msg "...checking ${MASTER_SITE}"88FTPLIST=`ftpls ${MASTER_SITE} 2>/dev/null | grep -v ^dir | awk '{print $6}'`89for DISTNAME in ${DISTFILES}; do90DF_PATR=`echo ${DISTNAME} | sed "s=${PV_PATR}=.*=" | \91sed 's=\.=\\\\.=g ; s=\\\.\*=.*='`92for i in `echo ${FTPLIST} | xargs -n1 echo | grep "${DF_PATR}$"` ; do93if [ "${i}" ">" "${DISTNAME}" ]; then94NEW="${NEW} ${MASTER_SITE}${i}"95fi96done97done98done99100if [ x"${NEW}" != x"" ]; then101display_msg ""102display_msg "Hmm, is seems that there is a newer version(s) at:"103echo "${NEW}" | xargs -n1 echo104display_msg ""105fi106107108