summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-07-06 19:06:02 +0530
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-07-07 15:18:16 +0000
commitca1a5ae952206b60f40adf643878db4fed42ca38 (patch)
treefe8628e06e995ac81e27dbbe9c99e501b9ba7f01
parent270ced20f45933c1a305149cf0d7b676180024d9 (diff)
cerbero: Allow changing tarball_name dynamically
You could only set self.tarball_name in a recipe in the definition. It could not be changed in prepare(). With this, it can be done. Needed for selecting debug-crt vs release-crt binaries for ANGLE (next commit). Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/538>
-rw-r--r--cerbero/build/source.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/cerbero/build/source.py b/cerbero/build/source.py
index 7ed0c578..f401c960 100644
--- a/cerbero/build/source.py
+++ b/cerbero/build/source.py
@@ -161,7 +161,6 @@ class BaseTarball(object):
def __init__(self):
if not self.tarball_name:
self.tarball_name = os.path.basename(self.url)
- self.download_path = os.path.join(self.download_dir, self.tarball_name)
# URL-encode spaces and other special characters in the URL's path
split = list(urllib.parse.urlsplit(self.url))
split[2] = urllib.parse.quote(split[2])
@@ -170,23 +169,31 @@ class BaseTarball(object):
if o.scheme in ('http', 'ftp'):
raise FatalError('Download URL {!r} must use HTTPS'.format(self.url))
+ def _get_download_path(self):
+ '''
+ Fetch download path dynamically because self.tarball_name may be
+ reset in prepare()
+ '''
+ return os.path.join(self.download_dir, self.tarball_name)
+
async def fetch(self, redownload=False):
+ fname = self._get_download_path()
if self.offline:
- if not os.path.isfile(self.download_path):
+ if not os.path.isfile(fname):
msg = 'Offline mode: tarball {!r} not found in local sources ({})'
raise FatalError(msg.format(self.tarball_name, self.download_dir))
- self.verify(self.download_path)
- m.action(_('Found %s at %s') % (self.url, self.download_path), logfile=get_logfile(self))
+ self.verify(fname)
+ m.action(_('Found %s at %s') % (self.url, fname), logfile=get_logfile(self))
return
if not os.path.exists(self.download_dir):
os.makedirs(self.download_dir)
# Enable certificate checking only on Linux for now
# FIXME: Add more platforms here after testing
cc = self.config.platform == Platform.LINUX
- await shell.download(self.url, self.download_path, check_cert=cc,
+ await shell.download(self.url, fname, check_cert=cc,
overwrite=redownload, logfile=get_logfile(self),
mirrors= self.config.extra_mirrors + DEFAULT_MIRRORS)
- self.verify(self.download_path)
+ self.verify(fname)
@staticmethod
def _checksum(fname):
@@ -215,7 +222,7 @@ class BaseTarball(object):
return True
async def extract_tarball(self, unpack_dir):
- fname = self.download_path
+ fname = self._get_download_path()
logfile = get_logfile(self)
try:
await shell.unpack(fname, unpack_dir, logfile=logfile)
@@ -250,6 +257,7 @@ class Tarball(BaseTarball, Source):
BaseTarball.__init__(self)
async def fetch(self, redownload=False):
+ fname = self._get_download_path()
if not os.path.exists(self.download_dir):
os.makedirs(self.download_dir)
@@ -257,8 +265,8 @@ class Tarball(BaseTarball, Source):
self.package_name, self.tarball_name)
if not redownload and os.path.isfile(cached_file) and self.verify(cached_file, fatal=False):
m.action(_('Copying cached tarball from %s to %s instead of %s') %
- (cached_file, self.download_path, self.url), logfile=get_logfile(self))
- shutil.copy(cached_file, self.download_path)
+ (cached_file, fname, self.url), logfile=get_logfile(self))
+ shutil.copy(cached_file, fname)
return
await super().fetch(redownload=redownload)