| OLD | NEW |
| 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 | |
| 7 import sys | 5 import sys |
| 8 import tempfile | |
| 9 | 6 |
| 10 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 7 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 11 ABP_DIR = os.path.join(BASE_DIR, "adblockplus") | 8 ABP_DIR = os.path.join(BASE_DIR, "adblockplus") |
| 12 | 9 |
| 13 def build_abp(base_dir, xpi_path): | |
| 14 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) | |
| 15 if not os.path.exists(xpi_dir): | |
| 16 os.makedirs(xpi_dir) | |
| 17 | 10 |
| 18 sys.path.insert(0, base_dir) | 11 def build_abp(xpi_path): |
| 19 import buildtools.build | 12 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) |
| 20 import buildtools.packager | 13 if not os.path.exists(xpi_dir): |
| 21 def get_metadata_path(base_dir, type): | 14 os.makedirs(xpi_dir) |
| 22 return os.path.join(BASE_DIR, "metadata.gecko") | 15 |
| 23 buildtools.packager.getMetadataPath = get_metadata_path | 16 sys.path.insert(0, ABP_DIR) |
| 24 buildtools.build.processArgs(base_dir, ["", "build", xpi_path]) | 17 import buildtools.build |
| 18 import buildtools.packager |
| 19 |
| 20 def get_metadata_path(base_dir, type): |
| 21 return os.path.join(BASE_DIR, "metadata.gecko") |
| 22 buildtools.packager.getMetadataPath = get_metadata_path |
| 23 buildtools.build.processArgs(ABP_DIR, ["", "build", xpi_path]) |
| 25 | 24 |
| 26 if __name__ == "__main__": | 25 if __name__ == "__main__": |
| 27 if len(sys.argv) < 2: | 26 if len(sys.argv) < 2: |
| 28 print >>sys.stderr, "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) | 27 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) |
| 29 sys.exit(1) | 28 print >>sys.stderr, error_message |
| 29 sys.exit(1) |
| 30 | 30 |
| 31 xpi_path = sys.argv[1] | 31 xpi_path = sys.argv[1] |
| 32 patched_abp_dir = tempfile.NamedTemporaryFile().name | 32 build_abp(xpi_path) |
| 33 | |
| 34 shutil.copytree(ABP_DIR, patched_abp_dir) | |
| 35 try: | |
| 36 subprocess.check_call(["hg", "import", "-q", "-R", | |
| 37 os.path.join(patched_abp_dir, "buildtools"), | |
| 38 os.path.join(BASE_DIR, "issue-2509.patch")]), | |
| 39 subprocess.check_call(["hg", "import", "-q", "-R", patched_abp_dir, | |
| 40 os.path.join(BASE_DIR, "issue-2510.patch")]), | |
| 41 build_abp(patched_abp_dir, xpi_path) | |
| 42 finally: | |
| 43 shutil.rmtree(patched_abp_dir) | |
| OLD | NEW |