Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: adblockplus/build.py

Issue 29617588: Issue 6070 - Filter list not loaded after install without internet (Closed)
Patch Set: Created Nov. 24, 2017, 11:17 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | adblockplus/issue-6070.patch » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 import os 4 import os
5 import shutil
6 import subprocess
5 import sys 7 import sys
8 import tempfile
6 9
7 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 10 _BASE_DIR = os.path.dirname(os.path.abspath(__file__))
8 ABP_DIR = os.path.join(BASE_DIR, "adblockplus") 11 _ABP_DIR = "adblockplus"
9 12
10 13
11 def build_abp(xpi_path): 14 def _build_abp(base_dir, xpi_path):
12 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) 15 xpi_dir = os.path.dirname(os.path.abspath(xpi_path))
13 if not os.path.exists(xpi_dir): 16 if not os.path.exists(xpi_dir):
14 os.makedirs(xpi_dir) 17 os.makedirs(xpi_dir)
15 18
16 sys.path.insert(0, ABP_DIR) 19 abp_dir = os.path.join(base_dir, _ABP_DIR)
20 sys.path.insert(0, abp_dir)
17 import buildtools.build 21 import buildtools.build
18 import buildtools.packager 22 import buildtools.packager
19 23
20 def get_metadata_path(base_dir, type): 24 def get_metadata_path(dir, type):
21 return os.path.join(BASE_DIR, "metadata.gecko") 25 return os.path.join(base_dir, "metadata.gecko")
26
22 buildtools.packager.getMetadataPath = get_metadata_path 27 buildtools.packager.getMetadataPath = get_metadata_path
23 buildtools.build.processArgs(ABP_DIR, ["", "build", xpi_path]) 28 buildtools.build.processArgs(abp_dir, ["", "build", xpi_path])
29
30
31 def _patch_abp(patched_dir):
32 shutil.copytree(_BASE_DIR, patched_dir)
33 abp_dir = os.path.join(patched_dir, _ABP_DIR)
34 subprocess.check_call(["hg", "import", "-q", "-R",
35 os.path.join(abp_dir, "adblockpluscore"),
36 os.path.join(patched_dir, "issue-6070.patch")])
24 37
25 if __name__ == "__main__": 38 if __name__ == "__main__":
26 if len(sys.argv) < 2: 39 if len(sys.argv) < 2:
27 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) 40 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0])
28 print >>sys.stderr, error_message 41 print >>sys.stderr, error_message
29 sys.exit(1) 42 sys.exit(1)
30 43
31 xpi_path = sys.argv[1] 44 xpi_path = sys.argv[1]
32 build_abp(xpi_path) 45 patched_dir = tempfile.NamedTemporaryFile().name
46 try:
47 _patch_abp(patched_dir)
48 _build_abp(patched_dir, xpi_path)
49 finally:
50 shutil.rmtree(patched_dir)
OLDNEW
« no previous file with comments | « no previous file | adblockplus/issue-6070.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld