Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 subprocess |
7 import sys | 7 import sys |
8 import tempfile | 8 import tempfile |
9 | 9 |
10 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 10 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
Felix Dahlke
2015/05/15 22:09:08
Realised the naming here was inconsistent with our
| |
11 ABP_DIR = os.path.join(BASE_DIR, "adblockplus") | 11 ABP_DIR = os.path.join(BASE_DIR, "adblockplus") |
12 | 12 |
13 def build_abp(base_dir, xpi_path): | 13 def build_abp(base_dir, xpi_path): |
14 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) | 14 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) |
15 if not os.path.exists(xpi_dir): | 15 if not os.path.exists(xpi_dir): |
16 os.makedirs(xpi_dir) | 16 os.makedirs(xpi_dir) |
17 | 17 |
18 sys.path.insert(0, base_dir) | 18 sys.path.insert(0, base_dir) |
19 import buildtools.build | 19 import buildtools.build |
20 import buildtools.packager | 20 import buildtools.packager |
21 def get_metadata_path(base_dir, type): | 21 def get_metadata_path(base_dir, type): |
22 return os.path.join(BASE_DIR, "metadata.gecko") | 22 return os.path.join(BASE_DIR, "metadata.gecko") |
23 buildtools.packager.getMetadataPath = get_metadata_path | 23 buildtools.packager.getMetadataPath = get_metadata_path |
24 buildtools.build.processArgs(base_dir, ["", "build", xpi_path]) | 24 buildtools.build.processArgs(base_dir, ["", "build", xpi_path]) |
25 | 25 |
26 if __name__ == "__main__": | 26 if __name__ == "__main__": |
27 if len(sys.argv) < 2: | 27 if len(sys.argv) < 2: |
28 print >>sys.stderr, "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) | |
28 sys.exit(1) | 29 sys.exit(1) |
Wladimir Palant
2015/05/18 11:01:22
Exiting without an error message is strange, why d
Felix Dahlke
2015/05/18 19:43:28
Oops, forgot that one.
| |
29 | 30 |
30 xpi_path = sys.argv[1] | 31 xpi_path = sys.argv[1] |
31 patched_abp_dir = tempfile.NamedTemporaryFile().name | 32 patched_abp_dir = tempfile.NamedTemporaryFile().name |
32 | 33 |
33 shutil.copytree(ABP_DIR, patched_abp_dir) | 34 shutil.copytree(ABP_DIR, patched_abp_dir) |
34 try: | 35 try: |
35 subprocess.call( | 36 subprocess.check_call(["hg", "import", "-q", "-R", |
36 ["hg", "import", "-q", os.path.join(BASE_DIR, "issue-2509.patch")], | 37 os.path.join(patched_abp_dir, "buildtools"), |
37 cwd=os.path.join(patched_abp_dir, "buildtools")) | 38 os.path.join(BASE_DIR, "issue-2509.patch")]), |
Wladimir Palant
2015/05/18 11:01:22
I'd prefer -R parameter instead of cwd but doesn't
Felix Dahlke
2015/05/18 19:43:28
Yeah that's nicer, done.
| |
38 subprocess.call( | 39 subprocess.check_call(["hg", "import", "-q", "-R", patched_abp_dir, |
39 ["hg", "import", "-q", os.path.join(BASE_DIR, "issue-2510.patch")], | 40 os.path.join(BASE_DIR, "issue-2510.patch")]), |
40 cwd=patched_abp_dir) | |
41 build_abp(patched_abp_dir, xpi_path) | 41 build_abp(patched_abp_dir, xpi_path) |
42 finally: | 42 finally: |
43 shutil.rmtree(patched_abp_dir) | 43 shutil.rmtree(patched_abp_dir) |
LEFT | RIGHT |