View | Details | Raw Unified | Return to bug 233988
Collapse All | Expand All

(-)freebsd-update.sh (-6 / +33 lines)
Lines 1059-1068 Link Here
1059
1059
1060
# Print user-friendly progress statistics
1060
# Print user-friendly progress statistics
1061
fetch_progress () {
1061
fetch_progress () {
1062
	if [ "$1" -gt 0 -a -t 1 ]; then
1063
		fetch_progress_tty $1
1064
	else
1065
		fetch_progress_classic
1066
	fi
1067
}
1068
1069
# Progress in an in-place "123/456 (26%)" style
1070
fetch_progress_tty () {
1071
	EXP=$1
1062
	LNC=0
1072
	LNC=0
1073
	printf " \033[s"
1063
	while read x; do
1074
	while read x; do
1064
		LNC=$(($LNC + 1))
1075
		LNC=$(($LNC + 1))
1076
		PCT=$((100 * $LNC / $EXP))
1065
		if [ $(($LNC % 10)) = 0 ]; then
1077
		if [ $(($LNC % 10)) = 0 ]; then
1078
			printf "\033[u%d/%d (%d%%)" $LNC $EXP $PCT
1079
		fi
1080
	done
1081
	printf "\033[u\033[K"
1082
}
1083
1084
# Progress in the original "10....20....30" style
1085
fetch_progress_classic () {
1086
	LNC=0
1087
	while read x; do
1088
		LNC=$(($LNC + 1))
1089
		if [ $(($LNC % 10)) = 0 ]; then
1066
			echo -n $LNC
1090
			echo -n $LNC
1067
		elif [ $(($LNC % 2)) = 0 ]; then
1091
		elif [ $(($LNC % 2)) = 0 ]; then
1068
			echo -n .
1092
			echo -n .
Lines 1311-1322 Link Here
1311
1335
1312
	if [ -s patchlist ]; then
1336
	if [ -s patchlist ]; then
1313
		# Attempt to fetch metadata patches
1337
		# Attempt to fetch metadata patches
1314
		echo -n "Fetching `wc -l < patchlist | tr -d ' '` "
1338
		NITEMS=`wc -l < patchlist | tr -d ' '`
1339
		echo -n "Fetching ${NITEMS} "
1315
		echo ${NDEBUG} "metadata patches.${DDSTATS}"
1340
		echo ${NDEBUG} "metadata patches.${DDSTATS}"
1316
		tr '|' '-' < patchlist |
1341
		tr '|' '-' < patchlist |
1317
		    lam -s "${FETCHDIR}/tp/" - -s ".gz" |
1342
		    lam -s "${FETCHDIR}/tp/" - -s ".gz" |
1318
		    xargs ${XARGST} ${PHTTPGET} ${SERVERNAME}	\
1343
		    xargs ${XARGST} ${PHTTPGET} ${SERVERNAME}	\
1319
			2>${STATSREDIR} | fetch_progress
1344
			2>${STATSREDIR} | fetch_progress ${NITEMS}
1320
		echo "done."
1345
		echo "done."
1321
1346
1322
		# Attempt to apply metadata patches
1347
		# Attempt to apply metadata patches
Lines 1850-1861 Link Here
1850
fetch_files () {
1875
fetch_files () {
1851
	# Attempt to fetch patches
1876
	# Attempt to fetch patches
1852
	if [ -s patchlist ]; then
1877
	if [ -s patchlist ]; then
1853
		echo -n "Fetching `wc -l < patchlist | tr -d ' '` "
1878
		NITEMS=`wc -l < patchlist | tr -d ' '`
1879
		echo -n "Fetching ${NITEMS} "
1854
		echo ${NDEBUG} "patches.${DDSTATS}"
1880
		echo ${NDEBUG} "patches.${DDSTATS}"
1855
		tr '|' '-' < patchlist |
1881
		tr '|' '-' < patchlist |
1856
		    lam -s "${PATCHDIR}/" - |
1882
		    lam -s "${PATCHDIR}/" - |
1857
		    xargs ${XARGST} ${PHTTPGET} ${SERVERNAME}	\
1883
		    xargs ${XARGST} ${PHTTPGET} ${SERVERNAME}	\
1858
			2>${STATSREDIR} | fetch_progress
1884
			2>${STATSREDIR} | fetch_progress ${NITEMS}
1859
		echo "done."
1885
		echo "done."
1860
1886
1861
		# Attempt to apply patches
1887
		# Attempt to apply patches
Lines 1884-1894 Link Here
1884
	done < files.wanted > filelist
1910
	done < files.wanted > filelist
1885
1911
1886
	if [ -s filelist ]; then
1912
	if [ -s filelist ]; then
1887
		echo -n "Fetching `wc -l < filelist | tr -d ' '` "
1913
		NITEMS=`wc -l < filelist | tr -d ' '`
1914
		echo -n "Fetching ${NITEMS} "
1888
		echo ${NDEBUG} "files... "
1915
		echo ${NDEBUG} "files... "
1889
		lam -s "${FETCHDIR}/f/" - -s ".gz" < filelist |
1916
		lam -s "${FETCHDIR}/f/" - -s ".gz" < filelist |
1890
		    xargs ${XARGST} ${PHTTPGET} ${SERVERNAME}	\
1917
		    xargs ${XARGST} ${PHTTPGET} ${SERVERNAME}	\
1891
			2>${STATSREDIR} | fetch_progress
1918
			2>${STATSREDIR} | fetch_progress ${NITEMS}
1892
1919
1893
		while read Y; do
1920
		while read Y; do
1894
			if ! [ -f ${Y}.gz ]; then
1921
			if ! [ -f ${Y}.gz ]; then

Return to bug 233988