View | Details | Raw Unified | Return to bug 208916 | Differences between
and this patch

Collapse All | Expand All

(-)Mk/Scripts/check-vulnerable.sh (+35 lines)
Added Link Here
1
#!/bin/sh
2
# $FreeBSD$
3
#
4
# MAINTAINER: portmgr@FreeBSD.org
5
6
set -e
7
8
. "${dp_SCRIPTSDIR}/functions.sh"
9
10
validate_env dp_ECHO_MSG dp_PKG_BIN dp_PORTNAME
11
12
set -u
13
14
# If the package is pkg, disable these checks, it fails while
15
# upgrading when pkg is not there.
16
# FIXME: check is this is still true
17
if [ "${dp_PORTNAME}" = "pkg" ]; then
18
	exit 0
19
fi
20
21
if [ -x "${dp_PKG_BIN}" ]; then
22
	vlist=$(${dp_PKG_BIN} audit "${dp_PKGNAME}" || :)
23
	if [ "${vlist}" = "0 problem(s) in the installed packages found." ]; then
24
		vlist=""
25
	fi
26
fi
27
28
if [ -n "$vlist" ]; then
29
	${dp_ECHO_MSG} "===>  ${dp_PKGNAME} has known vulnerabilities:"
30
	${dp_ECHO_MSG} "$vlist"
31
	${dp_ECHO_MSG} "=> Please update your ports tree and try again."
32
	${dp_ECHO_MSG} "=> Note: Vulnerable ports are marked as such even if there is no update available."
33
	${dp_ECHO_MSG} "=> If you wish to ignore this vulnerability rebuild with 'make DISABLE_VULNERABILITIES=yes'"
34
	exit 1
35
fi
(-)Mk/Scripts/checksum.sh (+89 lines)
Added Link Here
1
#!/bin/sh
2
# $FreeBSD$
3
#
4
# MAINTAINER: portmgr@FreeBSD.org
5
6
set -e
7
8
. "${dp_SCRIPTSDIR}/functions.sh"
9
10
validate_env dp_CHECKSUM_ALGORITHMS dp_CURDIR dp_DISTDIR dp_DISTINFO_FILE \
11
	dp_DIST_SUBDIR dp_ECHO_MSG dp_FETCH_REGET dp_MAKE dp_MAKEFLAGS \
12
	dp_DISABLE_SIZE dp_NO_CHECKSUM
13
14
set -u
15
16
check_checksum_algorithms
17
18
if [ -f "${dp_DISTINFO_FILE}" ]; then
19
	cd "${dp_DISTDIR}"
20
	OK=
21
	refetchlist=
22
	for file in "${@}"; do
23
		ignored="true"
24
		for alg in ${dp_CHECKSUM_ALGORITHMS}; do
25
			ignore="false"
26
			eval "alg_executable=\$dp_${alg}"
27
28
			if [ "$alg_executable" != "NO" ]; then
29
				MKSUM=$($alg_executable < "${file}")
30
				CKSUM=$(distinfo_data "${alg}" "${file}")
31
			else
32
				ignore="true"
33
			fi
34
35
			if [ $ignore = "false" -a -z "$CKSUM" ]; then
36
				${dp_ECHO_MSG} "=> No $alg checksum recorded for $file."
37
				ignore="true"
38
			fi
39
40
			if [ $ignore = "false" ]; then
41
				match="false"
42
				for chksum in $CKSUM; do
43
					if [ "$chksum" = "$MKSUM" ]; then
44
						match="true"
45
						break
46
					fi
47
				done
48
				if [ $match = "true" ]; then
49
					${dp_ECHO_MSG} "=> $alg Checksum OK for $file."
50
					ignored="false"
51
				else
52
					${dp_ECHO_MSG} "=> $alg Checksum mismatch for $file."
53
					refetchlist="$refetchlist $file "
54
					OK="${OK:-retry}"
55
					[ "${OK}" = "retry" -a "${dp_FETCH_REGET}" -gt 0 ] && rm -f "${file}"
56
					ignored="false"
57
				fi
58
			fi
59
		done
60
61
		if [ $ignored = "true" ]; then
62
			${dp_ECHO_MSG} "=> No suitable checksum found for $file."
63
			OK=false
64
		fi
65
	done
66
67
	if [ "${OK:=true}" = "retry" ] && [ "${dp_FETCH_REGET}" -gt 0 ]; then
68
		${dp_ECHO_MSG} "===>  Refetch for ${dp_FETCH_REGET} more times files: $refetchlist"
69
		if ${dp_MAKE} -C "${dp_CURDIR}" ${dp_MAKEFLAGS} FORCE_FETCH_LIST="$refetchlist" FETCH_REGET="$((dp_FETCH_REGET - 1))" fetch; then
70
			if ${dp_MAKE} -C "${dp_CURDIR}" ${dp_MAKEFLAGS} FETCH_REGET="$((dp_FETCH_REGET - 1))" checksum ; then
71
			OK="true"
72
			fi
73
		fi
74
	fi
75
76
	if [ "$OK" != "true" -a "${dp_FETCH_REGET}" -eq 0 ]; then
77
		${dp_ECHO_MSG} "===>  Giving up on fetching files: $refetchlist"
78
		${dp_ECHO_MSG} "Make sure the Makefile and distinfo file (${dp_DISTINFO_FILE})"
79
		${dp_ECHO_MSG} "are up to date.  If you are absolutely sure you want to override this"
80
		${dp_ECHO_MSG} "check, type \"make NO_CHECKSUM=yes [other args]\"."
81
		exit 1
82
	fi
83
	if [ "$OK" != "true" ]; then
84
		exit 1
85
	fi
86
elif [ -n "${@}" ]; then
87
	${dp_ECHO_MSG} "=> No checksum file (${DISTINFO_FILE})."
88
	exit 1
89
fi
(-)Mk/Scripts/do-fetch.sh (+148 lines)
Added Link Here
1
#!/bin/sh
2
# $FreeBSD$
3
#
4
# MAINTAINER: portmgr@FreeBSD.org
5
6
set -e
7
8
. "${dp_SCRIPTSDIR}/functions.sh"
9
10
validate_env dp_DISABLE_SIZE dp_DISTDIR dp_DISTINFO_FILE dp_DIST_SUBDIR \
11
	dp_ECHO_MSG dp_FETCH_AFTER_ARGS dp_FETCH_BEFORE_ARGS dp_FETCH_CMD \
