Move `_patch` method in `Source` class.

The patch method is not specific to a `RealeaseDownload` source.
This commit is contained in:
Matthieu Gautier 2017-05-03 10:52:47 +02:00
parent 5bf04936d9
commit f942c5951f
1 changed files with 8 additions and 7 deletions

View File

@ -82,6 +82,14 @@ class Source:
def source_dir(self): def source_dir(self):
return self.target.full_name return self.target.full_name
def _patch(self, context):
source_path = pj(self.buildEnv.source_dir, self.source_dir)
context.try_skip(source_path)
context.force_native_build = True
for p in self.patches:
with open(pj(SCRIPT_DIR, 'patches', p), 'r') as patch_input:
self.buildEnv.run_command("patch -p1", source_path, context, input=patch_input.read())
def command(self, *args, **kwargs): def command(self, *args, **kwargs):
return self.target.command(*args, **kwargs) return self.target.command(*args, **kwargs)
@ -105,13 +113,6 @@ class ReleaseDownload(Source):
topdir=self.archive_top_dir, topdir=self.archive_top_dir,
name=self.source_dir) name=self.source_dir)
def _patch(self, context):
context.try_skip(self.extract_path)
context.force_native_build = True
for p in self.patches:
with open(pj(SCRIPT_DIR, 'patches', p), 'r') as patch_input:
self.buildEnv.run_command("patch -p1", self.extract_path, context, input=patch_input.read())
def prepare(self): def prepare(self):
self.command('download', self._download) self.command('download', self._download)
self.command('extract', self._extract) self.command('extract', self._extract)