Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: adblockplus/build.py

Issue 29863604: Issue 6865 - Update ABP dependency to version 3.2 (Closed)
Left Patch Set: Removing patch file Created Aug. 24, 2018, 8:41 p.m.
Right Patch Set: Adjusting code style Created Jan. 16, 2019, 1:45 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | adblockplus/extensionBridge.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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/>, 4 # This file is part of Adblock Plus <https://adblockplus.org/>,
5 # Copyright (C) 2006-present eyeo GmbH 5 # Copyright (C) 2006-present eyeo GmbH
6 # 6 #
7 # Adblock Plus is free software: you can redistribute it and/or modify 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 8 # it under the terms of the GNU General Public License version 3 as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
10 # 10 #
11 # Adblock Plus is distributed in the hope that it will be useful, 11 # Adblock Plus is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details. 14 # GNU General Public License for more details.
15 # 15 #
16 # You should have received a copy of the GNU General Public License 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/>. 17 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
18 18
19 import os 19 import os
20 import shutil 20 import shutil
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 import tempfile 23 import tempfile
24 24
25 _BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 25 _BASE_DIR_PATH = os.path.dirname(os.path.abspath(__file__))
26 _ABP_DIR = "adblockpluschrome" 26 _ABP_DIR = "adblockpluschrome"
27 _ABP_CORE_DIR = "adblockpluscore" 27 _ABP_CORE_DIR = "adblockpluscore"
28 _ABP_UI_DIR = "adblockplusui" 28 _SUBSCRIPTIONS_PATH = os.path.join(_BASE_DIR_PATH, _ABP_DIR, _ABP_CORE_DIR,
29 29 "chrome", "content", "ui",
30 def _copy_subscriptions(xpi_path): 30 "subscriptions.xml")
31 xpi_dir = os.path.dirname(xpi_path)
32 subscriptions_file = os.path.join(_BASE_DIR, _ABP_DIR, _ABP_UI_DIR,
33 "subscriptions.xml")
Thomas Greiner 2018/08/27 15:24:41 The canonical version of subscriptions.xml is loca
diegocarloslima 2018/08/27 21:19:16 Acknowledged.
34 shutil.copy2(subscriptions_file, xpi_dir)
35 31
36 32
37 def _patch_abp(patched_dir): 33 def _import_issue_patch(src_path, patched_path, issue_name):
38 shutil.copytree(_BASE_DIR, patched_dir) 34 patch_filename = "issue-%s.patch" % issue_name
39 abp_dir = os.path.join(patched_dir, _ABP_DIR) 35 subprocess.check_call(["hg", "import", "-q", "-R", src_path,
40 abp_core_dir = os.path.join(abp_dir, _ABP_CORE_DIR) 36 os.path.join(patched_path, patch_filename)])
41 subprocess.check_call(["hg", "import", "-q", "-R", abp_core_dir,
42 os.path.join(patched_dir, "issue-6070.patch")])
43 37
44 def _build_abp(base_dir, xpi_path):
45 xpi_dir = os.path.dirname(os.path.abspath(xpi_path))
46 if not os.path.exists(xpi_dir):
47 os.makedirs(xpi_dir)
48 38
49 abp_dir = os.path.join(base_dir, _ABP_DIR) 39 def _patch_abp(patched_path):
50 sys.path.insert(0, abp_dir) 40 shutil.copytree(_BASE_DIR_PATH, patched_path)
41 abp_path = os.path.join(patched_path, _ABP_DIR)
42 abp_core_path = os.path.join(abp_path, _ABP_CORE_DIR)
43 _import_issue_patch(abp_core_path, patched_path, "6070")
44 _import_issue_patch(abp_path, patched_path, "6865")
45
46
47 def _build_abp(base_path, xpi_path):
48 xpi_dir_path = os.path.dirname(xpi_path)
49 if not os.path.exists(xpi_dir_path):
50 os.makedirs(xpi_dir_path)
51
52 abp_dir_path = os.path.join(base_path, _ABP_DIR)
53 sys.path.insert(0, abp_dir_path)
51 import buildtools.build as tools_build 54 import buildtools.build as tools_build
52 import buildtools.packager as tools_packager 55 import buildtools.packager as tools_packager
53 56
54 def get_metadata_path(dir, type): 57 def get_metadata_path(dir, type):
55 return os.path.join(base_dir, "metadata.gecko") 58 return os.path.join(base_path, "metadata.gecko")
56 59
57 tools_packager.getMetadataPath = get_metadata_path 60 tools_packager.getMetadataPath = get_metadata_path
58 tools_build.process_args(abp_dir, "build", "-t", "gecko", "-r", xpi_path) 61 tools_build.process_args(abp_dir_path, "build", "-t", "gecko", "-r",
62 xpi_path)
63
64
65 def _copy_subscriptions(xpi_path):
66 xpi_dir_path = os.path.dirname(xpi_path)
67 shutil.copy2(_SUBSCRIPTIONS_PATH, xpi_dir_path)
68
59 69
60 if __name__ == "__main__": 70 if __name__ == "__main__":
61 if len(sys.argv) < 2: 71 if len(sys.argv) < 2:
62 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) 72 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0])
63 print >>sys.stderr, error_message 73 print >>sys.stderr, error_message
64 sys.exit(1) 74 sys.exit(1)
65 75
66 xpi_path = sys.argv[1] 76 xpi_path = os.path.abspath(sys.argv[1])
67 patched_dir = tempfile.NamedTemporaryFile().name 77 patched_path = tempfile.NamedTemporaryFile().name
68 try: 78 try:
79 _patch_abp(patched_path)
80 _build_abp(patched_path, xpi_path)
69 _copy_subscriptions(xpi_path) 81 _copy_subscriptions(xpi_path)
70 _patch_abp(patched_dir)
71 _build_abp(patched_dir, xpi_path)
72 finally: 82 finally:
73 shutil.rmtree(patched_dir) 83 shutil.rmtree(patched_path)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld