Index: adblockplus/build.py |
=================================================================== |
--- a/adblockplus/build.py |
+++ b/adblockplus/build.py |
@@ -2,16 +2,42 @@ |
# coding: utf-8 |
import os |
+import shutil |
+import subprocess |
import sys |
+import tempfile |
-import buildtools.build |
-import buildtools.packager |
+BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
+ABP_DIR = os.path.join(BASE_DIR, "adblockplus") |
-BUILD_DIR = os.path.dirname(os.path.abspath(__file__)) |
-BASE_DIR = os.path.join(BUILD_DIR, "adblockplus") |
+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) |
-def getMetadataPath(baseDir, type): |
- return os.path.join(BUILD_DIR, "metadata.gecko") |
+ sys.path.insert(0, base_dir) |
+ import buildtools.build |
+ import buildtools.packager |
+ def get_metadata_path(base_dir, type): |
+ return os.path.join(BASE_DIR, "metadata.gecko") |
+ buildtools.packager.getMetadataPath = get_metadata_path |
+ buildtools.build.processArgs(base_dir, ["", "build", xpi_path]) |
-buildtools.packager.getMetadataPath = getMetadataPath |
-buildtools.build.processArgs(BASE_DIR, sys.argv) |
+if __name__ == "__main__": |
+ if len(sys.argv) < 2: |
+ print >>sys.stderr, "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) |
+ sys.exit(1) |
+ |
+ xpi_path = sys.argv[1] |
+ patched_abp_dir = tempfile.NamedTemporaryFile().name |
+ |
+ shutil.copytree(ABP_DIR, patched_abp_dir) |
+ try: |
+ subprocess.check_call(["hg", "import", "-q", "-R", |
+ os.path.join(patched_abp_dir, "buildtools"), |
+ os.path.join(BASE_DIR, "issue-2509.patch")]), |
+ subprocess.check_call(["hg", "import", "-q", "-R", patched_abp_dir, |
+ os.path.join(BASE_DIR, "issue-2510.patch")]), |
+ build_abp(patched_abp_dir, xpi_path) |
+ finally: |
+ shutil.rmtree(patched_abp_dir) |