| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # coding: utf-8 | 2 # coding: utf-8 |
| 3 | 3 |
| 4 # This file is part of Adblock Plus <https://adblockplus.org/>, |
| 5 # Copyright (C) 2006-present eyeo GmbH |
| 6 # |
| 7 # Adblock Plus is free software: you can redistribute it and/or modify |
| 8 # it under the terms of the GNU General Public License version 3 as |
| 9 # published by the Free Software Foundation. |
| 10 # |
| 11 # Adblock Plus is distributed in the hope that it will be useful, |
| 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 # GNU General Public License for more details. |
| 15 # |
| 16 # You should have received a copy of the GNU General Public License |
| 17 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
| 4 import os | 19 import os |
| 5 import sys | 20 import sys |
| 6 | 21 |
| 7 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 22 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 8 ABP_DIR = os.path.join(BASE_DIR, "adblockplus") | 23 ABP_DIR = os.path.join(BASE_DIR, "adblockplus") |
| 9 | 24 |
| 10 | 25 |
| 11 def build_abp(xpi_path): | 26 def build_abp(xpi_path): |
| 12 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) | 27 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) |
| 13 if not os.path.exists(xpi_dir): | 28 if not os.path.exists(xpi_dir): |
| 14 os.makedirs(xpi_dir) | 29 os.makedirs(xpi_dir) |
| 15 | 30 |
| 16 sys.path.insert(0, ABP_DIR) | 31 sys.path.insert(0, ABP_DIR) |
| 17 import buildtools.build | 32 import buildtools.build |
| 18 import buildtools.packager | 33 import buildtools.packager |
| 19 | 34 |
| 20 def get_metadata_path(base_dir, type): | 35 def get_metadata_path(base_dir, type): |
| 21 return os.path.join(BASE_DIR, "metadata.gecko") | 36 return os.path.join(BASE_DIR, "metadata.gecko") |
| 22 buildtools.packager.getMetadataPath = get_metadata_path | 37 buildtools.packager.getMetadataPath = get_metadata_path |
| 23 buildtools.build.processArgs(ABP_DIR, ["", "build", xpi_path]) | 38 buildtools.build.processArgs(ABP_DIR, ["", "build", xpi_path]) |
| 24 | 39 |
| 25 if __name__ == "__main__": | 40 if __name__ == "__main__": |
| 26 if len(sys.argv) < 2: | 41 if len(sys.argv) < 2: |
| 27 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) | 42 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) |
| 28 print >>sys.stderr, error_message | 43 print >>sys.stderr, error_message |
| 29 sys.exit(1) | 44 sys.exit(1) |
| 30 | 45 |
| 31 xpi_path = sys.argv[1] | 46 xpi_path = sys.argv[1] |
| 32 build_abp(xpi_path) | 47 build_abp(xpi_path) |
| OLD | NEW |