aboutsummaryrefslogtreecommitdiff
path: root/tests/dl-linux-tarball.bash
blob: fa27e37262079b669065ee40391bf746208f2474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash -eu
#
# This script checks the size of /tmp/linux-3.0.tar.gz and downloads
# a fresh copy if the size is incorrect or the file is missing.

URL=https://cdn.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz
TGZ=/tmp/linux-3.0.tar.gz

SIZE_WANT=96675825
SIZE_ACTUAL=0
if [[ -e $TGZ ]]; then
	if [[ $OSTYPE == linux* ]] ; then
		SIZE_ACTUAL=$(stat -c %s $TGZ)
	else
		# Mac OS X
		SIZE_ACTUAL=$(stat -f %z $TGZ)
	fi
fi

if [[ $SIZE_ACTUAL -ne $SIZE_WANT ]]; then
	echo "Downloading linux-3.0.tar.gz"
	if command -v wget > /dev/null ; then
		wget -nv --show-progress -c -O $TGZ $URL
	else
		curl -o $TGZ $URL
	fi
fi