Index: adblockplus/build.py |
=================================================================== |
--- a/adblockplus/build.py |
+++ b/adblockplus/build.py |
@@ -1,43 +1,32 @@ |
#!/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") |
-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, 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]) |
+def build_abp(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) |
+ 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(ABP_DIR, ["", "build", xpi_path]) |
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 |
+ 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) |
- 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) |
+ xpi_path = sys.argv[1] |
+ build_abp(xpi_path) |