addon-sdk/copy_source.py

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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.

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

mercurial