52 | 52 |
fi
|
53 | 53 |
set -e
|
54 | 54 |
|
55 | |
|
|
55 |
error=0
|
56 | 56 |
for pkgspec in $*; do
|
57 | 57 |
set +e
|
58 | |
apt-get -q2 --print-uris download "$pkgspec" 2>/dev/null >/dev/null
|
|
58 |
apt-get download "$pkgspec"
|
59 | 59 |
if [ $? -ne 0 ] ; then
|
60 | |
echo "ERROR: There is no '$pkgspec' package. Sorry."
|
61 | 60 |
echo "If you believe the package exists then consider updating your"
|
62 | 61 |
echo "package database using 'apt-get update'."
|
|
62 |
error=1
|
63 | 63 |
continue
|
64 | 64 |
fi
|
65 | |
set -e
|
66 | |
# This provides only one version, but it's better than the apt-get
|
67 | |
# call which will not work in packages not available locally
|
68 | |
apt-cache show "$pkgspec" 2>/dev/null | grep ^Ver |
|
69 | |
while read version; do
|
70 | |
version=`echo $version | sed -ne '$s/^.*: \(.*\).*$/\1/p'`
|
71 | |
echo "($pkgspec -> $version)"
|
72 | |
done
|
73 | |
aptdata=$(apt-get -q2 --print-uris download "$pkgspec" 2>/dev/null | grep -F "/${pkgspec}_")
|
74 | |
if [ -z "$aptdata" ] ; then
|
75 | |
echo "ERROR: No APT data returned for '$pkgspec'. Sorry."
|
76 | |
echo "This is probably because the package is in the local apt cache"
|
77 | |
echo "Tip: Use 'aptitude download'"
|
78 | |
continue
|
79 | |
fi
|
80 | |
url=$(echo "$aptdata" | sed -e "s/^'\([^']*\)'.*$/\1/")
|
81 | |
file=$(echo "$aptdata" | sed -e "s/^'[^']*' \([^ ]*\).*$/\1/")
|
82 | |
if [ -z "$url" ] ; then
|
83 | |
echo "ERROR: Cound not obtain an URL for $pkgspec"
|
84 | |
else
|
85 | |
if echo "$url" | egrep -q '^tor\+'; then
|
86 | |
if which torify 2>&1 > /dev/null; then
|
87 | |
torify=torify
|
88 | |
else
|
89 | |
echo "torify not found, can not download $url" 1>&2
|
90 | |
exit 2
|
91 | |
fi
|
92 | |
url=$(echo "$url" | sed -e 's/^tor+//')
|
93 | |
fi
|
94 | |
if [ -n "$torify" ]; then
|
95 | |
echo "Downloading $pkgspec from $url via tor"
|
96 | |
else
|
97 | |
echo "Downloading $pkgspec from $url"
|
98 | |
fi
|
99 | |
$torify curl "$url" > "$file"
|
100 | |
fi
|
101 | 65 |
done
|
|
66 |
exit $error
|