2 # download.sh - Download source and binary packages for GPG4Win.
3 # Copyright (C) 2005, 2007 g10 Code GmbH
5 # This file is part of Gpg4win.
7 # Gpg4win is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # Gpg4win is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 # Syntax of the packages.current file:
23 # If the first non whitespace character of a line is #, the line is
24 # considered a comment. If the first word of a line is "server", the
25 # rest of the line will be taken as the base URL for following file
26 # commands. If the first word of a line is "file" the rest of the
27 # line will be appended to the current base URL (with a / as
28 # delimiter). Example:
31 # server ftp://ftp.gnupg.org/gcrypt
33 # file gnupg/gnupg-1.4.2.tar.gz
34 # chk 1234567890123456789012345678901234567890
57 while [ $# -gt 0 ]; do
60 optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
98 # We used to download the packages.current list but it turned out that
99 # this is too problematic: As there is no history of these files it is
100 # not possible to build and older version of gpg4win using the online
101 # version of the list. Thus we keep the list now with the installer
102 # and in case a package update is required we will post an updated
103 # list to the mailing list.
105 #url="http://www.gpg4win.org"
106 #if [ "$keep_list" = "no" ]; then
107 # echo "downloading packages list from \`$url'."
108 # if ! ${WGET} -N -q $url/packages.current{,.sig} ; then
109 # echo "download of packages list failed." >&2
114 #if [ "$sig_ckeck" = yes ]; then
115 # if ! gpgv --keyring ./packages.keys packages.current.sig packages.current
117 # echo "list of packages is not usable." >&2
124 [ -f '.#download.failed' ] && rm '.#download.failed'
125 cat packages.current | \
126 while read key value ; do
127 : $(( lnr = lnr + 1 ))
128 [ -z "$key" ] && continue
136 if [ -z "$value" ]; then
137 echo "syntax error in name statement, line $lnr" >&2
141 [ $quiet = no ] && echo "using name \`$name'"
144 if [ -z "$value" ]; then
145 echo "syntax error in file statement, line $lnr" >&2
148 if [ -z "$server" ]; then
149 echo "no server location for file \`$value', line $lnr" >&2
153 if [ -z "$name" ]; then
154 name=`basename "$value"`
156 if [ -f "$name" -a "$force" = "no" ]; then
157 [ $quiet = no ] && echo "package \`$url' ... already exists"
159 echo -n "downloading \`$url' ..."
160 if ${WGET} -c -q "$url" -O "$name" ; then
163 echo " FAILED (line $lnr)"
164 echo "line $lnr: downloading $url failed" >> '.#download.failed'
169 if [ -z "$value" ]; then
170 echo "syntax error in file statement, line $lnr" >&2
173 if [ -z "$name" ]; then
174 echo "no name for link in line $lnr" >&2
177 if [ -f "$value" -a "$force" = "no" ]; then
178 [ $quiet = no ] && echo "package \`$value' ... already exists"
180 echo -n "linking \`$value' to \`$name' ..."
181 if ln -f "$name" "$value"; then
184 echo " FAILED (line $lnr)"
185 echo "line $lnr: linking $value failed" >> '.#download.failed'
190 if [ -z "$value" ]; then
191 echo "syntax error in chk statement, line $lnr" >&2
194 if [ -z "$name" ]; then
195 echo "no file name for chk statement, line $lnr" >&2
198 [ $quiet = no ] && echo -n "checking \`$name' ..."
199 if echo "$value *$name" | sha1sum -c >/dev/null 2>&1 ; then
200 [ $quiet = no ] && echo " okay"
202 [ $quiet = no ] && echo " FAILED (line $lnr)"
203 [ $quiet = no ] || echo "checking \`$name' FAILED (line $lnr)"
204 echo "line $lnr: checking $name failed" >> '.#download.failed'
209 echo "syntax error in \`packages.current', line $lnr." >&2
213 if [ -f '.#download.failed' ]; then
214 cat '.#download.failed' >&2
215 rm '.#download.failed'
216 echo "some files failed to download or checksums are not matching" >&2