summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2015-07-06 18:56:30 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2015-09-10 14:03:31 -0400
commit35e20b47d8ba3597d8d4c4b41a37d0152ed31e47 (patch)
tree37768e1a57139cf149c6532ac14a218a4aef4bab
parent9f49bcd70abe5ee4e749abbfb66fb41ef9b51e0d (diff)
source: Take sources from local directory instead of downloading if possible
This will take the sources from the cerbero tarball instead of the Internet if the recipes were put into the tarball. https://bugzilla.gnome.org/show_bug.cgi?id=742830
-rw-r--r--cerbero/build/source.py46
-rw-r--r--cerbero/config.py3
2 files changed, 38 insertions, 11 deletions
diff --git a/cerbero/build/source.py b/cerbero/build/source.py
index efecc8b9..2bc3360d 100644
--- a/cerbero/build/source.py
+++ b/cerbero/build/source.py
@@ -99,10 +99,18 @@ class Tarball (Source):
self.download_path = os.path.join(self.repo_dir, self.tarball_name)
def fetch(self):
- m.action(_('Fetching tarball %s to %s') %
- (self.url, self.download_path))
if not os.path.exists(self.repo_dir):
os.makedirs(self.repo_dir)
+
+ cached_file = os.path.join(self.config.cached_sources,
+ self.package_name, self.tarball_name)
+ if os.path.isfile(cached_file):
+ m.action(_('Copying cached tarball from %s to %s instead of %s') %
+ (cached_file, self.download_path, self.url))
+ shutil.copy(cached_file, self.download_path)
+ return
+ m.action(_('Fetching tarball %s to %s') %
+ (self.url, self.download_path))
shell.download(self.url, self.download_path, check_cert=False)
def extract(self):
@@ -143,14 +151,24 @@ class GitCache (Source):
def fetch(self, checkout=True):
if not os.path.exists(self.repo_dir):
git.init(self.repo_dir)
- # add remotes from both upstream and config so user can easily
- # cherry-pick patches between branches
- for remote, url in self.remotes.iteritems():
- git.add_remote(self.repo_dir, remote, url)
- for remote, url in self.config.recipe_remotes(self.name).iteritems():
- git.add_remote(self.repo_dir, remote, url)
- # fetch remote branches
- git.fetch(self.repo_dir, fail=False)
+
+ # First try to get the sources from the cached dir if there is one
+ cached_dir = os.path.join(self.config.cached_sources, self.name)
+ if os.path.isdir(os.path.join(cached_dir, ".git")):
+ for remote, url in self.remotes.iteritems():
+ git.add_remote(self.repo_dir, remote, "file://" + cached_dir)
+ for remote, url in self.config.recipe_remotes(self.name).iteritems():
+ git.add_remote(self.repo_dir, remote, "file://" + cached_dir)
+ git.fetch(self.repo_dir, fail=False)
+ else:
+ # add remotes from both upstream and config so user can easily
+ # cherry-pick patches between branches
+ for remote, url in self.remotes.iteritems():
+ git.add_remote(self.repo_dir, remote, url)
+ for remote, url in self.config.recipe_remotes(self.name).iteritems():
+ git.add_remote(self.repo_dir, remote, url)
+ # fetch remote branches
+ git.fetch(self.repo_dir, fail=False)
if checkout:
commit = self.config.recipe_commit(self.name) or self.commit
git.checkout(self.repo_dir, commit)
@@ -307,6 +325,14 @@ class Svn(Source):
def fetch(self):
if os.path.exists(self.repo_dir):
shutil.rmtree(self.repo_dir)
+
+ cached_dir = os.path.join(self.config.cached_sources, self.package_name)
+ if os.path.isdir(os.path.join(cached_dir, ".svn")):
+ m.action(_('Copying cached repo from %s to %s instead of %s') %
+ (cached_dir, self.repo_dir, self.url))
+ shell.copy_dir(cached_dir, self.repo_dir)
+ return
+
os.makedirs(self.repo_dir)
svn.checkout(self.url, self.repo_dir)
svn.update(self.repo_dir, self.revision)
diff --git a/cerbero/config.py b/cerbero/config.py
index 8fe6bd00..a510f956 100644
--- a/cerbero/config.py
+++ b/cerbero/config.py
@@ -92,7 +92,7 @@ class Config (object):
'recipes_remotes', 'ios_platform', 'extra_build_tools',
'distro_packages_install', 'interactive',
'target_arch_flags', 'sysroot', 'isysroot',
- 'extra_lib_path']
+ 'extra_lib_path', 'cached_sources']
def __init__(self):
self._check_uninstalled()
@@ -286,6 +286,7 @@ class Config (object):
self.set_property('prefix', None)
self.set_property('sources', None)
self.set_property('local_sources', None)
+ self.set_property('cached_sources', self._relative_path('sources'))
self.set_property('git_root', DEFAULT_GIT_ROOT)
self.set_property('allow_parallel_build', DEFAULT_ALLOW_PARALLEL_BUILD)
self.set_property('host', None)