| Left: | ||
| Right: |
| 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 | |
| 5 import sys | 6 import sys |
| 6 | 7 |
| 7 import buildtools.build | |
| 8 import buildtools.packager | |
| 9 | |
| 10 BUILD_DIR = os.path.dirname(os.path.abspath(__file__)) | 8 BUILD_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 11 BASE_DIR = os.path.join(BUILD_DIR, "adblockplus") | 9 BASE_DIR = os.path.join(BUILD_DIR, "adblockplus") |
| 12 | 10 |
| 13 def getMetadataPath(baseDir, type): | 11 def build_abp(base_dir, xpi_path): |
| 14 return os.path.join(BUILD_DIR, "metadata.gecko") | 12 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) |
| 13 if not os.path.exists(xpi_dir): | |
| 14 os.mkdir(xpi_dir) | |
|
Wladimir Palant
2015/05/15 19:16:16
os.makedirs() please - you don't know whether its
Felix Dahlke
2015/05/15 22:09:08
Done.
| |
| 15 | 15 |
| 16 buildtools.packager.getMetadataPath = getMetadataPath | 16 sys.path.insert(0, base_dir) |
| 17 buildtools.build.processArgs(BASE_DIR, sys.argv) | 17 import buildtools.build |
| 18 import buildtools.packager | |
| 19 def get_metadata_path(base_dir, type): | |
| 20 return os.path.join(BUILD_DIR, "metadata.gecko") | |
| 21 buildtools.packager.getMetadataPath = get_metadata_path | |
|
Wladimir Palant
2015/05/15 19:16:16
Funny how you replace getMetadataPath yet use a pa
Felix Dahlke
2015/05/15 22:09:08
Sticking to applying the issue 2509 patch file as
| |
| 22 buildtools.build.processArgs(base_dir, ["", "build", xpi_path]) | |
| 23 | |
| 24 if __name__ == "__main__": | |
| 25 if len(sys.argv) < 2: | |
| 26 print "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) | |
| 27 sys.exit(1) | |
| 28 | |
| 29 xpi_path = sys.argv[1] | |
| 30 patched_base_dir = os.path.join(os.sep, "tmp", | |
| 31 "adblockplus-patched-%s" % os.getpid()) | |
|
Wladimir Palant
2015/05/15 19:16:16
Please use tempfile.mkdtemp(), even though Windows
Felix Dahlke
2015/05/15 22:09:08
Forgot about tempfile, much nicer indeed. Ended up
| |
| 32 shutil.copytree(BASE_DIR, patched_base_dir) | |
| 33 try: | |
| 34 os.system('patch -s -p1 -d "%s/buildtools" < "%s/issue-2509.patch"' % ( | |
| 35 patched_base_dir, BUILD_DIR)) | |
| 36 os.system('patch -s -p1 -d "%s" < "%s/issue-2510.patch"' % ( | |
| 37 patched_base_dir, BUILD_DIR)) | |
|
Wladimir Palant
2015/05/15 19:16:16
1) Call hg import maybe?
2) Please use subprocess.
Felix Dahlke
2015/05/15 22:09:08
Done.
| |
| 38 build_abp(patched_base_dir, xpi_path) | |
| 39 finally: | |
| 40 shutil.rmtree(patched_base_dir) | |
| OLD | NEW |