Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | import os |
michael@0 | 6 | import sys |
michael@0 | 7 | |
michael@0 | 8 | if len(sys.argv) != 5: |
michael@0 | 9 | print >> sys.stderr, "Usage: copy_source.py " \ |
michael@0 | 10 | "<topsrcdir> <source directory> <target directory> <isb2g>" |
michael@0 | 11 | sys.exit(1) |
michael@0 | 12 | |
michael@0 | 13 | topsrcdir = sys.argv[1] |
michael@0 | 14 | source_dir = sys.argv[2] |
michael@0 | 15 | target_dir = sys.argv[3] |
michael@0 | 16 | isB2G = int(sys.argv[4]) |
michael@0 | 17 | |
michael@0 | 18 | print """ |
michael@0 | 19 | DEPTH = .. |
michael@0 | 20 | topsrcdir = %(topsrcdir)s |
michael@0 | 21 | srcdir = %(topsrcdir)s/addon-sdk |
michael@0 | 22 | VPATH = %(topsrcdir)s/addon-sdk |
michael@0 | 23 | |
michael@0 | 24 | include $(topsrcdir)/config/config.mk |
michael@0 | 25 | """ % {'topsrcdir': topsrcdir} |
michael@0 | 26 | |
michael@0 | 27 | real_source = source_dir.replace('/', os.sep) |
michael@0 | 28 | if not os.path.exists(real_source): |
michael@0 | 29 | print >> sys.stderr, "Error: Missing source file %s" % real_source |
michael@0 | 30 | sys.exit(1) |
michael@0 | 31 | elif not os.path.isdir(real_source): |
michael@0 | 32 | print >> sys.stderr, "Error: Source %s is not a directory" % real_source |
michael@0 | 33 | sys.exit(1) |
michael@0 | 34 | for dirpath, dirnames, filenames in os.walk(real_source): |
michael@0 | 35 | if not filenames: |
michael@0 | 36 | continue |
michael@0 | 37 | dirpath = dirpath.replace(os.sep, '/') |
michael@0 | 38 | relative = dirpath[len(source_dir):] |
michael@0 | 39 | if isB2G and relative in [ |
michael@0 | 40 | '/method/test', |
michael@0 | 41 | '/sdk/ui', |
michael@0 | 42 | '/sdk/ui/button', |
michael@0 | 43 | '/sdk/ui/sidebar', |
michael@0 | 44 | '/sdk/places', |
michael@0 | 45 | '/sdk/places/host', |
michael@0 | 46 | '/sdk/tabs', |
michael@0 | 47 | '/sdk/panel', |
michael@0 | 48 | '/sdk/frame', |
michael@0 | 49 | '/sdk/test', |
michael@0 | 50 | '/sdk/window', |
michael@0 | 51 | '/sdk/windows', |
michael@0 | 52 | '/sdk/deprecated', |
michael@0 | 53 | ]: |
michael@0 | 54 | continue |
michael@0 | 55 | varname = "COMMONJS%s" % relative.replace('/', '_') |
michael@0 | 56 | print "%s_FILES = \\" % varname |
michael@0 | 57 | for name in filenames: |
michael@0 | 58 | print " %s/%s \\" % (dirpath, name) |
michael@0 | 59 | print " $(NULL)" |
michael@0 | 60 | print "%s_DEST = %s%s" % (varname, target_dir, relative) |
michael@0 | 61 | print "INSTALL_TARGETS += %s\n" % varname |
michael@0 | 62 | |
michael@0 | 63 | print "include $(topsrcdir)/config/rules.mk" |