New gettext-runtime
[metze/wireshark/wip.git] / tools / win32-setup.sh
1 #!/bin/sh
2 #
3 # $Id$
4
5 # This MUST be in the form
6 #   http://anonsvn.wireshark.org/wireshark-win32-libs/tags/<date>/packages
7 # in order to provide backward compatibility with older trees (e.g. a
8 # previous release or an older SVN checkout).
9 # Save privious tag.
10 #DOWNLOAD_PREFIX="http://anonsvn.wireshark.org/wireshark-win32-libs/tags/2008-01-15/packages/"
11 DOWNLOAD_PREFIX="http://anonsvn.wireshark.org/wireshark-win32-libs/tags/2008-01-27/packages/"
12
13 # Set DOWNLOAD_PREFIX to /packages to test uploads before creating the tag.
14 # DOWNLOAD_PREFIX="http://anonsvn.wireshark.org/wireshark-win32-libs/trunk/packages/"
15
16 err_exit () {
17         echo ""
18         echo "ERROR: $1"
19         echo ""
20         exit 1
21 }
22
23 usage () {
24         echo "Usage:"
25         echo "  $0 --appverify <appname> [<appname>] ..."
26         echo "  $0 --libverify <destination> <subdirectory> <package>"
27         echo "  $0 --download  <destination> <subdirectory> <package>"
28         echo ""
29         exit 1
30 }
31
32
33 case "$1" in
34 --appverify)
35         shift
36         if [ -z "$*" ] ; then
37                 usage
38         fi
39         echo "Checking for required applications:"
40         which which > /dev/null 2>&1 || \
41                 err_exit "Can't find 'which'.  Unable to proceed."
42         for APP in $* ; do
43                 APP_PATH=`cygpath --unix $APP`
44                 if [ -x "$APP_PATH" -a ! -d "$APP_PATH" ] ; then
45                         APP_LOC="$APP_PATH"
46                 else
47                         APP_LOC=`which $APP_PATH 2> /dev/null`
48                 fi
49                 if [ "$APP_LOC" = "" ] ; then
50                         err_exit "Can't find $APP. This is probably an optional cygwin package not yet installed. Try to install it using cygwin's setup.exe!"
51                 fi
52                 echo "  $APP: $APP_LOC $res"
53         done
54         ;;
55 --libverify)
56         if [ -z "$2" -o -z "$3" -o -z "$4" ] ; then
57                 usage
58         fi
59         DEST_PATH=`cygpath --dos "$2"`
60         PACKAGE_PATH=$4
61         PACKAGE=`basename "$PACKAGE_PATH"`
62         if [ ! -e $DEST_PATH/$PACKAGE ] ; then 
63             err_exit "Package $PACKAGE is needed but is apparently not downloaded; 'nmake -f ... setup' required ?"
64         fi
65         ;;  
66 --download)
67         if [ -z "$2" -o -z "$3" -o -z "$4" ] ; then
68                 usage
69         fi
70         DEST_PATH=`cygpath --dos "$2"`
71         DEST_SUBDIR=$3
72         PACKAGE_PATH=$4
73         PACKAGE=`basename "$PACKAGE_PATH"`
74         echo ""
75         echo "****** $PACKAGE ******"
76         if [ -z "$http_proxy" -a -z "$HTTP_PROXY" ] ; then
77                 echo "No HTTP proxy specified (http_proxy and HTTP_PROXY are empty)."
78                 # a proxy might also be specified using .wgetrc, so don't switch off the proxy
79                 #use_proxy="-Y off"
80         else
81                 use_proxy="-Y on"
82                 if [ -z "$http_proxy" ] ; then
83                         echo "HTTP proxy ($HTTP_PROXY) has been specified and will be used."
84                         export http_proxy=$HTTP_PROXY
85                 else
86                         echo "HTTP proxy ($http_proxy) has been specified and will be used."
87                 fi
88         fi
89         echo "Downloading $4 into $DEST_PATH, installing into $3"
90         if [ ! -d "$DEST_PATH/$DEST_SUBDIR" ] ; then
91                 mkdir -p "$DEST_PATH/$DEST_SUBDIR" || \
92                         err_exit "Can't create $DEST_PATH/$DEST_SUBDIR"
93         fi
94         cd "$DEST_PATH" || err_exit "Can't find $DEST_PATH"
95         wget $use_proxy -nc "$DOWNLOAD_PREFIX/$PACKAGE_PATH" || \
96                 err_exit "Can't download $DOWNLOAD_PREFIX/$PACKAGE_PATH"
97         cd "$DEST_SUBDIR" || err_exit "Can't find $DEST_SUBDIR"
98         echo "Extracting $DEST_PATH/$PACKAGE into $DEST_PATH/$DEST_SUBDIR"
99         unzip -oq "$DEST_PATH/$PACKAGE" ||
100                 err_exit "Couldn't unpack $DEST_PATH/$PACKAGE"
101         echo "Verifying that the DLLs and EXEs in $DEST_SUBDIR are executable."
102         # XX: Note that find will check *all* dlls/exes in DEST_SUBDIR and below
103         #     which may be more than those just unzipped depending upon DEST_SUBDIR.
104         #     This may cause extra repeated checks but will do no harm. 
105         for i in `/usr/bin/find . \( -name '*\.dll' -o -name '*\.exe' \)` ; do
106                 if [ ! -x "$i" ] ; then
107                         echo "Changing file permissions (add executable bit) to:"
108                         echo "$i"
109                         chmod a+x "$i"
110                 fi
111         done
112         ;;
113 *)
114         usage
115         ;;
116 esac
117
118 exit 0