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

Delta Between Two Patch Sets: adblockplus/build.py

Issue 6238034718621696: Issue 2483 - Give Adblock Browser its own app ID (Closed)
Left Patch Set: Created May 14, 2015, 3:21 p.m.
Right Patch Set: Address additional comments Created May 18, 2015, 7:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | adblockplus/issue-2509.patch » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 5 import shutil
6 import subprocess
6 import sys 7 import sys
8 import tempfile
7 9
8 BUILD_DIR = os.path.dirname(os.path.abspath(__file__)) 10 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
9 BASE_DIR = os.path.join(BUILD_DIR, "adblockplus") 11 ABP_DIR = os.path.join(BASE_DIR, "adblockplus")
10 12
11 def build_abp(base_dir, xpi_path): 13 def build_abp(base_dir, xpi_path):
12 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) 14 xpi_dir = os.path.dirname(os.path.abspath(xpi_path))
13 if not os.path.exists(xpi_dir): 15 if not os.path.exists(xpi_dir):
14 os.mkdir(xpi_dir) 16 os.makedirs(xpi_dir)
Wladimir Palant 2015/05/15 19:16:16 os.makedirs() please - you don't know whether its
Felix Dahlke 2015/05/15 22:09:08 Done.
15 17
16 sys.path.insert(0, base_dir) 18 sys.path.insert(0, base_dir)
17 import buildtools.build 19 import buildtools.build
18 import buildtools.packager 20 import buildtools.packager
19 def get_metadata_path(base_dir, type): 21 def get_metadata_path(base_dir, type):
20 return os.path.join(BUILD_DIR, "metadata.gecko") 22 return os.path.join(BASE_DIR, "metadata.gecko")
21 buildtools.packager.getMetadataPath = get_metadata_path 23 buildtools.packager.getMetadataPath = get_metadata_path
Wladimir Palant 2015/05/15 19:16:16 Funny how you replace getMetadataPath yet use a pa
Felix Dahlke 2015/05/15 22:09:08 Sticking to applying the issue 2509 patch file as
22 buildtools.build.processArgs(base_dir, ["", "build", xpi_path]) 24 buildtools.build.processArgs(base_dir, ["", "build", xpi_path])
23 25
24 if __name__ == "__main__": 26 if __name__ == "__main__":
25 if len(sys.argv) < 2: 27 if len(sys.argv) < 2:
26 print "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) 28 print >>sys.stderr, "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0])
27 sys.exit(1) 29 sys.exit(1)
28 30
29 xpi_path = sys.argv[1] 31 xpi_path = sys.argv[1]
30 patched_base_dir = os.path.join(os.sep, "tmp", 32 patched_abp_dir = tempfile.NamedTemporaryFile().name
31 "adblockplus-patched-%s" % os.getpid()) 33
Wladimir Palant 2015/05/15 19:16:16 Please use tempfile.mkdtemp(), even though Windows
Felix Dahlke 2015/05/15 22:09:08 Forgot about tempfile, much nicer indeed. Ended up
32 shutil.copytree(BASE_DIR, patched_base_dir) 34 shutil.copytree(ABP_DIR, patched_abp_dir)
33 try: 35 try:
34 os.system('patch -s -p1 -d "%s/buildtools" < "%s/issue-2509.patch"' % ( 36 subprocess.check_call(["hg", "import", "-q", "-R",
35 patched_base_dir, BUILD_DIR)) 37 os.path.join(patched_abp_dir, "buildtools"),
36 os.system('patch -s -p1 -d "%s" < "%s/issue-2510.patch"' % ( 38 os.path.join(BASE_DIR, "issue-2509.patch")]),
37 patched_base_dir, BUILD_DIR)) 39 subprocess.check_call(["hg", "import", "-q", "-R", patched_abp_dir,
Wladimir Palant 2015/05/15 19:16:16 1) Call hg import maybe? 2) Please use subprocess.
Felix Dahlke 2015/05/15 22:09:08 Done.
38 build_abp(patched_base_dir, xpi_path) 40 os.path.join(BASE_DIR, "issue-2510.patch")]),
41 build_abp(patched_abp_dir, xpi_path)
39 finally: 42 finally:
40 shutil.rmtree(patched_base_dir) 43 shutil.rmtree(patched_abp_dir)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld