# Path: fabsetup/fabutils.py
# def checkup_git_repo_legacy(url, name=None, base_dir='~/repos',
#                             verbose=False, prefix='', postfix=''):
#     '''Checkout or update a git repo.'''
#     if not name:
#         match = re.match(r'.*/(.+)\.git', url)
#         assert match, flo("Unable to extract repo name from '{url}'")
#         name = match.group(1)
#     assert name is not None, flo('Cannot extract repo name from repo: {url}')
#     assert name != '', flo('Cannot extract repo name from repo: {url} (empty)')
#     if verbose:
#         name_blue = blue(name)
#         print_msg(flo('{prefix}Checkout or update {name_blue}{postfix}'))
#     if not exists(base_dir):
#         run(flo('mkdir -p {base_dir}'))
#     if not exists(flo('{base_dir}/{name}/.git')):
#         run(flo('  &&  '.join([
#                 'cd {base_dir}',
#                 'git clone  {url}  {name}'])),
#             msg='clone repo')
#     else:
#         if verbose:
#             print_msg('update: pull from origin')
#         run(flo('cd {base_dir}/{name}  &&  git pull'))
#     return name
# 
# Path: fabsetup/fabutils.py
# def suggest_localhost(func):
#     '''Decorator: prompt user for value of env.host_string with default to
#     'localhost' when env.host_string is empty.
# 
#     Modification of decorator function fabric.network.needs_host
#     '''
#     from fabric.network import handle_prompt_abort, to_dict
# 
#     @wraps(func)
#     def host_prompting_wrapper(*args, **kwargs):
#         while not env.get('host_string', False):
#             handle_prompt_abort("the target host connection string")
#             host_string = raw_input("No hosts found. Please specify "
#                                     "host string for connection [localhost]: ")
#             if host_string == '':
#                 host_string = 'localhost'
#             env.update(to_dict(host_string))
#         return func(*args, **kwargs)
# 
#     host_prompting_wrapper.undecorated = func
# 
#     return host_prompting_wrapper
# 
# def print_msg(msg):
#     if msg is not None:
#         print(cyan(flo('{msg}')))
# 
# Path: fabsetup/fabutils.py
# def run(*args, **kwargs):
#     func, kwargs = _func(kwargs)
#     return func(*args, **kwargs)
# 
# def subtask(*args, **kwargs):
#     '''Decorator which prints out the name of the decorated function on
#     execution.
#     '''
#     depth = kwargs.get('depth', 2)
#     prefix = kwargs.get('prefix', '\n' + '#' * depth + ' ')
#     tail = kwargs.get('tail', '\n')
#     doc1 = kwargs.get('doc1', False)
#     color = kwargs.get('color', cyan)
# 
#     def real_decorator(func):
#         if doc1:
#             return print_full_name(color=color, prefix=prefix,
#                                    tail=tail)(print_doc1(func))
#         return print_full_name(color=color, prefix=prefix, tail=tail)(func)
# 
#     invoked = bool(not args or kwargs)
#     if not invoked:
#         # invoke decorator function which returns the wrapper function
#         return real_decorator(func=args[0])
#     return real_decorator
# 
# def task(func, *args, **kwargs):
#     '''Composition of decorator functions for inherent self-documentation on
#     task execution.
# 
#     On execution, each task prints out its name and its first docstring line.
#     '''
#     prefix = '\n# '
#     tail = '\n'
#     return fabric.api.task(
#         print_full_name(color=magenta,
#                         prefix=prefix,
#                         tail=tail)(print_doc1(func)),
#         *args,
#         **kwargs)
# 
# Path: fabsetup/utils.py
# def flo(string):
#     '''Return the string given by param formatted with the callers locals.'''
#     callers_locals = {}
#     frame = inspect.currentframe()
#     try:
#         outerframe = frame.f_back
#         callers_locals = outerframe.f_locals
#     finally:
#         del frame
#     return string.format(**callers_locals)


from os.path import expanduser
from fabric.api import warn_only
from fabsetup.fabutils import checkup_git_repo_legacy
from fabsetup.fabutils import suggest_localhost, print_msg
from fabsetup.fabutils import run, subtask, task
from fabsetup.utils import flo
    checkup_git_repo_legacy('git://git.openssl.org/openssl.git',
                            base_dir=src_base)
    run(flo('cd {srcdir}  &&  git checkout {version}'))
    run(flo('cd {srcdir}  &&  git pull'))


@subtask
def compile(srcdir, instdir, confdir):
    instdir = expanduser(instdir)
    confdir = expanduser(confdir)

    run(flo('cd {srcdir}  &&  ./config  '
            'no-shared  '  # only create static libraries (no shared libs)
            'no-dso  '     # no support for loading dynamic shared objects
            '--prefix={instdir}  '
            '--openssldir={confdir}'))
    run(flo('cd {srcdir}  &&  make clean'))
    run(flo('cd {srcdir}  &&  make'))


@subtask
def test(srcdir, ignore_fail):
    cmd = flo('cd {srcdir}  &&  make test')
    if ignore_fail:
        with warn_only():
            run(cmd)
    else:
        run(cmd)



