diff --git a/contrib/brew/brew/__init__.py b/contrib/brew/brew/__init__.py index f693ad67a4..a9476ff5a4 100644 --- a/contrib/brew/brew/__init__.py +++ b/contrib/brew/brew/__init__.py @@ -1 +1 @@ -from brew import build_library +from brew import build_library, DEFAULT_REPOSITORY, DEFAULT_BRANCH diff --git a/contrib/brew/brew/brew.py b/contrib/brew/brew/brew.py index 69529201d6..ab0b886b2c 100644 --- a/contrib/brew/brew/brew.py +++ b/contrib/brew/brew/brew.py @@ -10,22 +10,30 @@ DEFAULT_BRANCH = 'library' logger = logging.getLogger(__name__) logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', - level='DEBUG') + level='INFO') client = docker.Client() processed = {} -def build_library(repository=None, branch=None, namespace=None, push=False): +def build_library(repository=None, branch=None, namespace=None, push=False, + debug=False): if repository is None: repository = DEFAULT_REPOSITORY if branch is None: branch = DEFAULT_BRANCH + if debug: + logger.setLevel('DEBUG') + + if not (repository.startswith('https://') or repository.startswith('git://')): + logger.info('Repository provided assumed to be a local path') + dst_folder = repository - logger.info('Cloning docker repo from {0}, branch: {1}'.format( - repository, branch)) #FIXME: set destination folder and only pull latest changes instead of # cloning the whole repo everytime - dst_folder = git.clone_branch(repository, branch) + if not dst_folder: + logger.info('Cloning docker repo from {0}, branch: {1}'.format( + repository, branch)) + dst_folder = git.clone_branch(repository, branch) 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 d1843d412b..3bcd99a3ad 100755 --- a/contrib/brew/docker-brew +++ b/contrib/brew/docker-brew @@ -5,21 +5,20 @@ import argparse import brew -DEFAULT_REPOSITORY = 'git://github.com/dotcloud/docker' -DEFAULT_BRANCH = 'library' - if __name__ == '__main__': parser = argparse.ArgumentParser('Build the docker standard library') parser.add_argument('--push', action='store_true', default=False, help='push generated repositories to the official registry') + parser.add_argument('--debug', default=False, action='store_true', + help='Enable debugging output') parser.add_argument('-n', metavar='NAMESPACE', default='library', help='namespace used for generated repositories.' ' Default is library') - parser.add_argument('-b', metavar='BRANCH', default=DEFAULT_BRANCH, + parser.add_argument('-b', metavar='BRANCH', default=brew.DEFAULT_BRANCH, help='branch in the repository where the library definition' - ' files will be fetched. Default is ' + DEFAULT_BRANCH) - parser.add_argument('repository', default=DEFAULT_REPOSITORY, nargs='?', - help='git repository containing the library definition files.' - ' Default is ' + DEFAULT_REPOSITORY) + ' files will be fetched. Default is ' + brew.DEFAULT_BRANCH) + parser.add_argument('repository', default=brew.DEFAULT_REPOSITORY, + nargs='?', help='git repository containing the library definition' + ' files. Default is ' + brew.DEFAULT_REPOSITORY) args = parser.parse_args() - brew.build_library(args.repository, args.b, args.n, args.push) \ No newline at end of file + brew.build_library(args.repository, args.b, args.n, args.push, args.debug)