build/unix/run-mozilla.sh

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rwxr-xr-x

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 #!/bin/sh
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6 cmdname=`basename "$0"`
michael@0 7 MOZ_DIST_BIN=`dirname "$0"`
michael@0 8 MOZ_DEFAULT_NAME="./${cmdname}-bin"
michael@0 9 MOZ_APPRUNNER_NAME="./mozilla-bin"
michael@0 10 MOZ_PROGRAM=""
michael@0 11
michael@0 12 exitcode=1
michael@0 13 #
michael@0 14 ##
michael@0 15 ## Functions
michael@0 16 ##
michael@0 17 ##########################################################################
michael@0 18 moz_usage()
michael@0 19 {
michael@0 20 echo "Usage: ${cmdname} [options] [program]"
michael@0 21 echo ""
michael@0 22 echo " options:"
michael@0 23 echo ""
michael@0 24 echo " -g Run in debugger."
michael@0 25 echo " --debug"
michael@0 26 echo ""
michael@0 27 echo " -d debugger Debugger to use."
michael@0 28 echo " --debugger debugger"
michael@0 29 echo ""
michael@0 30 echo " -a debugger_args Arguments passed to [debugger]."
michael@0 31 echo " --debugger-args debugger_args"
michael@0 32 echo ""
michael@0 33 echo " Examples:"
michael@0 34 echo ""
michael@0 35 echo " Run the mozilla-bin binary"
michael@0 36 echo ""
michael@0 37 echo " ${cmdname} mozilla-bin"
michael@0 38 echo ""
michael@0 39 echo " Debug the mozilla-bin binary in gdb"
michael@0 40 echo ""
michael@0 41 echo " ${cmdname} -g mozilla-bin -d gdb"
michael@0 42 echo ""
michael@0 43 echo " Run mozilla-bin under valgrind with arguments"
michael@0 44 echo ""
michael@0 45 echo " ${cmdname} -g -d valgrind -a '--tool=memcheck --leak-check=full' mozilla-bin"
michael@0 46 echo ""
michael@0 47 return 0
michael@0 48 }
michael@0 49 ##########################################################################
michael@0 50 moz_bail()
michael@0 51 {
michael@0 52 message=$1
michael@0 53 echo
michael@0 54 echo "$cmdname: $message"
michael@0 55 echo
michael@0 56 exit 1
michael@0 57 }
michael@0 58 ##########################################################################
michael@0 59 moz_test_binary()
michael@0 60 {
michael@0 61 binary=$1
michael@0 62 if [ -f "$binary" ]
michael@0 63 then
michael@0 64 if [ -x "$binary" ]
michael@0 65 then
michael@0 66 return 1
michael@0 67 fi
michael@0 68 fi
michael@0 69 return 0
michael@0 70 }
michael@0 71 ##########################################################################
michael@0 72 moz_get_debugger()
michael@0 73 {
michael@0 74 debuggers="ddd gdb dbx bdb native-gdb"
michael@0 75 debugger="notfound"
michael@0 76 done="no"
michael@0 77 for d in $debuggers
michael@0 78 do
michael@0 79 moz_test_binary /bin/which
michael@0 80 if [ $? -eq 1 ]
michael@0 81 then
michael@0 82 dpath=`which ${d}`
michael@0 83 else
michael@0 84 dpath=`LC_MESSAGES=C type ${d} | awk '{print $3;}' | sed -e 's/\.$//'`
michael@0 85 fi
michael@0 86 if [ -x "$dpath" ]
michael@0 87 then
michael@0 88 debugger=$dpath
michael@0 89 break
michael@0 90 fi
michael@0 91 done
michael@0 92 echo $debugger
michael@0 93 return 0
michael@0 94 }
michael@0 95 ##########################################################################
michael@0 96 moz_run_program()
michael@0 97 {
michael@0 98 prog=$MOZ_PROGRAM
michael@0 99 ##
michael@0 100 ## Make sure the program is executable
michael@0 101 ##
michael@0 102 if [ ! -x "$prog" ]
michael@0 103 then
michael@0 104 moz_bail "Cannot execute $prog."
michael@0 105 fi
michael@0 106 ##
michael@0 107 ## Run the program
michael@0 108 ##
michael@0 109 exec "$prog" ${1+"$@"}
michael@0 110 exitcode=$?
michael@0 111 }
michael@0 112 ##########################################################################
michael@0 113 moz_debug_program()
michael@0 114 {
michael@0 115 prog=$MOZ_PROGRAM
michael@0 116 ##
michael@0 117 ## Make sure the program is executable
michael@0 118 ##
michael@0 119 if [ ! -x "$prog" ]
michael@0 120 then
michael@0 121 moz_bail "Cannot execute $prog."
michael@0 122 fi
michael@0 123 if [ -n "$moz_debugger" ]
michael@0 124 then
michael@0 125 moz_test_binary /bin/which
michael@0 126 if [ $? -eq 1 ]
michael@0 127 then
michael@0 128 debugger=`which $moz_debugger`
michael@0 129 else
michael@0 130 debugger=`LC_MESSAGES=C type $moz_debugger | awk '{print $3;}' | sed -e 's/\.$//'`
michael@0 131 fi
michael@0 132 else
michael@0 133 debugger=`moz_get_debugger`
michael@0 134 fi
michael@0 135 if [ -x "$debugger" ]
michael@0 136 then
michael@0 137 # If you are not using ddd, gdb and know of a way to convey the arguments
michael@0 138 # over to the prog then add that here- Gagan Saksena 03/15/00
michael@0 139 case `basename $debugger` in
michael@0 140 native-gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
michael@0 141 exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
michael@0 142 exitcode=$?
michael@0 143 ;;
michael@0 144 gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
michael@0 145 exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
michael@0 146 exitcode=$?
michael@0 147 ;;
michael@0 148 ddd) echo "$debugger $moz_debugger_args --gdb -- --args $prog" ${1+"$@"}
michael@0 149 exec "$debugger" $moz_debugger_args --gdb -- --args "$prog" ${1+"$@"}
michael@0 150 exitcode=$?
michael@0 151 ;;
michael@0 152 *) echo "$debugger $moz_debugger_args $prog ${1+"$@"}"
michael@0 153 exec $debugger $moz_debugger_args "$prog" ${1+"$@"}
michael@0 154 exitcode=$?
michael@0 155 ;;
michael@0 156 esac
michael@0 157 else
michael@0 158 moz_bail "Could not find a debugger on your system."
michael@0 159 fi
michael@0 160 }
michael@0 161 ##########################################################################
michael@0 162 ##
michael@0 163 ## Command line arg defaults
michael@0 164 ##
michael@0 165 moz_debug=0
michael@0 166 moz_debugger=""
michael@0 167 moz_debugger_args=""
michael@0 168 #
michael@0 169 ##
michael@0 170 ## Parse the command line
michael@0 171 ##
michael@0 172 while [ $# -gt 0 ]
michael@0 173 do
michael@0 174 case $1 in
michael@0 175 -g | --debug)
michael@0 176 moz_debug=1
michael@0 177 shift
michael@0 178 ;;
michael@0 179 -d | --debugger)
michael@0 180 moz_debugger=$2;
michael@0 181 if [ "${moz_debugger}" != "" ]; then
michael@0 182 shift 2
michael@0 183 else
michael@0 184 echo "-d requires an argument"
michael@0 185 exit 1
michael@0 186 fi
michael@0 187 ;;
michael@0 188 -a | --debugger-args)
michael@0 189 moz_debugger_args=$2;
michael@0 190 if [ "${moz_debugger_args}" != "" ]; then
michael@0 191 shift 2
michael@0 192 else
michael@0 193 echo "-a requires an argument"
michael@0 194 exit 1
michael@0 195 fi
michael@0 196 ;;
michael@0 197 *)
michael@0 198 break;
michael@0 199 ;;
michael@0 200 esac
michael@0 201 done
michael@0 202 #
michael@0 203 ##
michael@0 204 ## Program name given in $1
michael@0 205 ##
michael@0 206 if [ $# -gt 0 ]
michael@0 207 then
michael@0 208 MOZ_PROGRAM=$1
michael@0 209 shift
michael@0 210 fi
michael@0 211 ##
michael@0 212 ## Program not given, try to guess a default
michael@0 213 ##
michael@0 214 if [ -z "$MOZ_PROGRAM" ]
michael@0 215 then
michael@0 216 ##
michael@0 217 ## Try this script's name with '-bin' appended
michael@0 218 ##
michael@0 219 if [ -x "$MOZ_DEFAULT_NAME" ]
michael@0 220 then
michael@0 221 MOZ_PROGRAM=$MOZ_DEFAULT_NAME
michael@0 222 ##
michael@0 223 ## Try mozilla-bin
michael@0 224 ##
michael@0 225 elif [ -x "$MOZ_APPRUNNER_NAME" ]
michael@0 226 then
michael@0 227 MOZ_PROGRAM=$MOZ_APPRUNNER_NAME
michael@0 228 fi
michael@0 229 fi
michael@0 230 #
michael@0 231 #
michael@0 232 ##
michael@0 233 ## Make sure the program is executable
michael@0 234 ##
michael@0 235 if [ ! -x "$MOZ_PROGRAM" ]
michael@0 236 then
michael@0 237 moz_bail "Cannot execute $MOZ_PROGRAM."
michael@0 238 fi
michael@0 239 #
michael@0 240 ##
michael@0 241 ## Set MOZILLA_FIVE_HOME
michael@0 242 ##
michael@0 243 MOZILLA_FIVE_HOME=$MOZ_DIST_BIN
michael@0 244
michael@0 245 if [ -z "$MRE_HOME" ]; then
michael@0 246 MRE_HOME=$MOZILLA_FIVE_HOME
michael@0 247 fi
michael@0 248 ##
michael@0 249 ## Set LD_LIBRARY_PATH
michael@0 250 ##
michael@0 251 ## On Solaris we use $ORIGIN (set in RUNPATH) instead of LD_LIBRARY_PATH
michael@0 252 ## to locate shared libraries.
michael@0 253 ##
michael@0 254 ## When a shared library is a symbolic link, $ORIGIN will be replaced with
michael@0 255 ## the real path (i.e., what the symbolic link points to) by the runtime
michael@0 256 ## linker. For example, if dist/bin/libxul.so is a symbolic link to
michael@0 257 ## toolkit/library/libxul.so, $ORIGIN will be "toolkit/library" instead of "dist/bin".
michael@0 258 ## So the runtime linker will use "toolkit/library" NOT "dist/bin" to locate the
michael@0 259 ## other shared libraries that libxul.so depends on. This only happens
michael@0 260 ## when a user (developer) tries to start firefox, thunderbird, or seamonkey
michael@0 261 ## under dist/bin. To solve the problem, we should rely on LD_LIBRARY_PATH
michael@0 262 ## to locate shared libraries.
michael@0 263 ##
michael@0 264 ## Note:
michael@0 265 ## We test $MOZ_DIST_BIN/*.so. If any of them is a symbolic link,
michael@0 266 ## we need to set LD_LIBRARY_PATH.
michael@0 267 ##########################################################################
michael@0 268 moz_should_set_ld_library_path()
michael@0 269 {
michael@0 270 [ `uname -s` != "SunOS" ] && return 0
michael@0 271 for sharedlib in $MOZ_DIST_BIN/*.so
michael@0 272 do
michael@0 273 [ -h $sharedlib ] && return 0
michael@0 274 done
michael@0 275 return 1
michael@0 276 }
michael@0 277 if moz_should_set_ld_library_path
michael@0 278 then
michael@0 279 LD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}
michael@0 280 fi
michael@0 281
michael@0 282 if [ -n "$LD_LIBRARYN32_PATH" ]
michael@0 283 then
michael@0 284 LD_LIBRARYN32_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN32_PATH:+":$LD_LIBRARYN32_PATH"}
michael@0 285 fi
michael@0 286 if [ -n "$LD_LIBRARYN64_PATH" ]
michael@0 287 then
michael@0 288 LD_LIBRARYN64_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN64_PATH:+":$LD_LIBRARYN64_PATH"}
michael@0 289 fi
michael@0 290 if [ -n "$LD_LIBRARY_PATH_64" ]; then
michael@0 291 LD_LIBRARY_PATH_64=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH_64:+":$LD_LIBRARY_PATH_64"}
michael@0 292 fi
michael@0 293 #
michael@0 294 #
michael@0 295 ## Set SHLIB_PATH for HPUX
michael@0 296 SHLIB_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${SHLIB_PATH:+":$SHLIB_PATH"}
michael@0 297 #
michael@0 298 ## Set LIBPATH for AIX
michael@0 299 LIBPATH=${MOZ_DIST_BIN}:${MRE_HOME}${LIBPATH:+":$LIBPATH"}
michael@0 300 #
michael@0 301 ## Set DYLD_LIBRARY_PATH for Mac OS X (Darwin)
michael@0 302 DYLD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${DYLD_LIBRARY_PATH:+":$DYLD_LIBRARY_PATH"}
michael@0 303 #
michael@0 304 ## Solaris Xserver(Xsun) tuning - use shared memory transport if available
michael@0 305 if [ "$XSUNTRANSPORT" = "" ]
michael@0 306 then
michael@0 307 XSUNTRANSPORT="shmem"
michael@0 308 XSUNSMESIZE="512"
michael@0 309 export XSUNTRANSPORT XSUNSMESIZE
michael@0 310 fi
michael@0 311
michael@0 312 # Disable Gnome crash dialog
michael@0 313 GNOME_DISABLE_CRASH_DIALOG=1
michael@0 314 export GNOME_DISABLE_CRASH_DIALOG
michael@0 315
michael@0 316 if [ "$moz_debug" -eq 1 ]
michael@0 317 then
michael@0 318 echo "MOZILLA_FIVE_HOME=$MOZILLA_FIVE_HOME"
michael@0 319 echo " LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
michael@0 320 if [ -n "$LD_LIBRARYN32_PATH" ]
michael@0 321 then
michael@0 322 echo "LD_LIBRARYN32_PATH=$LD_LIBRARYN32_PATH"
michael@0 323 fi
michael@0 324 if [ -n "$LD_LIBRARYN64_PATH" ]
michael@0 325 then
michael@0 326 echo "LD_LIBRARYN64_PATH=$LD_LIBRARYN64_PATH"
michael@0 327 fi
michael@0 328 if [ -n "$LD_LIBRARY_PATH_64" ]; then
michael@0 329 echo "LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64"
michael@0 330 fi
michael@0 331 if [ -n "$DISPLAY" ]; then
michael@0 332 echo "DISPLAY=$DISPLAY"
michael@0 333 fi
michael@0 334 if [ -n "$FONTCONFIG_PATH" ]; then
michael@0 335 echo "FONTCONFIG_PATH=$FONTCONFIG_PATH"
michael@0 336 fi
michael@0 337 if [ -n "$MOZILLA_POSTSCRIPT_PRINTER_LIST" ]; then
michael@0 338 echo "MOZILLA_POSTSCRIPT_PRINTER_LIST=$MOZILLA_POSTSCRIPT_PRINTER_LIST"
michael@0 339 fi
michael@0 340 echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH"
michael@0 341 echo " LIBRARY_PATH=$LIBRARY_PATH"
michael@0 342 echo " SHLIB_PATH=$SHLIB_PATH"
michael@0 343 echo " LIBPATH=$LIBPATH"
michael@0 344 echo " ADDON_PATH=$ADDON_PATH"
michael@0 345 echo " MOZ_PROGRAM=$MOZ_PROGRAM"
michael@0 346 echo " MOZ_TOOLKIT=$MOZ_TOOLKIT"
michael@0 347 echo " moz_debug=$moz_debug"
michael@0 348 echo " moz_debugger=$moz_debugger"
michael@0 349 echo "moz_debugger_args=$moz_debugger_args"
michael@0 350 fi
michael@0 351 #
michael@0 352 export MOZILLA_FIVE_HOME LD_LIBRARY_PATH
michael@0 353 export SHLIB_PATH LIBPATH LIBRARY_PATH ADDON_PATH DYLD_LIBRARY_PATH
michael@0 354
michael@0 355 if [ $moz_debug -eq 1 ]
michael@0 356 then
michael@0 357 moz_debug_program ${1+"$@"}
michael@0 358 else
michael@0 359 moz_run_program ${1+"$@"}
michael@0 360 fi
michael@0 361
michael@0 362 exit $exitcode

mercurial