summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2000-07-10 13:40:08 +0000
committersobomax <sobomax@FreeBSD.org>2000-07-10 13:40:08 +0000
commitc4f718ff0020e81d58a1f488ad31fdb9e7edf049 (patch)
treea546b608cfcfe43110cf798c0599f9df1f69edd6 /Tools
parent657fc5910b406164c37180a2ba2ffb659c635428 (diff)
downloadFreeBSD-ports-c4f718ff0020e81d58a1f488ad31fdb9e7edf049.zip
FreeBSD-ports-c4f718ff0020e81d58a1f488ad31fdb9e7edf049.tar.gz
Add "-s" (silent) option useful for shell scripts.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/checknewver.sh59
1 files changed, 41 insertions, 18 deletions
diff --git a/Tools/scripts/checknewver.sh b/Tools/scripts/checknewver.sh
index e6d061b..6020208 100755
--- a/Tools/scripts/checknewver.sh
+++ b/Tools/scripts/checknewver.sh
@@ -5,7 +5,7 @@
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):
-# Maxim Sobolev <sobomax@altavista.net wrote this file. As long as you retain
+# Maxim Sobolev <sobomax@FreeBSD.org wrote this file. As long as you retain
# this notice you can do whatever you want with this stuff. If we meet some
# day, and you think this stuff is worth it, you can buy me a beer in return.
#
@@ -16,40 +16,63 @@
#
# MAINTAINER= sobomax@FreeBSD.org
-if [ x`which ftpls` = x"" ]; then
- echo -n "ERROR: Couldn't find ftpls program, which is part of " >&2
- echo "ports/ftp/ftpcopy port." >&2
- echo " Please make sure that it is installed and try again." >&2
+display_warn () {
+ if [ x"${SILENT}" != x"yes" ]; then
+ echo "WARN: ${@}" >&2
+ fi
+}
+
+display_err () {
+ if [ x"${SILENT}" != x"yes" ]; then
+ echo "ERROR: ${@}" >&2
+ fi
exit 1
+}
+
+display_msg () {
+ if [ x"${SILENT}" != x"yes" ]; then
+ echo "${@}" >&2
+ fi
+}
+
+while getopts "s" COMMAND_LINE_ARGUMENT ; do
+ case "${COMMAND_LINE_ARGUMENT}" in
+ s)
+ SILENT=yes
+ ;;
+ esac
+done
+
+if [ x`which ftpls` = x"" ]; then
+ display_err "Couldn't find ftpls program, which is part of" \
+ "ports/ftp/ftpcopy port. Please make sure that it is installed" \
+ "and try again."
fi
if [ ! -e Makefile ]; then
- echo "ERROR: Couldn't find Makefile here." >&2
- exit 1
+ display_err "Couldn't find Makefile here."
fi
PORTNAME=`make -V PORTNAME`
PORTVERSION=`make -V PORTVERSION`
DISTFILES=`make -V DISTFILES`
if [ x"${PORTNAME}" = x"" -o x"${PORTVERSION}" = x"" -o x"${DISTFILES}" = x"" ]; then
- echo "ERROR: either PORTNAME, PORTVERSION or DISTFILES is undefined in Makefile." >&2
- exit 1
+ display_err "Either PORTNAME, PORTVERSION or DISTFILES is undefined in Makefile."
fi
MASTER_SITES=`env MASTER_SITE_BACKUP=\"\" make -V MASTER_SITES | xargs -n1 echo | grep ^ftp://`
if [ x"${MASTER_SITES}" = x"" ]; then
- echo "ERROR: either MASTER_SITES is undefined in Makefile or it doesn't contain any ftp sites." >&2
- exit 1
+ display_err "Either MASTER_SITES is undefined in Makefile or it doesn't contain any ftp sites."
fi
-echo "Checking for updated version of ${PORTNAME}..." >&2
+display_msg "Checking for updated version of ${PORTNAME}..."
PV_PATR=`echo ${PORTVERSION} | sed 's=\.=\\\\.=g'`
for DISTNAME in ${DISTFILES}; do
DF_PATR=`echo ${DISTNAME} | sed "s=${PV_PATR}=.*=" | \
sed 's=\.=\\\\.=g ; s=\\\.\*=.*='`
DF_CHECK=`echo ${DISTNAME} | sed 's=\.=\\\\.=g`
if [ x"${DF_PATR}" = x"${DF_CHECK}" ]; then
- echo "WARN: Couldn't construct searching pattern - ${DISTNAME} ignored." >&2
+ display_warn "Couldn't construct searching pattern - ${DISTNAME} ignored."
else
DF_PATRNS="${DF_PATRNS} ${DF_PATR}"
F_DISTFILES="${F_DISTFILES} ${DISTNAME}"
@@ -57,14 +80,14 @@ for DISTNAME in ${DISTFILES}; do
done
if [ x"${F_DISTFILES}" = x"" ]; then
- echo "WARN: Nothing to check - exitting." >&2
+ display_warn "Nothing to check - exitting."
exit 0
fi
DISTFILES="${F_DISTFILES}"
for MASTER_SITE in ${MASTER_SITES}; do
- echo "...checking ${MASTER_SITE}" >&2
+ display_msg "...checking ${MASTER_SITE}"
FTPLIST=`ftpls ${MASTER_SITE} 2>/dev/null | grep -v ^dir | awk '{print $6}'`
for DISTNAME in ${DISTFILES}; do
DF_PATR=`echo ${DISTNAME} | sed "s=${PV_PATR}=.*=" | \
@@ -78,8 +101,8 @@ for MASTER_SITE in ${MASTER_SITES}; do
done
if [ x"${NEW}" != x"" ]; then
- echo ""
- echo "Hmm, is seems that there is newest version(s) at:"
+ display_msg ""
+ display_msg "Hmm, is seems that there is newest version(s) at:"
echo "${NEW}" | xargs -n1 echo
- echo ""
+ display_msg ""
fi
OpenPOWER on IntegriCloud