summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2019-09-25 12:53:49 +1000
committerNirbheek Chauhan <nirbheek@centricular.com>2019-10-31 18:31:53 +0530
commitbddd67c3ee06accf38f23b879e09151fd3d7a507 (patch)
tree8e2146c649ff01045f4456fd0d58c3e00dd70dc4
parentb3e47b85d6e28c8fc0c430bf49f606a5734e9e1f (diff)
convert extract command to async
-rw-r--r--cerbero/build/source.py30
-rw-r--r--cerbero/commands/fetch.py2
-rw-r--r--cerbero/utils/git.py4
-rw-r--r--cerbero/utils/shell.py4
-rw-r--r--recipes/build-tools/bison.recipe4
-rw-r--r--recipes/build-tools/libtool.recipe4
-rw-r--r--recipes/build-tools/wix.recipe4
-rw-r--r--recipes/libusrsctp.recipe4
8 files changed, 28 insertions, 28 deletions
diff --git a/cerbero/build/source.py b/cerbero/build/source.py
index ae7603b5..a7537005 100644
--- a/cerbero/build/source.py
+++ b/cerbero/build/source.py
@@ -70,7 +70,7 @@ class Source (object):
'''
raise NotImplemented("'fetch' must be implemented by subclasses")
- def extract(self):
+ async def extract(self):
'''
Extracts the sources
'''
@@ -123,7 +123,7 @@ class CustomSource (Source):
async def fetch(self):
pass
- def extract(self):
+ async def extract(self):
pass
@@ -201,13 +201,13 @@ class BaseTarball(object):
.format(fname, checksum, self.tarball_checksum))
return True
- def extract_tarball(self, unpack_dir):
+ async def extract_tarball(self, unpack_dir):
try:
- shell.unpack(self.download_path, unpack_dir, logfile=get_logfile(self))
+ await shell.unpack(self.download_path, unpack_dir, logfile=get_logfile(self))
except (IOError, EOFError, tarfile.ReadError):
m.action(_('Corrupted or partial tarball, redownloading...'))
- run_until_complete(self.fetch(redownload=True))
- shell.unpack(self.download_path, unpack_dir, logfile=get_logfile(self))
+ await self.fetch(redownload=True)
+ await shell.unpack(self.download_path, unpack_dir, logfile=get_logfile(self))
class Tarball(BaseTarball, Source):
@@ -241,11 +241,11 @@ class Tarball(BaseTarball, Source):
return
await super().fetch(redownload=redownload)
- def extract(self):
+ async def extract(self):
m.action(_('Extracting tarball to %s') % self.build_dir)
if os.path.exists(self.build_dir):
shutil.rmtree(self.build_dir)
- self.extract_tarball(self.config.sources)
+ await self.extract_tarball(self.config.sources)
if self.tarball_dirname is not None:
extracted = os.path.join(self.config.sources, self.tarball_dirname)
# Since we just extracted this, a Windows anti-virus might still
@@ -339,11 +339,11 @@ class LocalTarball (GitCache):
self.package_name = self.package_name
self.unpack_dir = self.config.sources
- def extract(self):
+ async def extract(self):
if not os.path.exists(self.build_dir):
os.mkdir(self.build_dir)
self._find_tarball()
- shell.unpack(self.tarball_path, self.unpack_dir, logfile=get_logfile(self))
+ await shell.unpack(self.tarball_path, self.unpack_dir, logfile=get_logfile(self))
# apply common patches
self._apply_patches(self.repo_dir)
# apply platform patches
@@ -383,7 +383,7 @@ class Git (GitCache):
# For forced commits in the config
self.commit = self.config.recipe_commit(self.name) or self.commit
- def extract(self):
+ async def extract(self):
if os.path.exists(self.build_dir):
try:
commit_hash = git.get_hash(self.repo_dir, self.commit)
@@ -397,7 +397,7 @@ class Git (GitCache):
os.mkdir(self.build_dir)
# checkout the current version
- git.local_checkout(self.build_dir, self.repo_dir, self.commit, logfile=get_logfile(self))
+ await git.local_checkout(self.build_dir, self.repo_dir, self.commit, logfile=get_logfile(self))
for patch in self.patches:
if not os.path.isabs(patch):
@@ -428,8 +428,8 @@ class GitExtractedTarball(Git):
Git.__init__(self)
self._files = {}
- def extract(self):
- if not Git.extract(self):
+ async def extract(self):
+ if not await Git.extract(self):
return False
for match in self.matches:
self._files[match] = []
@@ -492,7 +492,7 @@ class Svn(Source):
await svn.checkout(self.url, self.repo_dir)
await svn.update(self.repo_dir, self.revision)
- def extract(self):
+ async def extract(self):
if os.path.exists(self.build_dir):
shutil.rmtree(self.build_dir)
diff --git a/cerbero/commands/fetch.py b/cerbero/commands/fetch.py
index deae56b8..72f78fac 100644
--- a/cerbero/commands/fetch.py
+++ b/cerbero/commands/fetch.py
@@ -227,7 +227,7 @@ class FetchCache(Command):
try:
artifacts_path = "%s/cerbero-deps.tar.gz" % config.home_dir
await shell.download(dep['url'], artifacts_path, check_cert=True, overwrite=True)
- shell.unpack(artifacts_path, config.home_dir)
+ await shell.unpack(artifacts_path, config.home_dir)
os.remove(artifacts_path)
origin = self.build_dir % namespace
m.message("Relocating from %s to %s" % (origin, config.home_dir))
diff --git a/cerbero/utils/git.py b/cerbero/utils/git.py
index f82817b5..aa0789a9 100644
--- a/cerbero/utils/git.py
+++ b/cerbero/utils/git.py
@@ -200,7 +200,7 @@ def get_hash(git_dir, commit):
(GIT, commit), git_dir).rstrip()
-def local_checkout(git_dir, local_git_dir, commit, logfile=None):
+async def local_checkout(git_dir, local_git_dir, commit, logfile=None):
'''
Clone a repository for a given commit in a different location
@@ -216,7 +216,7 @@ def local_checkout(git_dir, local_git_dir, commit, logfile=None):
shell.call('%s clone %s -s -b %s .' % (GIT, local_git_dir, branch_name),
git_dir, logfile=logfile)
ensure_user_is_set(local_git_dir, logfile=logfile)
- run_until_complete(submodules_update(git_dir, local_git_dir, logfile=logfile))
+ await submodules_update(git_dir, local_git_dir, logfile=logfile)
def add_remote(git_dir, name, url, logfile=None):
'''
diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py
index 4b962ecd..dfae0ee0 100644
--- a/cerbero/utils/shell.py
+++ b/cerbero/utils/shell.py
@@ -311,7 +311,7 @@ def apply_patch(patch, directory, strip=1, logfile=None):
call('%s -p%s -f -i %s' % (PATCH, strip, patch), directory)
-def unpack(filepath, output_dir, logfile=None):
+async def unpack(filepath, output_dir, logfile=None):
'''
Extracts a tarball
@@ -328,7 +328,7 @@ def unpack(filepath, output_dir, logfile=None):
if PLATFORM != Platform.WINDOWS:
if not os.path.exists(output_dir):
os.makedirs(output_dir)
- new_call(['tar', '-C', output_dir, '-xf', filepath])
+ await async_call(['tar', '-C', output_dir, '-xf', filepath])
else:
cmode = 'bz2' if filepath.endswith('bz2') else filepath[-2:]
tf = tarfile.open(filepath, mode='r:' + cmode)
diff --git a/recipes/build-tools/bison.recipe b/recipes/build-tools/bison.recipe
index 2244f61b..d8d60a13 100644
--- a/recipes/build-tools/bison.recipe
+++ b/recipes/build-tools/bison.recipe
@@ -14,7 +14,7 @@ class Recipe(recipe.Recipe):
files_bins = ['bison', 'yacc']
- def extract(self):
+ async def extract(self):
if os.path.exists(self.build_dir):
shutil.rmtree(self.build_dir)
- super(recipe.Recipe, self).extract()
+ await super(recipe.Recipe, self).extract()
diff --git a/recipes/build-tools/libtool.recipe b/recipes/build-tools/libtool.recipe
index af76055b..92a3bf6e 100644
--- a/recipes/build-tools/libtool.recipe
+++ b/recipes/build-tools/libtool.recipe
@@ -26,10 +26,10 @@ class Recipe(recipe.Recipe):
'share/aclocal/ltversion.m4',
'share/aclocal/lt~obsolete.m4']
- def extract(self):
+ async def extract(self):
if os.path.exists(self.build_dir):
shutil.rmtree(self.build_dir)
- super(recipe.Recipe, self).extract()
+ await super(recipe.Recipe, self).extract()
async def configure(self):
shell.touch(os.path.join(self.build_dir, 'doc', 'libtool.1'))
diff --git a/recipes/build-tools/wix.recipe b/recipes/build-tools/wix.recipe
index a750c273..4fc0eabb 100644
--- a/recipes/build-tools/wix.recipe
+++ b/recipes/build-tools/wix.recipe
@@ -13,11 +13,11 @@ class Recipe(recipe.Recipe):
btype = BuildType.CUSTOM
winetricks_url = 'https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks'
- def extract(self):
+ async def extract(self):
if os.path.exists(self.build_dir):
shutil.rmtree(self.build_dir)
os.makedirs(self.build_dir)
- shell.unpack(self.download_path, self.build_dir)
+ await shell.unpack(self.download_path, self.build_dir)
def install(self):
shell.copy_dir(self.build_dir, os.path.join(self.config.prefix, 'lib', 'wix', 'bin'))
diff --git a/recipes/libusrsctp.recipe b/recipes/libusrsctp.recipe
index 6b7656d6..22a0660c 100644
--- a/recipes/libusrsctp.recipe
+++ b/recipes/libusrsctp.recipe
@@ -46,8 +46,8 @@ class Recipe(recipe.Recipe):
'libusrsctp/0003-Fix-build-with-MinGW-and-the-ucrtbase-CRT.patch',
]
- def extract(self):
- super().extract()
+ async def extract(self):
+ await super().extract()
for f in ['NEWS', 'README', 'AUTHORS', 'ChangeLog']:
shell.log(os.path.join(self.build_dir, f), self.logfile)
shell.touch(os.path.join(self.build_dir, f), True)