From d521eeccc47497d17fed90596fa73d89de9da3a4 Mon Sep 17 00:00:00 2001 From: Eloston Date: Wed, 20 Jul 2016 21:17:59 -0700 Subject: [PATCH] Allow source unpacking without a cleaning list Use member values for source downloading functions --- building/debian.py | 12 +++++++----- building/generic.py | 15 +++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/building/debian.py b/building/debian.py index 7611f972..4090e1c3 100644 --- a/building/debian.py +++ b/building/debian.py @@ -47,12 +47,14 @@ class DebianPlatform(generic.GenericPlatform): def generate_debian_tar_xz(self, tar_xz_path): pass - def setup_chromium_source(cleaning_list=pathlib.Path("cleaning_list"), debian_cleaning_list=(PLATFORM_RESOURCES / pathlib.Path("cleaning_list")), **kwargs): + def setup_chromium_source(self, cleaning_list=pathlib.Path("cleaning_list"), debian_cleaning_list=(PLATFORM_RESOURCES / pathlib.Path("cleaning_list")), **kwargs): tmp = tempfile.SpooledTemporaryFile(mode="w+") - with cleaning_list.open() as f: - tmp.write(f.read()) - with debian_cleaning_list.open() as f: - tmp.write(f.read()) + if not cleaning_list is None: + with cleaning_list.open() as f: + tmp.write(f.read()) + if not debian_cleaning_list is None: + with debian_cleaning_list.open() as f: + tmp.write(f.read()) tmp.seek(0) tmp.open = lambda: tmp super(DebianPlatform, self).setup_chromium_source(cleaning_list=tmp, **kwargs) diff --git a/building/generic.py b/building/generic.py index 90700793..f1212e71 100644 --- a/building/generic.py +++ b/building/generic.py @@ -88,19 +88,19 @@ class GenericPlatform: else: self.logger.warning("Hash algorithm '{}' not available. Skipping...".format(hash_line[0])) - def _download_source_archive(self, archive_path): + def _download_source_archive(self): ''' Downloads the original Chromium source code in .tar.xz format ''' download_url = "https://commondatastorage.googleapis.com/chromium-browser-official/chromium-{version}.tar.xz".format(version=self.version) with urllib.request.urlopen(download_url) as response: - with archive_path.open("wb") as f: + with self.sourcearchive.open("wb") as f: shutil.copyfileobj(response, f) - def _download_source_hashes(self, hashes_path): + def _download_source_hashes(self): hashes_url = "https://commondatastorage.googleapis.com/chromium-browser-official/chromium-{version}.tar.xz.hashes".format(version=self.version) with urllib.request.urlopen(hashes_url) as response: - with hashes_path.open("wb") as f: + with self.sourcearchive_hashes.open("wb") as f: shutil.copyfileobj(response, f) def _extract_source_archive(self, cleaning_list): @@ -277,8 +277,11 @@ class GenericPlatform: if extract_archive: self.logger.info("Extracting source archive into building sandbox...") - with cleaning_list.open() as f: - self._extract_source_archive([x for x in f.read().splitlines() if x != ""]) + if cleaning_list is None: + self._extract_source_archive(list()) + else: + with cleaning_list.open() as f: + self._extract_source_archive([x for x in f.read().splitlines() if x != ""]) def setup_build_sandbox(self, run_domain_substitution=True, domain_regexes=pathlib.Path("domain_regex_list"), domain_sub_list=pathlib.Path("domain_substitution_list")): '''