MSWSP: add two more Property Sets
[wireshark-wip.git] / tools / win-setup.sh
blobd0c1f6df9ceb40ca4f77b10fa2ea2ed0d9afbee2
1 #!/bin/bash
3 # Copyright 2013 Gerald Combs <gerald@wireshark.org>
5 # $Id$
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 1998 Gerald Combs
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 (set -o igncr) 2>/dev/null && set -o igncr; # hack to force this file to be processed by cygwin bash with -o igncr
25 # needed when this file is exec'd from win32-setup.sh & win64-setup.sh
27 err_exit () {
28 echo ""
29 echo "ERROR: $1"
30 shift
31 for str in "$@" ; do
32 echo "$str"
33 done
34 echo ""
35 exit 1
38 if [ -z "$DOWNLOAD_TAG" ]; then
39 err_exit "DOWNLOAD_TAG not defined (internal error)"
42 if [ -z "$WIRESHARK_TARGET_PLATFORM" ]; then
43 err_exit "WIRESHARK_TARGET_PLATFORM not defined (internal error)"
46 # This MUST be in the form
47 # http://anonsvn.wireshark.org/wireshark-win32-libs/tags/<date>/packages
48 # or
49 # http://anonsvn.wireshark.org/wireshark-win64-libs/tags/<date>/packages
50 # in order to provide backward compatibility with older trees (e.g. a
51 # previous release or an older SVN checkout).
52 # Save previous tag.
54 # Set DOWNLOAD_PREFIX to /packages to test uploads before creating the tag.
55 #DOWNLOAD_PREFIX="http://anonsvn.wireshark.org/wireshark-$WIRESHARK_TARGET_PLATFORM-libs/trunk/packages/"
56 DOWNLOAD_PREFIX="http://anonsvn.wireshark.org/wireshark-$WIRESHARK_TARGET_PLATFORM-libs/tags/$DOWNLOAD_TAG/packages/"
58 TAG_FILE="current_tag.txt"
60 usage () {
61 echo "Usage:"
62 echo " $0 --appverify <appname> [<appname>] ..."
63 echo " $0 --libverify <destination> <subdirectory> <package>"
64 echo " $0 --download <destination> <subdirectory> <package>"
65 echo " $0 --settag <destination>"
66 echo " $0 --checktag <destination>"
67 echo ""
68 exit 1
71 # Try to find our proxy settings, and set http_proxy/use_proxy accordingly.
72 find_proxy() {
73 # Someone went to the trouble of configuring wget.
74 if grep "^use_proxy *= *on" $HOME/.wgetrc > /dev/null 2>&1 ; then
75 return
78 # ...and wget can't fetch two registry keys because...?
79 proxy_enabled=$(regtool get /HKCU/Software/Microsoft/Windows/CurrentVersion/Internet\ Settings/ProxyEnable 2>/dev/null | tr -d '\012')
81 # Bash's test command appears not to use short-circuit evaluation,
82 # so
84 # -n "$proxy_enabled" -a "$proxy_enabled" -ne 0
86 # causes a complaint if "$proxy_enabled" is an empty string -
87 # the first test fails, but the second test is done anyway,
88 # and generates a complaint about the LHS of -ne not being
89 # numeric. Therefore, we do the tests separately.
91 if [ -n "$proxy_enabled" ] ; then
92 if [ "$proxy_enabled" -ne 0 ] ; then
93 export http_proxy=$(regtool get /HKCU/Software/Microsoft/Windows/CurrentVersion/Internet\ Settings/ProxyServer 2>/dev/null)
94 echo "Using Internet Explorer proxy settings."
98 if [ -z "$http_proxy" -a -z "$HTTP_PROXY" ] ; then
99 echo "No HTTP proxy specified (http_proxy and HTTP_PROXY are empty)."
100 # a proxy might also be specified using .wgetrc, so don't switch off the proxy
101 #use_proxy="-Y off"
102 return
105 # We found a proxy somewhere
106 use_proxy="-Y on"
107 if [ -z "$http_proxy" ] ; then
108 echo "HTTP proxy ($HTTP_PROXY) has been specified and will be used."
109 export http_proxy=$HTTP_PROXY
110 else
111 echo "HTTP proxy ($http_proxy) has been specified and will be used."
117 case "$1" in
118 --appverify)
119 shift
121 if [ -z "$*" ] ; then
122 usage
125 echo "Checking for required applications:"
126 which which > /dev/null 2>&1 || \
127 err_exit "Can't find 'which'. Unable to proceed."
129 MISSING_APPS=
130 PATH_RE=""
131 for APP in $* ; do
133 case "$APP" in
134 --windowsonly)
135 PATH_RE="^/cygdrive/.*/"
136 continue
138 --cygwinonly)
139 PATH_RE="^/usr/.*/"
140 continue
142 esac
144 APP_PATH=$(cygpath --unix "$APP")
145 if [ -x "$APP_PATH" -a ! -d "$APP_PATH" ] ; then
146 APP_LOC="$APP_PATH"
147 else
148 APP_LOC=$(which "$APP_PATH" 2> /dev/null)
150 echo "$APP_LOC" | grep "$PATH_RE" > /dev/null 2>&1
151 IN_PATH=$?
152 if [ "$APP_LOC" = "" -o $IN_PATH -ne 0 ] ; then
153 MISSING_APPS="$MISSING_APPS $APP"
154 else
155 echo " $APP: $APP_LOC $res"
158 PATH_RE=""
159 done
161 if [ -n "$MISSING_APPS" ]; then
162 echo
163 echo "Can't find: $MISSING_APPS"
164 err_exit "These application(s) are either not installed or simply can't be found in the current PATH: $PATH." \
165 "" "For additional help, please visit:" " http://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWin32.html"
168 --libverify)
169 if [ -z "$2" -o -z "$3" -o -z "$4" ] ; then
170 usage
172 DEST_PATH=$(cygpath "$2")
173 PACKAGE_PATH=$4
174 PACKAGE=$(basename "$PACKAGE_PATH")
175 if [ ! -e "$DEST_PATH/$PACKAGE" ] ; then
176 err_exit "Package $PACKAGE is needed but is apparently not downloaded; 'nmake -f ... setup' required ?"
179 --download)
180 if [ -z "$2" -o -z "$3" -o -z "$4" ] ; then
181 usage
183 DEST_PATH=$(cygpath "$2")
184 DEST_SUBDIR=$3
185 PACKAGE_PATH=$4
186 PACKAGE=$(basename "$PACKAGE_PATH")
187 echo ""
188 echo "****** $PACKAGE ******"
189 find_proxy
190 echo "Downloading $4 into '$DEST_PATH', installing into $3"
191 if [ ! -d "$DEST_PATH/$DEST_SUBDIR" ] ; then
192 mkdir -p "$DEST_PATH/$DEST_SUBDIR" || \
193 err_exit "Can't create '$DEST_PATH/$DEST_SUBDIR'"
195 cd "$DEST_PATH" || err_exit "Can't find '$DEST_PATH'"
196 PKG_PATH="$PWD"
197 wget $use_proxy -nc "$DOWNLOAD_PREFIX/$PACKAGE_PATH" || \
198 err_exit "Can't download $DOWNLOAD_PREFIX/$PACKAGE_PATH"
199 cd "$DEST_SUBDIR" || err_exit "Can't find $DEST_SUBDIR"
200 echo "Extracting '$PKG_PATH/$PACKAGE' into '$PKG_PATH/$DEST_SUBDIR'"
201 if [[ "$PACKAGE" == *.zip ]] ; then
202 unzip -oq "$PKG_PATH/$PACKAGE" ||
203 err_exit "Couldn't unpack '$PKG_PATH/$PACKAGE'"
204 echo "Verifying that the DLLs and EXEs in $DEST_SUBDIR are executable."
205 # XX: Note that find will check *all* dlls/exes in DEST_SUBDIR and below
206 # which may be more than those just unzipped depending upon DEST_SUBDIR.
207 # This may cause extra repeated checks but will do no harm.
208 for i in $(/usr/bin/find . \( -name '*\.dll' -o -name '*\.exe' \)) ; do
209 if [ ! -x "$i" ] ; then
210 echo "Changing file permissions (add executable bit) to:"
211 echo "$i"
212 chmod a+x "$i"
214 done
217 --settag)
218 if [ -z "$2" ] ; then
219 usage
221 DEST_PATH=$(cygpath "$2")
222 echo "$DOWNLOAD_TAG" > "$DEST_PATH/$TAG_FILE"
224 --checktag)
225 if [ -z "$2" ] ; then
226 usage
228 DEST_PATH=$(cygpath "$2")
229 WIN_PATH=$(cygpath --windows "$2")
230 LAST_TAG=$(cat "$DEST_PATH/$TAG_FILE" 2> /dev/null)
231 if [ "$DOWNLOAD_TAG" != "$LAST_TAG" ] ; then
232 if [ -z "$LAST_TAG" ] ; then
233 LAST_TAG="(unknown)"
235 err_exit \
236 "The contents of '$WIN_PATH\\$TAG_FILE' is $LAST_TAG." \
237 "It should be $DOWNLOAD_TAG."
241 usage
243 esac
245 exit 0