12
	dp_FETCH_ENV dp_FORCE_FETCH_ALL dp_FORCE_FETCH_LIST \
13
	dp_MASTER_SITE_BACKUP dp_MASTER_SITE_OVERRIDE dp_MASTER_SORT_AWK \
14
	dp_NO_CHECKSUM dp_RANDOMIZE_SITES dp_SITE_FLAVOR dp_SCRIPTSDIR \
15
	dp_SORTED_MASTER_SITES_DEFAULT_CMD dp_SORTED_PATCH_SITES_DEFAULT_CMD \
16
	dp_TARGET
17
18
set -u
19
20
mkdir -p "${dp_DISTDIR}"
21
cd "${dp_DISTDIR}"
22
23
for _file in "${@}"; do
24
	file=${_file%%:*}
25
26
	# If this files has groups
27
	if [ "$_file" = "$file" ]; then
28
		select=''
29
	else
30
		select=$(echo "${_file##*:}" | sed -e 's/,/ /g')
31
	fi
32
33
	filebasename=${file##*/}
34
	if [ -n "${dp_FORCE_FETCH_ALL}" ]; then
35
		force_fetch=true
36
	else
37
		force_fetch=false
38
		for afile in ${dp_FORCE_FETCH_LIST}; do
39
			afile=${afile##*/}
40
			if [ "x$afile" = "x$filebasename" ]; then
41
				force_fetch=true
42
			fi
43
		done
44
	fi
45
	if [ ! -f "$file" -a ! -f "$filebasename" -o "$force_fetch" = "true" ]; then
46
		full_file="${dp_DIST_SUBDIR:+${dp_DIST_SUBDIR}/}${file}"
47
		if [ -L "$file" -o -L "$filebasename" ]; then
48
			${dp_ECHO_MSG} "=> ${dp_DISTDIR}/$file is a broken symlink."
49
			${dp_ECHO_MSG} "=> Perhaps a filesystem (most likely a CD) isn't mounted?"
50
			${dp_ECHO_MSG} "=> Please correct this problem and try again."
51
			exit 1
52
		fi
53
		if [ -f "${dp_DISTINFO_FILE}" -a -z "${dp_NO_CHECKSUM}" ]; then
54
			_sha256sum=$(distinfo_data SHA256 "${full_file}")
55
			if [ -z "$_sha256sum" ]; then
56
				${dp_ECHO_MSG} "=> ${dp_DIST_SUBDIR:+$dp_DIST_SUBDIR/}$file is not in ${dp_DISTINFO_FILE}."
57
				${dp_ECHO_MSG} "=> Either ${dp_DISTINFO_FILE} is out of date, or"
58
				${dp_ECHO_MSG} "=> ${dp_DIST_SUBDIR:+$dp_DIST_SUBDIR/}$file is spelled incorrectly."
59
				exit 1
60
			fi
61
		fi
62
		case ${dp_TARGET} in
63
		do-fetch|makesum)
64
			${dp_ECHO_MSG} "=> $file doesn't seem to exist in ${dp_DISTDIR}."
65
			;;
66
		esac
67
		if [ ! -w "${dp_DISTDIR}" ]; then
68
			${dp_ECHO_MSG} "=> ${dp_DISTDIR} is not writable by you; cannot fetch."
69
			exit 1
70
		fi
71
		if [ -n "$select" ] ; then
72
			__MASTER_SITES_TMP=
73
			for group in $select; do
74
				eval ___MASTER_SITES_TMP="\${_${dp_SITE_FLAVOR}_SITES_${group}}"
75
				if [ -n "${___MASTER_SITES_TMP}" ] ; then
76
					__MASTER_SITES_TMP="${__MASTER_SITES_TMP} ${___MASTER_SITES_TMP}"
77
				fi
78
			done
79
			___MASTER_SITES_TMP=
80
			SORTED_MASTER_SITES_CMD_TMP="echo ${dp_MASTER_SITE_OVERRIDE} $(echo -n "${__MASTER_SITES_TMP}" | awk "${dp_MASTER_SORT_AWK}") ${dp_MASTER_SITE_BACKUP}"
81
		else
82
			if [ ${dp_SITE_FLAVOR} = "MASTER" ]; then
83
				SORTED_MASTER_SITES_CMD_TMP="${dp_SORTED_MASTER_SITES_DEFAULT_CMD}"
84
			else
85
				SORTED_MASTER_SITES_CMD_TMP="${dp_SORTED_PATCH_SITES_DEFAULT_CMD}"
86
			fi
87
		fi
88
		case ${dp_TARGET} in
89
			fetch-list)
90
				echo -n "mkdir -p ${dp_DISTDIR} && "
91
				echo -n "cd ${dp_DISTDIR} && { "
92
				;;
93
		esac
94
		sites_remaining=0
95
		sites="$(eval "${SORTED_MASTER_SITES_CMD_TMP} ${dp_RANDOMIZE_SITES}")"
96
		for site in ${sites}; do
97
			sites_remaining=$((sites_remaining + 1))
98
		done
99
		for site in ${sites}; do
100
			sites_remaining=$((sites_remaining - 1))
101
			CKSIZE=$(distinfo_data SIZE "${full_file}")
102
			case ${file} in
