File: wget

package info (click to toggle)
apt-zip 0.9
  • links: PTS
  • area: main
  • in suites: potato
  • size: 84 kB
  • ctags: 37
  • sloc: sh: 291; makefile: 63; awk: 10
file content (69 lines) | stat: -rwxr-xr-x 1,051 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh -e

###############
# write header
#

cat <<-EOF
#!/bin/sh
# auto-generated file from apt-zip-list
set -e
err(){ echo >&2 "Fetching \$1 failed (\$2)"; }
do_wget(){
	wget -t3 -nv -O \$2 \$1
	ret=$?
	[ "\`which md5sum\`" ] && 
		if [ "\`md5sum \$2 | cut -d' ' -f1\`" = \$4 ]
		then return 0
		else err \$2 "wrong MD5"; return 1
		fi
	[ "\`which gzip\`" ] &&
		if ar p \$2 data.tar.gz | gzip -t
		then return 0
		else err \$2 "wrong contents"; return 1
		fi
	return $ret
}
EOF


###############
# Write tar-dependant stuff
#

if [ "$OPTION_TAR" = 1 ]
then
    cat <<-EOF
getfile(){
	do_wget \$1 \$2 \$3 \$4 &&
	tar rf $APTZIPTARFILE \$2 &&
	rm \$2
}
touch foo-stamp && tar cf $APTZIPTARFILE foo-stamp && rm foo-stamp
EOF
else
    cat <<-EOF
getfile(){
	do_wget \$1 \$2 \$3 \$4 &&
	mv \$2 ../disk/
}
mkdir -p partial disk && cd partial
EOF
fi

###############
# Feed the data to the core function
#

cat <<-EOF
while read URL FILE SIZE MD5
do getfile \$URL \$FILE \$SIZE \$MD5
done <<EOP
EOF

###############
# The data itself
#
cat

echo "EOP"