Fixed build
[distributed.git] / tools / maint / fetch.in
blobfa1566770eb0d56e08060eebe21df2910d01fbc4
1 #! @SHELL@
4 # fetch.in
6 # Copyright (C) 2007, 2008 Francesco Salvestrini
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 me="fetch"
24 version="0.1"
26 WGET=@WGET@
28 case $1 in
29     -h|--help)
30         echo "Usage: $me URL FILE"
31         echo ""
32         echo "Fetch file from URL, placing output in FILE"
33         echo ""
34         echo "OPTIONS:"
35         echo ""
36         echo "  -h, --help       display this help and exit"
37         echo "  -v, --version    output version information and exit"
38         echo ""
39         echo "Report bugs to <@PACKAGE_BUGREPORT@>"
40         exit 0
41         ;;
42     -v|--version)
43         echo "$me (@PACKAGE_NAME@) $version"
44         echo "Written by Francesco Salvestrini."
45         echo ""
46         echo "This is free software; see the source for copying conditions.  There is NO"
47         echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
48         exit 0
49         ;;
50 esac
52 URL=$1
53 FILE=$2
55 if test "$WGET" = "" ; then
56     echo "$me: Missing wget executable ..."
57     exit 1
59 if test "$URL" = "" ; then
60     echo "$me: Missing input URL"
61     echo "Try \`$program --help' for more information."
62     exit 1
64 if test "$FILE" = "" ; then
65     echo "$me: Missing output file"
66     echo "Try \`$program --help' for more information."
67     exit 1
70 echo "$me: $URL"
71 rm -f $FILE
72 $WGET --no-verbose -q -O $FILE -- $URL || {
73     echo "$me: Cannot fetch $URL"
74     rm -f $FILE
75     exit 1
78 if test ! -s $FILE ; then
79     echo "$me: $URL not fetched ?"
80     rm -f $FILE
81     exit 1
84 exit 0