From 6178dc7f1be0d3c90ed02e8ccbafa4d7e103508d Mon Sep 17 00:00:00 2001 From: shin- Date: Fri, 9 Aug 2013 16:40:28 +0200 Subject: [PATCH] brew: added safeguards in script and changed default branch to 'master' --- contrib/brew/README.md | 2 +- contrib/brew/brew/brew.py | 10 ++++++++-- contrib/brew/docker-brew | 10 ++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/contrib/brew/README.md b/contrib/brew/README.md index d50e66f2a8..026758e876 100644 --- a/contrib/brew/README.md +++ b/contrib/brew/README.md @@ -8,7 +8,7 @@ docker-brew is a command-line tool used to build the docker standard library. 1. Install the easy_install tool (`sudo apt-get install python-setuptools` for Debian) 1. Install the python package manager, `pip` (`easy_install pip`) -1. Run the following command: `pip install -r requirements.txt` +1. Run the following command: `sudo pip install -r requirements.txt` 1. You should now be able to use the `docker-brew` script as such. ## Basics diff --git a/contrib/brew/brew/brew.py b/contrib/brew/brew/brew.py index 73d59877fb..8cbbaca06a 100644 --- a/contrib/brew/brew/brew.py +++ b/contrib/brew/brew/brew.py @@ -7,7 +7,7 @@ import docker import git DEFAULT_REPOSITORY = 'git://github.com/dotcloud/docker' -DEFAULT_BRANCH = 'library' +DEFAULT_BRANCH = 'master' logger = logging.getLogger(__name__) logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', @@ -36,7 +36,13 @@ def build_library(repository=None, branch=None, namespace=None, push=False, if not dst_folder: logger.info('Cloning docker repo from {0}, branch: {1}'.format( repository, branch)) - dst_folder = git.clone_branch(repository, branch) + try: + dst_folder = git.clone_branch(repository, branch) + except Exception as e: + logger.exception(e) + logger.error('Source repository could not be fetched. Check ' + 'that the address is correct and the branch exists.') + return for buildfile in os.listdir(os.path.join(dst_folder, 'library')): if buildfile == 'MAINTAINERS': continue diff --git a/contrib/brew/docker-brew b/contrib/brew/docker-brew index ead6b65075..c3fc147cf5 100755 --- a/contrib/brew/docker-brew +++ b/contrib/brew/docker-brew @@ -1,9 +1,15 @@ #!/usr/bin/env python import argparse +import sys -import brew - +try: + import brew +except ImportError as e: + print str(e) + print 'Please install the required dependencies first' + print 'sudo pip install -r requirements.txt' + sys.exit(1) if __name__ == '__main__': parser = argparse.ArgumentParser('Build the docker standard library')