Ejemplo n.º 1
0
def install(opts, conf):
    dotfiles = conf.get_dotfiles(opts['profile'])
    if dotfiles == []:
        LOG.err('no dotfiles defined for this profile (\"%s\")' %
                (str(opts['profile'])))
        return False
    t = Templategen(base=opts['dotpath'])
    inst = Installer(create=opts['create'],
                     backup=opts['backup'],
                     dry=opts['dry'],
                     safe=opts['safe'],
                     base=opts['dotpath'],
                     diff=opts['installdiff'],
                     quiet=opts['quiet'])
    installed = []
    for dotfile in dotfiles:
        if hasattr(dotfile, 'link') and dotfile.link:
            r = inst.link(dotfile.src, dotfile.dst)
        else:
            r = inst.install(t, opts['profile'], dotfile.src, dotfile.dst)
        if len(r) > 0 and len(dotfile.actions) > 0:
            # execute action
            for action in dotfile.actions:
                action.execute()
        installed.extend(r)
    LOG.log('\n%u dotfile(s) installed.' % (len(installed)))
    return True