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 --no-verify 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 release_py = os.path.join(path, 'openerp/release.py')
54 if os.path.isfile(release_py):
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")
70 # sane push config for git < 2.0
71 run('git','config','push.default','simple')
73 run('git','config','merge.ff','no')
74 run('git','config','merge.commit','no')
76 pre_push_path = os.path.join(git_dir, '.git/hooks/pre-push')
77 open(pre_push_path,'w').write(GIT_HOOKS_PRE_PUSH.strip())
78 os.chmod(pre_push_path, 0755)
80 run('git','config','remote.odoo.url','https://github.com/odoo/odoo.git')
81 run('git','config','remote.odoo.pushurl','git@github.com:odoo/odoo.git')
82 run('git','config','--add','remote.odoo.fetch','dummy')
83 run('git','config','--unset-all','remote.odoo.fetch')
84 run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/heads/*')
85 # setup odoo-dev remote
86 run('git','config','remote.odoo-dev.url','https://github.com/odoo-dev/odoo.git')
87 run('git','config','remote.odoo-dev.pushurl','git@github.com:odoo-dev/odoo.git')
88 run('git','remote','update')
90 run('git','config','branch.master.remote','odoo')
91 run('git','config','branch.master.merge','refs/heads/master')
92 run('git','checkout','master')
94 printf('no git repo found')
96 def cmd_setup_git_dev():
97 git_dir = git_locate()
99 # setup odoo-dev remote
100 run('git','config','--add','remote.odoo-dev.fetch','dummy')
101 run('git','config','--unset-all','remote.odoo-dev.fetch')
102 run('git','config','--add','remote.odoo-dev.fetch','+refs/heads/*:refs/remotes/odoo-dev/heads/*')
103 run('git','config','--add','remote.odoo-dev.fetch','+refs/pull/*:refs/remotes/odoo-dev/pull/*')
104 run('git','remote','update')
106 def cmd_setup_git_review():
107 git_dir = git_locate()
109 # setup odoo-dev remote
110 run('git','config','--add','remote.odoo.fetch','dummy')
111 run('git','config','--unset-all','remote.odoo.fetch')
112 run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/heads/*')
113 run('git','config','--add','remote.odoo.fetch','+refs/tags/*:refs/remotes/odoo/tags/*')
114 run('git','config','--add','remote.odoo.fetch','+refs/pull/*:refs/remotes/odoo/pull/*')
116 def setup_deps_debian(git_dir):
117 debian_control_path = os.path.join(git_dir, 'setup/debian/control')
118 debian_control = open(debian_control_path).read()
119 debs = re.findall('python-[0-9a-z]+',debian_control)
120 proc = subprocess.Popen(['sudo','apt-get','install'] + debs, stdin=open('/dev/tty'))
123 def cmd_setup_deps():
124 git_dir = git_locate()
126 if os.path.isfile('/etc/debian_version'):
127 setup_deps_debian(git_dir)
129 def setup_pg_debian(git_dir):
130 cmd = ['sudo','su','-','postgres','-c','createuser -s %s' % os.environ['USER']]
134 git_dir = git_locate()
136 if os.path.isfile('/etc/debian_version'):
137 setup_pg_debian(git_dir)
145 # regsitry of commands
147 cmds = dict([(i[4:],g[i]) for i in g if i.startswith('cmd_')])
148 # if curl URL | python2 then use command setup
149 if len(sys.argv) == 1 and __file__ == '<stdin>':
151 elif len(sys.argv) == 2 and sys.argv[1] in cmds:
157 if __name__ == "__main__":