Commit 63e1b6d5 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜
Browse files

cerbero: Add fetch() and extract() to bootstrapper

This separates each bootstrapper into three distinct stages:

1. Fetch network resources into self.config.local_sources
2. Extract/copy network resources into the correct location
3. Run arbitrary commands that do not need network access
parent ded0eb57
......@@ -16,12 +16,52 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
import os
import shutil
from import BaseTarball
class BootstrapTarball(BaseTarball):
def __init__(self, config, offline, url, checksum, download_dir, tarball_name=None):
self.config = config
self.offline = offline
self.url = url
self.download_dir = download_dir
self.tarball_name = tarball_name
self.tarball_checksum = checksum
class BootstrapperBase (object):
# Dict of URLs to be fetched and their checksums
fetch_urls = None
# Dict of extract steps to be done
extract_steps = None
def __init__(self, config, offline):
self.config = config
self.offline = offline
self.fetch_urls = {}
self.extract_steps = []
self.sources = {}
def start(self):
raise NotImplemented("'start' must be implemented by subclasses")
def fetch(self):
for url, checksum in self.fetch_urls.items():
source = BootstrapTarball(self.config, self.offline, url, checksum,
self.sources[url] = source
def extract(self):
for (url, unpack, unpack_dir) in self.extract_steps:
if unpack:
# Just copy the file as-is
fname = os.path.basename(url)
fpath = os.path.join(self.config.local_sources, fname)
shutil.copy(fpath, unpack_dir)
......@@ -37,6 +37,8 @@ class Bootstrap(Command):
def run(self, config, args):
bootstrappers = Bootstrapper(config, args.build_tools_only, args.offline)
for bootstrapper in bootstrappers:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment