Ply updated to v2.3
[obnox/wireshark/wip.git] / tools / win32-setup.sh
1 #!/bin/sh
2
3 # This MUST be in the form
4 #   http://anonsvn.wireshark.org/wireshark-win32-libs/tags/<date>/packages
5 # in order to provide backward compatibility with older trees (e.g. a
6 # previous release or an older SVN checkout).
7 DOWNLOAD_PREFIX="http://anonsvn.wireshark.org/wireshark-win32-libs/tags/2007-03-22/packages"
8
9 # Set DOWNLOAD_PREFIX to /packages to test uploads before creating the tag.
10 #DOWNLOAD_PREFIX="http://anonsvn.wireshark.org/wireshark-win32-libs/trunk/packages/"
11
12 err_exit () {
13         echo ""
14         echo "ERROR: $1"
15         echo ""
16         exit 1
17 }
18
19 usage () {
20         echo "Usage:"
21         echo "  $0 --appverify <appname> [<appname>] ..."
22         echo "  $0 --download <destination> <subdirectory> <package>"
23         echo ""
24         exit 1
25 }
26
27
28 case "$1" in
29 --appverify)
30         shift
31         if [ -z "$*" ] ; then
32                 usage
33         fi
34         echo "Checking for required applications:"
35         which which > /dev/null 2>&1 || \
36                 err_exit "Can't find 'which'.  Unable to proceed."
37         for APP in $* ; do
38                 APP_PATH=`cygpath --unix $APP`
39                 if [ -x "$APP_PATH" -a ! -d "$APP_PATH" ] ; then
40                         APP_LOC="$APP_PATH"
41                 else
42                         APP_LOC=`which $APP_PATH 2> /dev/null`
43                 fi
44                 if [ "$APP_LOC" = "" ] ; then
45                         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!"
46                 fi
47                 echo "  $APP: $APP_LOC $res"
48         done
49         ;;
50 --download)
51         if [ -z "$2" -o -z "$3" -o -z "$4" ] ; then
52                 usage
53         fi
54         DEST_PATH=`cygpath --dos "$2"`
55         DEST_SUBDIR=$3
56         PACKAGE_PATH=$4
57         PACKAGE=`basename "$PACKAGE_PATH"`
58         echo "****** $PACKAGE ******"
59         if [ -z "$http_proxy" -a -z "$HTTP_PROXY" ] ; then
60                 echo "No HTTP proxy specified (http_proxy and HTTP_PROXY are empty)."
61                 # a proxy might also be specified using .wgetrc, so don't switch off the proxy
62                 #use_proxy="-Y off"
63         else
64                 use_proxy="-Y on"
65                 if [ -z "$http_proxy" ] ; then
66                         echo "HTTP proxy ($HTTP_PROXY) has been specified and will be used."
67                 else
68                         echo "HTTP proxy ($http_proxy) has been specified and will be used."
69                 fi
70         fi
71         echo "Downloading $4 into $DEST_PATH, installing into $3"
72         if [ ! -d "$DEST_PATH/$DEST_SUBDIR" ] ; then
73                 mkdir -p "$DEST_PATH/$DEST_SUBDIR" || \
74                         err_exit "Can't create $DEST_PATH/$DEST_SUBDIR"
75         fi
76         cd "$DEST_PATH" || err_exit "Can't find $DEST_PATH"
77         wget $use_proxy -nc "$DOWNLOAD_PREFIX/$PACKAGE_PATH" || \
78                 err_exit "Can't download $DOWNLOAD_PREFIX/$PACKAGE_PATH"
79         cd "$DEST_SUBDIR" || err_exit "Can't find $DEST_SUBDIR"
80         echo "Extracting $DEST_PATH/$PACKAGE into $DEST_PATH/$DEST_SUBDIR"
81         unzip -oq "$DEST_PATH/$PACKAGE" ||
82                 err_exit "Couldn't unpack $DEST_PATH/$PACKAGE"
83         echo "Verifying that the DLLs in $DEST_PATH/$DEST_SUBDIR are executable."
84         for i in `/usr/bin/find $DEST_PATH/$DEST_SUBDIR -name \*\.dll` ; do
85                 if [ ! -x "$i" ] ; then
86                         echo "Changing file permissions (add executable bit) to:"
87                         echo "$i"
88                         chmod a+x "$i"
89                 fi
90         done
91         ;;
92 *)
93         usage
94         ;;
95 esac
96
97 exit 0