103
				*/*)
104
					mkdir -p "${file%/*}"
105
					args="-o ${file} ${site}${file}"
106
					;;
107
				*)
108
					args=${site}${file}
109
					;;
110
			esac
111
			_fetch_cmd=$(eval "echo ${dp_FETCH_ENV} ${dp_FETCH_CMD} ${dp_FETCH_BEFORE_ARGS} \\\"${args}\\\" ${dp_FETCH_AFTER_ARGS}")
112
			case ${dp_TARGET} in
113
			do-fetch|makesum)
114
				${dp_ECHO_MSG} "=> Attempting to fetch ${site}${file}"
115
				if eval "env ${_fetch_cmd}"; then
116
					actual_size=$(stat -f %z "${file}")
117
					if [ -n "${dp_DISABLE_SIZE}" ] || [ -z "${CKSIZE}" ] || [ "${actual_size}" -eq "${CKSIZE}" ]; then
118
						continue 2
119
					else
120
						${dp_ECHO_MSG} "=> Fetched file size mismatch (expected ${CKSIZE}, actual ${actual_size})"
121
						if [ ${sites_remaining} -gt 0 ]; then
122
							${dp_ECHO_MSG} "=> Trying next site"
123
							rm -f "${file}"
124
						fi
125
					fi
126
				fi
127
				;;
128
			fetch-list)
129
				echo -n "env ${_fetch_cmd} || "
130
				;;
131
			fetch-url-list-int)
132
				echo "${args}"
133
				;;
134
			esac
135
		done
136
		case ${dp_TARGET} in
137
		do-fetch|makesum)
138
			${dp_ECHO_MSG} "=> Couldn't fetch it - please try to retrieve this"
139
			${dp_ECHO_MSG} "=> port manually into ${dp_DISTDIR} and try again."
140
			exit 1
141
			;;
142
		fetch-list)
143
			echo "echo ${file} not fetched; }" ; \
144
			;;
145
		esac
146
	fi
147
done
148
(-)Mk/Scripts/functions.sh (+28 lines)
Lines 216-218 export_ports_env() { Link Here
216
		fi
216
		fi
217
	done
217
	done
218
}
218
}
219
220
distinfo_data() {
221
	local alg file
222
223
	alg=$1
224
	file=$2
225
226
	if [ \( -n "${dp_DISABLE_SIZE}" -a -n "${dp_NO_CHECKSUM}" \) -o ! -f "${dp_DISTINFO_FILE}" ]; then
227
		exit
228
	fi
229
	awk -v alg="$alg" -v file="${file}" \
230
		'$1 == alg && $2 == "(" file ")" {print $4}' "${dp_DISTINFO_FILE}"
231
}
232
233
check_checksum_algorithms() {
234
	for alg in ${dp_CHECKSUM_ALGORITHMS}; do
235
		eval "alg_executable=\$dp_$alg"
236
		if [ -z "$alg_executable" ]; then
237
			${dp_ECHO_MSG} "Checksum algorithm $alg: Couldn't find the executable."
238
			${dp_ECHO_MSG} "Set $alg=/path/to/$alg in /etc/make.conf and try again."
239
			exit 1
240
		elif [ ! -x "$alg_executable" ]; then
241
			${dp_ECHO_MSG} "Checksum algorithm $alg: $alg_executable is not executable."
242
			${dp_ECHO_MSG} "Fix modes, or change $alg=$alg_executable in /etc/make.conf and try again."
243
			exit 1
244
		fi
245
	done
246
}
(-)Mk/Scripts/makesum.sh (+32 lines)
Added Link Here
1
#!/bin/sh
2
# $FreeBSD$
3
#
4
# MAINTAINER: portmgr@FreeBSD.org
5
6
set -e
7
8
. "${dp_SCRIPTSDIR}/functions.sh"
9
10
validate_env dp_CHECKSUM_ALGORITHMS dp_CKSUMFILES dp_DISTDIR dp_DISTINFO_FILE \
11
	dp_ECHO_MSG
12
13
set -u
14
15
check_checksum_algorithms
16
17
if [ -f "${dp_DISTINFO_FILE}" ]; then
18
	> "${dp_DISTINFO_FILE}"
19
fi
20
21
cd "${dp_DISTDIR}"
22
23
for file in ${dp_CKSUMFILES}; do
24
	for alg in ${dp_CHECKSUM_ALGORITHMS}; do
25
		eval "alg_executable=\$dp_$alg"
26
27
		if [ "$alg_executable" != "NO" ]; then
28
			$alg_executable "$file" >> "${dp_DISTINFO_FILE}"
29
		fi
30
	done
31
	echo "SIZE ($file) = $(stat -f %z "$file")" >> "${dp_DISTINFO_FILE}"
32
done
(-)Mk/bsd.port.mk (-462 / +141 lines)
Lines 3050-3244 check-deprecated: Link Here
3050
AUDITFILE?=		${PKG_DBDIR}/vuln.xml
3050
AUDITFILE?=		${PKG_DBDIR}/vuln.xml
3051
3051
3052
check-vulnerable:
3052
check-vulnerable:
3053
.if !defined(DISABLE_VULNERABILITIES) && !defined(PACKAGE_BUILDING)
3053
.if !defined(DISABLE_VULNERABILITIES) && !defined(PACKAGE_BUILDING) \
3054
	@if [ -f "${AUDITFILE}" ]; then \
3054
		&& exists(${AUDITFILE})
3055
		if [ -x "${PKG_BIN}" ]; then \
3055
	@${SETENV} \
3056
			vlist=`${PKG_BIN} audit "${PKGNAME}" || :`; \
3056
			dp_ECHO_MSG="${ECHO_MSG}" \
3057
			if [ "$${vlist}" = "0 problem(s) in the installed packages found." ]; then \
3057
			dp_PKG_BIN="${PKG_BIN}" \
3058
				vlist=""; \
3058
			dp_PORTNAME="${PORTNAME}" \
3059
			fi; \
3059
			dp_SCRIPTSDIR="${SCRIPTSDIR}" \
3060
		elif [ "${PORTNAME}" = "pkg" ]; then \
3060
			${SH} ${SCRIPTSDIR}/check-vulnerable.sh
3061
			vlist=""; \
3061
.endif
3062
		fi; \
3062
3063
		if [ -n "$$vlist" ]; then \
3063
_DO_FETCH_ENV= \
3064
			${ECHO_MSG} "===>  ${PKGNAME} has known vulnerabilities:"; \
3064
			dp_DISABLE_SIZE='${DISABLE_SIZE}' \
3065
			${ECHO_MSG} "$$vlist"; \
3065
			dp_DISTDIR='${_DISTDIR}' \
3066
			${ECHO_MSG} "=> Please update your ports tree and try again."; \
3066
			dp_DISTINFO_FILE='${DISTINFO_FILE}' \
3067
			${ECHO_MSG} "=> Note: Vulnerable ports are marked as such even if there is no update available."; \
3067
			dp_DIST_SUBDIR='${DIST_SUBDIR}' \
3068
			${ECHO_MSG} "=> If you wish to ignore this vulnerability rebuild with 'make DISABLE_VULNERABILITIES=yes'"; \
3068
			dp_ECHO_MSG='${ECHO_MSG}' \
3069
			exit 1; \
3069
			dp_FETCH_AFTER_ARGS='${FETCH_AFTER_ARGS}' \
3070
		fi; \
3070
			dp_FETCH_BEFORE_ARGS='${FETCH_BEFORE_ARGS}' \
3071
	fi
3071
			dp_FETCH_CMD='${FETCH_CMD}' \
3072
.endif
3072
			dp_FETCH_ENV='${FETCH_ENV}' \
3073
3073
			dp_FORCE_FETCH_ALL='${FORCE_FETCH_ALL}' \
3074
# set alg to any of SIZE, SHA256 (or any other checksum algorithm):
3074
			dp_FORCE_FETCH_LIST='${FORCE_FETCH_LIST}' \
3075
DISTINFO_DATA?=	if [ \( -n "${DISABLE_SIZE}" -a -n "${NO_CHECKSUM}" \) -o ! -f "${DISTINFO_FILE}" ]; then exit; fi; \
3075
			dp_MASTER_SITE_BACKUP='${_MASTER_SITE_BACKUP}' \
3076
	DIR=${DIST_SUBDIR}; ${AWK} -v alg=$$alg -v file=$${DIR:+$$DIR/}$${file}	\
3076
			dp_MASTER_SITE_OVERRIDE='${_MASTER_SITE_OVERRIDE}' \
3077
		'$$1 == alg && $$2 == "(" file ")" {print $$4}' ${DISTINFO_FILE}
3077
			dp_MASTER_SORT_AWK='${MASTER_SORT_AWK}' \
3078
			dp_NO_CHECKSUM='${NO_CHECKSUM}' \
3079
			dp_RANDOMIZE_SITES='${_RANDOMIZE_SITES}' \
3080
			dp_SCRIPTSDIR='${SCRIPTSDIR}' \
3081
			dp_SORTED_MASTER_SITES_DEFAULT_CMD='${SORTED_MASTER_SITES_DEFAULT_CMD}' \
3082
			dp_SORTED_PATCH_SITES_DEFAULT_CMD='${SORTED_PATCH_SITES_DEFAULT_CMD}' \
3083
			dp_TARGET='${.TARGET}'
3078
3084
3079
# Fetch
3085
# Fetch
3080
3086
3081
.if !target(do-fetch)
3087
.if !target(do-fetch)
3082
do-fetch:
3088
do-fetch:
3083
	@${MKDIR} ${_DISTDIR}
3089
.if !empty(DISTFILES)
3084
	@cd ${_DISTDIR};\
3090
	@${SETENV} \
3085
	${_MASTER_SITES_ENV} ; \
3091
			${_DO_FETCH_ENV} ${_MASTER_SITES_ENV} \
3086
	for _file in ${DISTFILES}; do \
3092
			dp_SITE_FLAVOR=MASTER \
3087
		file=$${_file%%:*}; \
3093
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${DISTFILES:C/.*/'&'/}
3088
		if [ $$_file = $$file ]; then	\
