2 #----------------------------------------------------------
5 # To install your odoo development environement type:
7 # wget -O- https://raw.githubusercontent.com/odoo/odoo/master/odoo.py | python
9 # The setup_* subcommands used to boostrap odoo are defined here inline and may
10 # only depends on the python 2.7 stdlib
12 # The rest of subcommands are defined in odoo/cli or in <module>/cli by
13 # subclassing the Command object
15 # https://raw.githubusercontent.com/odoo-dev/odoo/master-odoo-cmd-fme/odoo.py
17 #----------------------------------------------------------
23 GIT_HOOKS_PRE_PUSH = """
24 #!/usr/bin/env python2
27 if re.search('github.com[:/]odoo/odoo.git$', sys.argv[2]):
28 print "Pushing to /odoo/odoo.git is forbidden, please push to odoo-dev, use -f to override"
36 if isinstance(l[0], list):
38 printf("running %s", " ".join(l))
39 subprocess.check_call(l)
43 # TODO add support for os.environ.get('GIT_DIR')
45 # check for an odoo child
46 if os.path.isfile('odoo/.git/config'):
51 gitconfig_path = os.path.join(path, '.git/config')
52 if os.path.isfile(gitconfig_path):
53 content = open(gitconfig_path).read()
54 if re.search('github.com[:/]odoo/odoo.git', content):
56 path = os.path.dirname(path)
61 def cmd_setup_git_init():
62 git_dir = git_locate()
64 printf('git repo found at %s',git_dir)
66 run("git", "init", "odoo")
67 git_dir = os.path.join(os.getcwd(), 'odoo')
69 # sane push config for git < 2.0
70 run('git','config','push.default','simple')
72 run('git','config','merge.ff','no')
73 run('git','config','merge.commit','no')
75 pre_push_path = os.path.join(git_dir, '.git/hooks/pre-push')
76 open(pre_push_path,'w').write(GIT_HOOKS_PRE_PUSH.strip())
77 os.chmod(pre_push_path, 0755)
79 run('git','config','remote.odoo.url','https://github.com/odoo/odoo.git')
80 run('git','config','remote.odoo.pushurl','git@github.com:odoo/odoo.git')
81 run('git','config','--add','remote.odoo.fetch','dummy')
82 run('git','config','--unset-all','remote.odoo.fetch')
83 run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/heads/*')
84 # setup odoo-dev remote
85 run('git','config','remote.odoo-dev.url','https://github.com/odoo-dev/odoo.git')
86 run('git','config','remote.odoo-dev.pushurl','git@github.com:odoo-dev/odoo.git')
87 run('git','remote','update')
89 run('git','config','branch.master.remote','odoo')
90 run('git','config','branch.master.merge','refs/heads/master')
91 run('git','checkout','master')
93 printf('no git repo found')
95 def cmd_setup_git_odoo_dev():
96 git_dir = git_locate()
98 # setup odoo-dev remote
99 run('git','config','--add','remote.odoo-dev.fetch','dummy')
100 run('git','config','--unset-all','remote.odoo-dev.fetch')
101 run('git','config','--add','remote.odoo-dev.fetch','+refs/heads/*:refs/remotes/odoo-dev/heads/*')
102 run('git','config','--add','remote.odoo-dev.fetch','+refs/pull/*:refs/remotes/odoo-dev/pull/*')
103 run('git','remote','update')
105 def cmd_setup_git_odoo_review():
106 git_dir = git_locate()
108 # setup odoo-dev remote
109 run('git','config','--add','remote.odoo.fetch','dummy')
110 run('git','config','--unset-all','remote.odoo.fetch')
111 run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/heads/*')
112 run('git','config','--add','remote.odoo.fetch','+refs/tags/*:refs/remotes/odoo/tags/*')
113 run('git','config','--add','remote.odoo.fetch','+refs/pull/*:refs/remotes/odoo/pull/*')
115 def setup_deps_debian(git_dir):
116 debian_control_path = os.path.join(git_dir, 'debian/control')
117 debian_control = open(debian_control_path).read()
118 debs = re.findall('python-[0-9a-z]+',debian_control)
119 proc = subprocess.Popen(['sudo','apt-get','install'] + debs, stdin=open('/dev/tty'))
122 def cmd_setup_deps():
123 git_dir = git_locate()
125 if os.path.isfile('/etc/debian_version'):
126 setup_deps_debian(git_dir)
128 def setup_pg_debian(git_dir):
129 cmd = ['sudo','su','-','postgres','-c','createuser -s %s' % os.environ['USER']]
133 git_dir = git_locate()
135 if os.path.isfile('/etc/debian_version'):
136 setup_pg_debian(git_dir)
144 # regsitry of commands
146 cmds = dict([(i[4:],g[i]) for i in g if i.startswith('cmd_')])
147 # if curl URL | python2 then use command setup
148 if len(sys.argv) == 1 and __file__ == '<stdin>':
150 elif len(sys.argv) == 2 and sys.argv[1] in cmds:
156 if __name__ == "__main__":