# Path: fabsetup/fabutils.py
# def checkup_git_repo_legacy(url, name=None, base_dir='~/repos',
#                             verbose=False, prefix='', postfix=''):
#     '''Checkout or update a git repo.'''
#     if not name:
#         match = re.match(r'.*/(.+)\.git', url)
#         assert match, flo("Unable to extract repo name from '{url}'")
#         name = match.group(1)
#     assert name is not None, flo('Cannot extract repo name from repo: {url}')
#     assert name != '', flo('Cannot extract repo name from repo: {url} (empty)')
#     if verbose:
#         name_blue = blue(name)
#         print_msg(flo('{prefix}Checkout or update {name_blue}{postfix}'))
#     if not exists(base_dir):
#         run(flo('mkdir -p {base_dir}'))
#     if not exists(flo('{base_dir}/{name}/.git')):
#         run(flo('  &&  '.join([
#                 'cd {base_dir}',
#                 'git clone  {url}  {name}'])),
#             msg='clone repo')
#     else:
#         if verbose:
#             print_msg('update: pull from origin')
#         run(flo('cd {base_dir}/{name}  &&  git pull'))
#     return name
# 
# Path: fabsetup/fabutils.py
# def suggest_localhost(func):
#     '''Decorator: prompt user for value of env.host_string with default to
#     'localhost' when env.host_string is empty.
# 
#     Modification of decorator function fabric.network.needs_host
#     '''
#     from fabric.network import handle_prompt_abort, to_dict
# 
#     @wraps(func)
#     def host_prompting_wrapper(*args, **kwargs):
#         while not env.get('host_string', False):
#             handle_prompt_abort("the target host connection string")
#             host_string = raw_input("No hosts found. Please specify "
#                                     "host string for connection [localhost]: ")
#             if host_string == '':
#                 host_string = 'localhost'
#             env.update(to_dict(host_string))
#         return func(*args, **kwargs)
# 
#     host_prompting_wrapper.undecorated = func
# 
#     return host_prompting_wrapper
# 
# def print_msg(msg):
#     if msg is not None:
#         print(cyan(flo('{msg}')))
# 
# Path: fabsetup/fabutils.py
# def run(*args, **kwargs):
#     func, kwargs = _func(kwargs)
#     return func(*args, **kwargs)
# 
# def subtask(*args, **kwargs):
#     '''Decorator which prints out the name of the decorated function on
#     execution.
#     '''
#     depth = kwargs.get('depth', 2)
#     prefix = kwargs.get('prefix', '\n' + '#' * depth + ' ')
#     tail = kwargs.get('tail', '\n')
#     doc1 = kwargs.get('doc1', False)
#     color = kwargs.get('color', cyan)
# 
#     def real_decorator(func):
#         if doc1:
#             return print_full_name(color=color, prefix=prefix,
#                                    tail=tail)(print_doc1(func))
#         return print_full_name(color=color, prefix=prefix, tail=tail)(func)
# 
#     invoked = bool(not args or kwargs)
#     if not invoked:
#         # invoke decorator function which returns the wrapper function
#         return real_decorator(func=args[0])
#     return real_decorator
# 
# def task(func, *args, **kwargs):
#     '''Composition of decorator functions for inherent self-documentation on
#     task execution.
# 
#     On execution, each task prints out its name and its first docstring line.
#     '''
#     prefix = '\n# '
#     tail = '\n'
#     return fabric.api.task(
#         print_full_name(color=magenta,
#                         prefix=prefix,
#                         tail=tail)(print_doc1(func)),
#         *args,
#         **kwargs)
# 
# Path: fabsetup/utils.py
# def flo(string):
#     '''Return the string given by param formatted with the callers locals.'''
#     callers_locals = {}
#     frame = inspect.currentframe()
#     try:
#         outerframe = frame.f_back
#         callers_locals = outerframe.f_locals
#     finally:
#         del frame
#     return string.format(**callers_locals)


# Path: fabsetup/fabfile/setup/openssl.py
from os.path import expanduser
from fabric.api import warn_only
from fabsetup.fabutils import checkup_git_repo_legacy
from fabsetup.fabutils import suggest_localhost, print_msg
from fabsetup.fabutils import run, subtask, task
from fabsetup.utils import flo

    checkup_git_repo_legacy('git://git.openssl.org/openssl.git',
                            base_dir=src_base)
    run(flo('cd {srcdir}  &&  git checkout {version}'))
    run(flo('cd {srcdir}  &&  git pull'))


@subtask
def compile(srcdir, instdir, confdir):
    instdir = expanduser(instdir)
    confdir = expanduser(confdir)

    run(flo('cd {srcdir}  &&  ./config  '
            'no-shared  '  # only create static libraries (no shared libs)
            'no-dso  '     # no support for loading dynamic shared objects
            '--prefix={instdir}  '
            '--openssldir={confdir}'))
    run(flo('cd {srcdir}  &&  make clean'))
    run(flo('cd {srcdir}  &&  make'))


@subtask
def test(srcdir, ignore_fail):
    cmd = flo('cd {srcdir}  &&  make test')
    if ignore_fail:
        with warn_only():
            run(cmd)
    else:
        run(cmd)



@subtask