Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/Tools/scripts/checknewver.sh
18157 views
1
#!/bin/sh
2
#
3
# checknewver
4
# Check for availability of the newest distfiles
5
#
6
# ----------------------------------------------------------------------------
7
# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):
8
# Maxim Sobolev <[email protected]> wrote this file. As long as you retain
9
# this notice you can do whatever you want with this stuff. If we meet some
10
# day, and you think this stuff is worth it, you can buy me a beer in return.
11
#
12
# Maxim Sobolev
13
# ----------------------------------------------------------------------------
14
#
15
# MAINTAINER= [email protected]
16
17
display_warn () {
18
if [ x"${SILENT}" != x"yes" ]; then
19
echo "WARN: ${@}" >&2
20
fi
21
}
22
23
display_err () {
24
if [ x"${SILENT}" != x"yes" ]; then
25
echo "ERROR: ${@}" >&2
26
fi
27
exit 1
28
}
29
30
display_msg () {
31
if [ x"${SILENT}" != x"yes" ]; then
32
echo "${@}" >&2
33
fi
34
}
35
36
while getopts "s" COMMAND_LINE_ARGUMENT ; do
37
case "${COMMAND_LINE_ARGUMENT}" in
38
s)
39
SILENT=yes
40
;;
41
esac
42
done
43
44
if [ x`which ftpls` = x"" ]; then
45
display_err "Couldn't find ftpls program, which is part of" \
46
"ports/ftp/ftpcopy port. Please make sure that it is installed" \
47
"and try again."
48
fi
49
50
if [ ! -e Makefile ]; then
51
display_err "Couldn't find Makefile here."
52
fi
53
54
PORTNAME=`make -V PORTNAME 2>/dev/null`
55
PORTVERSION=`make -V PORTVERSION 2>/dev/null`
56
DISTFILES=`make -V DISTFILES 2>/dev/null`
57
if [ x"${PORTNAME}" = x"" -o x"${PORTVERSION}" = x"" -o x"${DISTFILES}" = x"" ]; then
58
display_err "Either PORTNAME, PORTVERSION or DISTFILES is undefined in Makefile."
59
fi
60
61
MASTER_SITES=`env MASTER_SITE_BACKUP=\"\" make master-sites-all 2>/dev/null | xargs -n1 echo | grep ^ftp://`
62
if [ x"${MASTER_SITES}" = x"" ]; then
63
display_err "Either MASTER_SITES is undefined in Makefile or it doesn't contain any ftp sites."
64
fi
65
66
display_msg "Checking for updated version of ${PORTNAME}..."
67
PV_PATR=`echo ${PORTVERSION} | sed 's=\.=\\\\.=g'`
68
for DISTNAME in ${DISTFILES}; do
69
DF_PATR=`echo ${DISTNAME} | sed "s=${PV_PATR}=.*=" | \
70
sed 's=\.=\\\\.=g ; s=\\\.\*=.*='`
71
DF_CHECK=`echo ${DISTNAME} | sed 's=\.=\\\\.=g'`
72
if [ x"${DF_PATR}" = x"${DF_CHECK}" ]; then
73
display_warn "Couldn't construct searching pattern - ${DISTNAME} ignored."
74
else
75
DF_PATRNS="${DF_PATRNS} ${DF_PATR}"
76
F_DISTFILES="${F_DISTFILES} ${DISTNAME}"
77
fi
78
done
79
80
if [ x"${F_DISTFILES}" = x"" ]; then
81
display_warn "Nothing to check - exiting."
82
exit 0
83
fi
84
85
DISTFILES="${F_DISTFILES}"
86
87
for MASTER_SITE in ${MASTER_SITES}; do
88
display_msg "...checking ${MASTER_SITE}"
89
FTPLIST=`ftpls ${MASTER_SITE} 2>/dev/null | grep -v ^dir | awk '{print $6}'`
90
for DISTNAME in ${DISTFILES}; do
91
DF_PATR=`echo ${DISTNAME} | sed "s=${PV_PATR}=.*=" | \
92
sed 's=\.=\\\\.=g ; s=\\\.\*=.*='`
93
for i in `echo ${FTPLIST} | xargs -n1 echo | grep "${DF_PATR}$"` ; do
94
if [ "${i}" ">" "${DISTNAME}" ]; then
95
NEW="${NEW} ${MASTER_SITE}${i}"
96
fi
97
done
98
done
99
done
100
101
if [ x"${NEW}" != x"" ]; then
102
display_msg ""
103
display_msg "Hmm, is seems that there is a newer version(s) at:"
104
echo "${NEW}" | xargs -n1 echo
105
display_msg ""
106
fi
107
108