1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Brew: Avoid duplicate commands, added --debug option, added local repo support

This commit is contained in:
shin- 2013-07-24 16:47:50 +02:00
parent 7813f2a25e
commit 362f1735e6
3 changed files with 22 additions and 15 deletions

View file

@ -1 +1 @@
from brew import build_library from brew import build_library, DEFAULT_REPOSITORY, DEFAULT_BRANCH

View file

@ -10,22 +10,30 @@ DEFAULT_BRANCH = 'library'
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
level='DEBUG') level='INFO')
client = docker.Client() client = docker.Client()
processed = {} 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: if repository is None:
repository = DEFAULT_REPOSITORY repository = DEFAULT_REPOSITORY
if branch is None: if branch is None:
branch = DEFAULT_BRANCH 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 #FIXME: set destination folder and only pull latest changes instead of
# cloning the whole repo everytime # 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')): for buildfile in os.listdir(os.path.join(dst_folder, 'library')):
if buildfile == 'MAINTAINERS': if buildfile == 'MAINTAINERS':
continue continue

View file

@ -5,21 +5,20 @@ import argparse
import brew import brew
DEFAULT_REPOSITORY = 'git://github.com/dotcloud/docker'
DEFAULT_BRANCH = 'library'
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser('Build the docker standard library') parser = argparse.ArgumentParser('Build the docker standard library')
parser.add_argument('--push', action='store_true', default=False, parser.add_argument('--push', action='store_true', default=False,
help='push generated repositories to the official registry') 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', parser.add_argument('-n', metavar='NAMESPACE', default='library',
help='namespace used for generated repositories.' help='namespace used for generated repositories.'
' Default is library') ' 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' help='branch in the repository where the library definition'
' files will be fetched. Default is ' + DEFAULT_BRANCH) ' files will be fetched. Default is ' + brew.DEFAULT_BRANCH)
parser.add_argument('repository', default=DEFAULT_REPOSITORY, nargs='?', parser.add_argument('repository', default=brew.DEFAULT_REPOSITORY,
help='git repository containing the library definition files.' nargs='?', help='git repository containing the library definition'
' Default is ' + DEFAULT_REPOSITORY) ' files. Default is ' + brew.DEFAULT_REPOSITORY)
args = parser.parse_args() args = parser.parse_args()
brew.build_library(args.repository, args.b, args.n, args.push) brew.build_library(args.repository, args.b, args.n, args.push, args.debug)