3094
.endif
3089
			select='';	\
3090
		else	\
3091
			select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ;	\
3092
		fi;	\
3093
		force_fetch=false; \
3094
		filebasename=$${file##*/}; \
3095
		for afile in ${FORCE_FETCH}; do \
3096
			afile=$${afile##*/}; \
3097
			if [ "x$$afile" = "x$$filebasename" ]; then \
3098
				force_fetch=true; \
3099
			fi; \
3100
		done; \
3101
		if [ ! -f $$file -a ! -f $$filebasename -o "$$force_fetch" = "true" ]; then \
3102
			if [ -L $$file -o -L $$filebasename ]; then \
3103
				${ECHO_MSG} "=> ${_DISTDIR}/$$file is a broken symlink."; \
3104
				${ECHO_MSG} "=> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
3105
				${ECHO_MSG} "=> Please correct this problem and try again."; \
3106
				exit 1; \
3107
			fi; \
3108
			if [ -f ${DISTINFO_FILE} -a "x${NO_CHECKSUM}" = "x" ]; then \
3109
				_sha256sum=`alg=SHA256; ${DISTINFO_DATA}`; \
3110
				if [ -z "$$_sha256sum" ]; then \
3111
					${ECHO_MSG} "=> $${DIR:+$$DIR/}$$file is not in ${DISTINFO_FILE}."; \
3112
					${ECHO_MSG} "=> Either ${DISTINFO_FILE} is out of date, or"; \
3113
					${ECHO_MSG} "=> $${DIR:+$$DIR/}$$file is spelled incorrectly."; \
3114
					exit 1; \
3115
				fi; \
3116
			fi; \
3117
			${ECHO_MSG} "=> $$file doesn't seem to exist in ${_DISTDIR}."; \
3118
			if [ ! -w ${_DISTDIR} ]; then \
3119
			   ${ECHO_MSG} "=> ${_DISTDIR} is not writable by you; cannot fetch."; \
3120
			   exit 1; \
3121
			fi; \
3122
			if [ ! -z "$$select" ] ; then \
3123
				__MASTER_SITES_TMP= ; \
3124
				for group in $$select; do \
3125
					if [ ! -z \$${_MASTER_SITES_$${group}} ] ; then \
3126
						eval ___MASTER_SITES_TMP="\$${_MASTER_SITES_$${group}}" ; \
3127
						__MASTER_SITES_TMP="$${__MASTER_SITES_TMP} $${___MASTER_SITES_TMP}" ; \
3128
					fi; \
3129
				done; \
3130
				___MASTER_SITES_TMP= ; \
3131
				SORTED_MASTER_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__MASTER_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
3132
			else \
3133
				SORTED_MASTER_SITES_CMD_TMP="${SORTED_MASTER_SITES_DEFAULT_CMD}" ; \
3134
			fi; \
3135
			sites_remaining=0; \
3136
			sites="`eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`"; \
3137
			for site in $${sites}; do \
3138
				sites_remaining=$$(($${sites_remaining} + 1)); \
3139
			done; \
3140
			for site in $${sites}; do \
3141
				sites_remaining=$$(($${sites_remaining} - 1)); \
3142
			    ${ECHO_MSG} "=> Attempting to fetch $${site}$${file}"; \
3143
				CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
3144
				case $${file} in \
3145
				*/*)	${MKDIR} $${file%/*}; \
3146
						args="-o $${file} $${site}$${file}";; \
3147
				*)		args=$${site}$${file};; \
3148
				esac; \
3149
				if ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} ${FETCH_AFTER_ARGS}; then \
3150
					actual_size=`stat -f %z "$${file}"`; \
3151
					if [ -n "${DISABLE_SIZE}" ] || [ -z "$${CKSIZE}" ] || [ $${actual_size} -eq $${CKSIZE} ]; then \
3152
						continue 2; \
3153
					else \
3154
						${ECHO_MSG} "=> Fetched file size mismatch (expected $${CKSIZE}, actual $${actual_size})"; \
3155
						if [ $${sites_remaining} -gt 0 ]; then \
3156
							${ECHO_MSG} "=> Trying next site"; \
3157
							${RM} -f $${file}; \
3158
						fi; \
3159
					fi; \
3160
				fi; \
3161
			done; \
3162
			${ECHO_MSG} "=> Couldn't fetch it - please try to retrieve this";\
3163
			${ECHO_MSG} "=> port manually into ${_DISTDIR} and try again."; \
3164
			exit 1; \
3165
	    fi; \
3166
	 done
3167
.if defined(PATCHFILES)
3095
.if defined(PATCHFILES)
3168
	@cd ${_DISTDIR};\
3096
	@${SETENV} \
3169
	${_PATCH_SITES_ENV} ; \
3097
			${_DO_FETCH_ENV} ${_PATCH_SITES_ENV} \
3170
	for _file in ${PATCHFILES}; do \
3098
			dp_SITE_FLAVOR=PATCH \
3171
		file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^-:][^:]*$$//'` ; \
3099
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${PATCHFILES:C/.*/'&'/}
3172
		if [ $$_file = $$file ]; then	\
3100
.endif
3173
			select='';	\
3101
.endif
3174
		else	\
3102
#
3175
			select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ;	\
3103
# Prints out a list of files to fetch (useful to do a batch fetch)
3176
		fi;	\
3104
3177
		file=`${ECHO_CMD} $$file | ${SED} -E -e 's/:-[^:]+$$//'` ; \
3105
.if !target(fetch-list)
3178
		force_fetch=false; \
3106
fetch-list:
3179
		filebasename=$${file##*/}; \
3107
.if !empty(DISTFILES)
3180
		for afile in ${FORCE_FETCH}; do \
3108
	@${SETENV} \
3181
			afile=$${afile##*/}; \
3109
			${_DO_FETCH_ENV} ${_MASTER_SITES_ENV} \
3182
			if [ "x$$afile" = "x$$filebasename" ]; then \
3110
			dp_SITE_FLAVOR=MASTER \
3183
				force_fetch=true; \
3111
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${DISTFILES:C/.*/'&'/}
3184
			fi; \
3112
.endif
3185
		done; \
3113
.if defined(PATCHFILES)
3186
		if [ ! -f $$file -a ! -f $$filebasename -o "$$force_fetch" = "true" ]; then \
3114
	@${SETENV} \
3187
			if [ -L $$file -o -L $${file##*/} ]; then \
3115
			${_DO_FETCH_ENV} ${_PATCH_SITES_ENV} \
3188
				${ECHO_MSG} "=> ${_DISTDIR}/$$file is a broken symlink."; \
3116
			dp_SITE_FLAVOR=PATCH \
3189
				${ECHO_MSG} "=> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
3117
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${PATCHFILES:C/.*/'&'/}
3190
				${ECHO_MSG} "=> Please correct this problem and try again."; \
3118
.endif
3191
				exit 1; \
3192
			fi; \
3193
			${ECHO_MSG} "=> $$file doesn't seem to exist in ${_DISTDIR}."; \
3194
			if [ ! -z "$$select" ] ; then \
3195
				__PATCH_SITES_TMP= ; \
3196
				for group in $$select; do \
3197
					if [ ! -z \$${_PATCH_SITES_$${group}} ] ; then \
3198
						eval ___PATCH_SITES_TMP="\$${_PATCH_SITES_$${group}}" ; \
3199
						__PATCH_SITES_TMP="$${__PATCH_SITES_TMP} $${___PATCH_SITES_TMP}" ; \
3200
					fi; \
3201
				done; \
3202
				___PATCH_SITES_TMP= ; \
3203
				SORTED_PATCH_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__PATCH_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
3204
			else \
3205
				SORTED_PATCH_SITES_CMD_TMP="${SORTED_PATCH_SITES_DEFAULT_CMD}" ; \
3206
			fi; \
3207
			sites_remaining=0; \
3208
			sites="`eval $$SORTED_PATCH_SITES_CMD_TMP`"; \
3209
			for site in $${sites}; do \
3210
				sites_remaining=$$(($${sites_remaining} + 1)); \
3211
			done; \
3212
			for site in $${sites}; do \
3213
				sites_remaining=$$(($${sites_remaining} - 1)); \
3214
			    ${ECHO_MSG} "=> Attempting to fetch $${site}$${file}"; \
3215
				CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
3216
				case $${file} in \
3217
				*/*)	${MKDIR} $${file%/*}; \
3218
						args="-o $${file} $${site}$${file}";; \
3219
				*)		args=$${site}$${file};; \
3220
				esac; \
3221
				if ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} ${FETCH_AFTER_ARGS}; then \
3222
					actual_size=`stat -f %z "$${file}"`; \
3223
					if [ -n "${DISABLE_SIZE}" ] || [ -z "$${CKSIZE}" ] || [ $${actual_size} -eq $${CKSIZE} ]; then \
3224
						continue 2; \
3225
					else \
3226
						${ECHO_MSG} "=> Fetched file size mismatch (expected $${CKSIZE}, actual $${actual_size})"; \
3227
						if [ $${sites_remaining} -gt 1 ]; then \
3228
							${ECHO_MSG} "=> Trying next site"; \
3229
							${RM} -f $${file}; \
3230
						fi; \
3231
					fi; \
3232
				fi; \
3233
			done; \
3234
			${ECHO_MSG} "=> Couldn't fetch it - please try to retrieve this";\
3235
			${ECHO_MSG} "=> port manually into ${_DISTDIR} and try again."; \
3236
			exit 1; \
3237
		fi; \
3238
	 done
3239
.endif
3119
.endif
3120
3121
# Used by fetch-urlall-list and fetch-url-list
3122
3123
.if !target(fetch-url-list-int)
3124
fetch-url-list-int:
3125
.if !empty(DISTFILES)
3126
	@${SETENV} \
3127
			${_DO_FETCH_ENV} ${_MASTER_SITES_ENV} \
3128
			dp_SITE_FLAVOR=MASTER \
3129
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${DISTFILES:C/.*/'&'/}
3130
.endif
3131
.if defined(PATCHFILES)
3132
	@${SETENV} \
3133
			${_DO_FETCH_ENV} ${_PATCH_SITES_ENV} \
3134
			dp_SITE_FLAVOR=PATCH \
3135
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${PATCHFILES:C/.*/'&'/}
3136
.endif
3137
.endif
3138
3139
# Prints out all the URL for all the DISTFILES and PATCHFILES.
3140
3141
.if !target(fetch-urlall-list)
3142
fetch-urlall-list:
3143
	@cd ${.CURDIR} && ${SETENV} FORCE_FETCH_ALL=yes ${MAKE} fetch-url-list-int
3144
.endif
3145
3146
# Prints the URL for all the DISTFILES and PATCHFILES that are not here
3147
3148
.if !target(fetch-url-list)
3149
fetch-url-list: fetch-url-list-int
3240
.endif
3150
.endif
3241
3151
3152
3242
# Extract
3153
# Extract
3243
3154
3244
clean-wrkdir:
3155
clean-wrkdir:
Lines 3956-4131 delete-distfiles-list: Link Here
3956
.endif
3867
.endif
3957
.endif
3868
.endif
3958
3869
3959
# Prints out a list of files to fetch (useful to do a batch fetch)
3960
3961
.if !target(fetch-list)
3962
fetch-list:
3963
	@${MKDIR} ${_DISTDIR}
3964
	@(cd ${_DISTDIR}; \
3965
	 ${_MASTER_SITES_ENV} ; \
3966
	 for _file in ${DISTFILES}; do \
3967
		file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \
3968
		if [ $$_file = $$file ]; then	\
3969
			select='';	\
3970
		else	\
3971
			select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ;	\
3972
		fi;	\
3973
		if [ ! -f $$file -a ! -f $${file##*/} ]; then \
3974
			if [ ! -z "$$select" ] ; then \
3975
				__MASTER_SITES_TMP= ; \
3976
				for group in $$select; do \
3977
					if [ ! -z \$${_MASTER_SITES_$${group}} ] ; then \
3978
						eval ___MASTER_SITES_TMP=\$${_MASTER_SITES_$${group}} ; \
3979
						__MASTER_SITES_TMP="$${__MASTER_SITES_TMP} $${___MASTER_SITES_TMP}" ; \
3980
					fi; \
3981
				done; \
3982
				___MASTER_SITES_TMP= ; \
3983
				SORTED_MASTER_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__MASTER_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
3984
			else \
3985
				SORTED_MASTER_SITES_CMD_TMP="${SORTED_MASTER_SITES_DEFAULT_CMD}" ; \
3986
			fi; \
3987
			${ECHO_CMD} -n ${MKDIR} ${_DISTDIR} '&& ' ; \
3988
			${ECHO_CMD} -n cd ${_DISTDIR} '&& { ' ; \
3989
			for site in `eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
3990
				if [ ! -z "`${ECHO_CMD} ${NOFETCHFILES} | ${GREP} -w $${file}`" ]; then \
3991
					if [ -z "`${ECHO_CMD} ${MASTER_SITE_OVERRIDE} | ${GREP} -w $${site}`" ]; then \
3992
						continue; \
3993
					fi; \
3994
				fi; \
3995
				CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
3996
				case $${file} in \
3997
				*/*)	args="-o $${file} $${site}$${file}";; \
3998
				*)		args=$${site}$${file};; \
3999
				esac; \
4000
				${ECHO_CMD} -n ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} "${FETCH_AFTER_ARGS}" '|| ' ; \
4001
			done; \
4002
			${ECHO_CMD} "${ECHO_CMD} $${file} not fetched; }" ; \
4003
		fi; \
4004
	done)
4005
.if defined(PATCHFILES)
4006
	@(cd ${_DISTDIR}; \
4007
	 ${_PATCH_SITES_ENV} ; \
4008
	 for _file in ${PATCHFILES}; do \
4009
		file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^-:][^:]*$$//'` ; \
4010
		if [ $$_file = $$file ]; then	\
4011
			select='';	\
4012
		else	\
4013
			select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ;	\
4014
		fi;	\
4015
		file=`${ECHO_CMD} $$file | ${SED} -E -e 's/:-[^:]+$$//'` ; \
4016
		if [ ! -f $$file -a ! -f $${file##*/} ]; then \
4017
			if [ ! -z "$$select" ] ; then \
4018
				__PATCH_SITES_TMP= ; \
4019
				for group in $$select; do \
4020
					if [ ! -z \$${_PATCH_SITES_$${group}} ] ; then \
4021
						eval ___PATCH_SITES_TMP=\$${_PATCH_SITES_$${group}} ; \
4022
						__PATCH_SITES_TMP="$${__PATCH_SITES_TMP} $${___PATCH_SITES_TMP}" ; \
4023
				fi; \
4024
				done; \
4025
				___PATCH_SITES_TMP= ; \
4026
				SORTED_PATCH_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__PATCH_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
4027
			else \
4028
				SORTED_PATCH_SITES_CMD_TMP="${SORTED_PATCH_SITES_DEFAULT_CMD}" ; \
4029
			fi; \
4030
			${ECHO_CMD} -n ${MKDIR} ${_DISTDIR} '&& ' ; \
4031
			${ECHO_CMD} -n cd ${_DISTDIR} '&& { ' ; \
4032
			for site in `eval $$SORTED_PATCH_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
4033
				CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
4034
				case $${file} in \
4035
				*/*)	args="-o $${file} $${site}$${file}";; \
4036
				*)		args=$${site}$${file};; \
4037
				esac; \
4038
				${ECHO_CMD} -n ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} "${FETCH_AFTER_ARGS}" '|| ' ; \
4039
			done; \
4040
			${ECHO_CMD} "${ECHO_CMD} $${file} not fetched; }" ; \
4041
		fi; \
4042
	 done)
4043
.endif
4044
.endif
4045
4046
.if !target(fetch-url-list-int)
4047
fetch-url-list-int:
4048
	@${MKDIR} ${_DISTDIR}
4049
	@(cd ${_DISTDIR}; \
4050
	${_MASTER_SITES_ENV}; \
4051
	for _file in ${DISTFILES}; do \
4052
		file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \
4053
			fileptn=`${ECHO_CMD} $$file | ${SED} 's|/|\\\\/|g;s/\./\\\\./g;s/\+/\\\\+/g;s/\?/\\\\?/g'` ; \
4054
		if [ $$_file = $$file ]; then	\
4055
			select='';	\
4056
		else	\
4057
			select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ;	\
4058
		fi;	\
4059
		if [ ! -z "${LISTALL}" -o ! -f $$file -a ! -f $${file##*/} ]; then \
4060
			if [ ! -z "$$select" ] ; then \
4061
				__MASTER_SITES_TMP= ; \
4062
				for group in $$select; do \
4063
					if [ ! -z \$${_MASTER_SITES_$${group}} ] ; then \
4064
						eval ___MASTER_SITES_TMP=\$${_MASTER_SITES_$${group}} ; \
4065
						__MASTER_SITES_TMP="$${__MASTER_SITES_TMP} $${___MASTER_SITES_TMP}" ; \
4066
					fi \
4067
				done; \
4068
				___MASTER_SITES_TMP= ; \
4069
				SORTED_MASTER_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__MASTER_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
4070
			else \
4071
				SORTED_MASTER_SITES_CMD_TMP="${SORTED_MASTER_SITES_DEFAULT_CMD}" ; \
4072
			fi ; \
4073
			for site in `eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
4074
				case $${file} in \
4075
				*/*)	args="-o $${file} $${site}$${file}";; \
4076
				*)		args=$${site}$${file};; \
4077
				esac; \
4078
				${ECHO_CMD} $${args} ; \
4079
			done; \
4080
		fi \
4081
	done)
4082
.if defined(PATCHFILES)
4083
	@(cd ${_DISTDIR}; \
4084
	${_PATCH_SITES_ENV} ; \
4085
	for _file in ${PATCHFILES}; do \
4086
		file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^-:][^:]*$$//'` ; \
4087
		if [ $$_file = $$file ]; then	\
4088
			select='';	\
4089
		else	\
4090
			select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ;	\
4091
		fi;	\
4092
		file=`${ECHO_CMD} $$file | ${SED} -E -e 's/:-[^:]+$$//'` ; \
4093
		fileptn=`${ECHO_CMD} $$file | ${SED} 's|/|\\\\/|g;s/\./\\\\./g;s/\+/\\\\+/g;s/\?/\\\\?/g'` ; \
4094
		if [ ! -z "${LISTALL}" -o ! -f $$file -a ! -f $${file##*/} ]; then \
4095
			if [ ! -z "$$select" ] ; then \
4096
				__PATCH_SITES_TMP= ; \
4097
				for group in $$select; do \
4098
					if [ ! -z \$${_PATCH_SITES_$${group}} ] ; then \
4099
						eval ___PATCH_SITES_TMP=\$${_PATCH_SITES_$${group}} ; \
4100
						__PATCH_SITES_TMP="$${__PATCH_SITES_TMP} $${___PATCH_SITES_TMP}" ; \
4101
					fi \
4102
				done; \
4103
				___PATCH_SITES_TMP= ; \
4104
				SORTED_PATCH_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__PATCH_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
4105
			else \
4106
				SORTED_PATCH_SITES_CMD_TMP="${SORTED_PATCH_SITES_DEFAULT_CMD}" ; \
4107
			fi ; \
4108
			for site in `eval $$SORTED_PATCH_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
4109
				case $${file} in \
4110
				*/*)	args="-o $${file} $${site}$${file}";; \
4111
				*)		args=$${site}$${file};; \
4112
				esac; \
4113
				${ECHO_CMD} $${args} ; \
4114
			done; \
4115
		fi \
4116
	 done)
4117
.endif
4118
.endif
4119
4120
.if !target(fetch-urlall-list)
4121
fetch-urlall-list:
4122
	@cd ${.CURDIR} && LISTALL=yes ${MAKE} fetch-url-list-int
4123
.endif
4124
4125
.if !target(fetch-url-list)
4126
fetch-url-list: fetch-url-list-int
4127
.endif
4128
4129
# Generates patches.
3870
# Generates patches.
4130
3871
4131
update-patches:
3872
update-patches:
Lines 4141-4263 update-patches: Link Here
4141
3882
4142
# Checksumming utilities
3883
# Checksumming utilities
4143
3884
4144
check-checksum-algorithms:
3885
# List all algorithms here, all the variables name must begin with dp_
4145
	@ \
3886
_CHECKSUM_INIT_ENV= \
4146
	${checksum_init} \
3887
	dp_SHA256=${SHA256}
4147
	\
4148
	for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
4149
		eval alg_executable=\$$$$alg; \
4150
		if [ -z "$$alg_executable" ]; then \
4151
			${ECHO_MSG} "Checksum algorithm $$alg: Couldn't find the executable."; \
4152
			${ECHO_MSG} "Set $$alg=/path/to/$$alg in /etc/make.conf and try again."; \
4153
			exit 1; \
4154
		fi; \
4155
	done; \
4156
4157
checksum_init=\
4158
	SHA256=${SHA256};
4159
3888
4160
.if !target(makesum)
3889
.if !target(makesum)
4161
makesum: check-checksum-algorithms
3890
# Some port change the options with OPTIONS_*_FORCE when make(makesum) to be
4162
	@cd ${.CURDIR} && ${MAKE} fetch NO_CHECKSUM=yes \
3891
# able to add all distfiles in one go.
4163
		DISABLE_SIZE=yes
3892
# For this to work, we need to call the do-fetch script directly here so that
4164
	@if [ -f ${DISTINFO_FILE} ]; then ${CAT} /dev/null > ${DISTINFO_FILE}; fi
3893
# the options consistent when fetching and when makesum'ing.
4165
	@( \
3894
# As we're fetching new distfiles, that are not in the distinfo file, disable
4166
		cd ${DISTDIR}; \
3895
# checksum and sizes checks.
4167
		\
3896
makesum:
4168
		${checksum_init} \
3897
.if !empty(DISTFILES)
4169
		\
3898
	@${SETENV} \
4170
		for file in ${_CKSUMFILES}; do \
3899
			${_DO_FETCH_ENV} ${_MASTER_SITES_ENV} \
4171
			for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
3900
			dp_NO_CHECKSUM=yes dp_DISABLE_SIZE=yes \
4172
				eval alg_executable=\$$$$alg; \
3901
			dp_SITE_FLAVOR=MASTER \
4173
				\
3902
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${DISTFILES:C/.*/'&'/}
4174
				if [ $$alg_executable != "NO" ]; then \
3903
.endif
4175
					$$alg_executable $$file >> ${DISTINFO_FILE}; \
3904
.if defined(PATCHFILES)
4176
				fi; \
3905
	@${SETENV} \
4177
			done; \
3906
			${_DO_FETCH_ENV} ${_PATCH_SITES_ENV} \
4178
			${ECHO_CMD} "SIZE ($$file) = `${STAT} -f \"%z\" $$file`" >> ${DISTINFO_FILE}; \
3907
			dp_NO_CHECKSUM=yes dp_DISABLE_SIZE=yes \
4179
		done \
3908
			dp_SITE_FLAVOR=PATCH \
4180
	)
3909
			${SH} ${SCRIPTSDIR}/do-fetch.sh ${PATCHFILES:C/.*/'&'/}
3910
.endif
3911
	@${SETENV} \
3912
			${_CHECKSUM_INIT_ENV} \
3913
			dp_CHECKSUM_ALGORITHMS='${CHECKSUM_ALGORITHMS:tu}' \
3914
			dp_CKSUMFILES='${_CKSUMFILES}' \
3915
			dp_DISTDIR='${DISTDIR}' \
3916
			dp_DISTINFO_FILE='${DISTINFO_FILE}' \
3917
			dp_ECHO_MSG='${ECHO_MSG}' \
3918
			dp_SCRIPTSDIR='${SCRIPTSDIR}' \
3919
			${SH} ${SCRIPTSDIR}/makesum.sh ${DISTFILES:C/.*/'&'/}
4181
.endif
3920
.endif
4182
3921
4183
.if !target(checksum)
3922
.if !target(checksum)
4184
checksum: fetch check-checksum-algorithms
3923
checksum: fetch
4185
	@set -e ; \
3924
	@${SETENV} \
4186
	${checksum_init} \
3925
			${_CHECKSUM_INIT_ENV} \
4187
	if [ -f ${DISTINFO_FILE} ]; then \
3926
			dp_CHECKSUM_ALGORITHMS='${CHECKSUM_ALGORITHMS:tu}' \
4188
		cd ${DISTDIR}; OK="";\
3927
			dp_CURDIR='${.CURDIR}' \
4189
		for file in ${_CKSUMFILES}; do \
3928
			dp_DISTDIR='${DISTDIR}' \
4190
			ignored="true"; \
3929
			dp_DISTINFO_FILE='${DISTINFO_FILE}' \
4191
			_file=$${file#${DIST_SUBDIR}/*};	\
3930
			dp_DIST_SUBDIR='${DIST_SUBDIR}' \
4192
			for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
3931
			dp_ECHO_MSG='${ECHO_MSG}' \
4193
				ignore="false"; \
3932
			dp_FETCH_REGET='${FETCH_REGET}' \
4194
				eval alg_executable=\$$$$alg; \
3933
			dp_MAKE='${MAKE}' \
4195
				\
3934
			dp_MAKEFLAGS='${.MAKEFLAGS}' \
4196
				if [ $$alg_executable != "NO" ]; then \
3935
			dp_SCRIPTSDIR='${SCRIPTSDIR}' \
4197
					MKSUM=`$$alg_executable < $$file`; \
3936
			dp_DISABLE_SIZE='${DISABLE_SIZE}' \
4198
					CKSUM=`file=$$_file; ${DISTINFO_DATA}`; \
3937
			dp_NO_CHECKSUM='${NO_CHECKSUM}' \
4199
				else \
3938
			${SH} ${SCRIPTSDIR}/checksum.sh ${_CKSUMFILES:C/.*/'&'/}
4200
					ignore="true"; \
3939
4201
				fi; \
4202
				\
4203
				if [ $$ignore = "false" -a -z "$$CKSUM" ]; then \
4204
					${ECHO_MSG} "=> No $$alg checksum recorded for $$file."; \
4205
					ignore="true"; \
4206
				fi; \
4207
				\
4208
				if [ $$ignore = "false" ]; then \
4209
					match="false"; \
4210
					for chksum in $$CKSUM; do \
4211
						if [ "$$chksum" = "$$MKSUM" ]; then \
4212
							match="true"; \
4213
							break; \
4214
						fi; \
4215
					done; \
4216
					if [ $$match = "true" ]; then \
4217
						${ECHO_MSG} "=> $$alg Checksum OK for $$file."; \
4218
						ignored="false"; \
4219
					else \
4220
						${ECHO_MSG} "=> $$alg Checksum mismatch for $$file."; \
4221
						refetchlist="$$refetchlist$$file "; \
4222
						OK="$${OK:-retry}"; \
4223
						[ "$${OK}" = "retry" -a ${FETCH_REGET} -gt 0 ] && ${RM} -f $${file}; \
4224
						ignored="false"; \
4225
					fi; \
4226
				fi; \
4227
			done; \
4228
			\
4229
			if [ $$ignored = "true" ]; then \
4230
				${ECHO_MSG} "=> No suitable checksum found for $$file."; \
4231
				OK="${FALSE}"; \
4232
			fi; \
4233
			\
4234
		done; \
4235
		\
4236
		if [ "$${OK:=true}" = "retry" ] && [ ${FETCH_REGET} -gt 0 ]; then \
4237
			${ECHO_MSG} "===>  Refetch for ${FETCH_REGET} more times files: $$refetchlist"; \
4238
			if ( cd ${.CURDIR} && \
4239
			    ${MAKE} ${.MAKEFLAGS} FORCE_FETCH="$$refetchlist" FETCH_REGET="`${EXPR} ${FETCH_REGET} - 1`" fetch); then \
4240
				  if ( cd ${.CURDIR} && \
4241
			        ${MAKE} ${.MAKEFLAGS} FETCH_REGET="`${EXPR} ${FETCH_REGET} - 1`" checksum ); then \
4242
				      OK="true"; \
4243
				  fi; \
4244
			fi; \
4245
		fi; \
4246
		\
4247
		if [ "$$OK" != "true" -a ${FETCH_REGET} -eq 0 ]; then \
4248
			${ECHO_MSG} "===>  Giving up on fetching files: $$refetchlist"; \
4249
			${ECHO_MSG} "Make sure the Makefile and distinfo file (${DISTINFO_FILE})"; \
4250
			${ECHO_MSG} "are up to date.  If you are absolutely sure you want to override this"; \
4251
			${ECHO_MSG} "check, type \"make NO_CHECKSUM=yes [other args]\"."; \
4252
			exit 1; \
4253
		fi; \
4254
		if [ "$$OK" != "true" ]; then \
4255
			exit 1; \
4256
		fi; \
4257
	elif [ -n "${_CKSUMFILES:M*}" ]; then \
4258
		${ECHO_MSG} "=> No checksum file (${DISTINFO_FILE})."; \
4259
		exit 1; \
4260
	fi
4261
.endif
3940
.endif
4262
3941
4263
################################################################
3942
################################################################

Return to bug 208916