Index: adblockplus/build.py |
=================================================================== |
--- a/adblockplus/build.py |
+++ b/adblockplus/build.py |
@@ -1,32 +1,50 @@ |
#!/usr/bin/env python |
# coding: utf-8 |
import os |
+import shutil |
+import subprocess |
import sys |
+import tempfile |
-BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
-ABP_DIR = os.path.join(BASE_DIR, "adblockplus") |
+_BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
+_ABP_DIR = "adblockplus" |
-def build_abp(xpi_path): |
+def _build_abp(base_dir, xpi_path): |
xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) |
if not os.path.exists(xpi_dir): |
os.makedirs(xpi_dir) |
- sys.path.insert(0, ABP_DIR) |
+ abp_dir = os.path.join(base_dir, _ABP_DIR) |
+ sys.path.insert(0, abp_dir) |
import buildtools.build |
import buildtools.packager |
- def get_metadata_path(base_dir, type): |
- return os.path.join(BASE_DIR, "metadata.gecko") |
+ def get_metadata_path(dir, type): |
+ return os.path.join(base_dir, "metadata.gecko") |
+ |
buildtools.packager.getMetadataPath = get_metadata_path |
- buildtools.build.processArgs(ABP_DIR, ["", "build", xpi_path]) |
+ buildtools.build.processArgs(abp_dir, ["", "build", xpi_path]) |
+ |
+ |
+def _patch_abp(patched_dir): |
+ shutil.copytree(_BASE_DIR, patched_dir) |
+ abp_dir = os.path.join(patched_dir, _ABP_DIR) |
+ subprocess.check_call(["hg", "import", "-q", "-R", |
+ os.path.join(abp_dir, "adblockpluscore"), |
+ os.path.join(patched_dir, "issue-6070.patch")]) |
if __name__ == "__main__": |
if len(sys.argv) < 2: |
error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) |
print >>sys.stderr, error_message |
sys.exit(1) |
xpi_path = sys.argv[1] |
- build_abp(xpi_path) |
+ patched_dir = tempfile.NamedTemporaryFile().name |
+ try: |
+ _patch_abp(patched_dir) |
+ _build_abp(patched_dir, xpi_path) |
+ finally: |
+ shutil.rmtree(patched_dir) |