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)
62 git_dir = git_locate()
64 printf('git repo found at %s',git_dir)
66 run("git", "init", "odoo")
70 # push sane config for git < 2.0, and hooks
71 #run('git','config','push.default','simple')
73 run('git','config','alias.st','status')
75 run('git','config','merge.commit','no')
76 # pull let me choose between merge or rebase only works in git > 2.0, use an alias for 1
77 run('git','config','pull.ff','only')
78 run('git','config','alias.pl','pull --ff-only')
79 pre_push_path = os.path.join(git_dir, '.git/hooks/pre-push')
80 open(pre_push_path,'w').write(GIT_HOOKS_PRE_PUSH.strip())
81 os.chmod(pre_push_path, 0755)
83 run('git','config','remote.odoo.url','https://github.com/odoo/odoo.git')
84 run('git','config','remote.odoo.pushurl','git@github.com:odoo/odoo.git')
85 run('git','config','--add','remote.odoo.fetch','dummy')
86 run('git','config','--unset-all','remote.odoo.fetch')
87 run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/heads/*')
88 # setup odoo-dev remote
89 run('git','config','remote.odoo-dev.url','https://github.com/odoo-dev/odoo.git')
90 run('git','config','remote.odoo-dev.pushurl','git@github.com:odoo-dev/odoo.git')
91 run('git','remote','update')
93 run('git','config','branch.master.remote','odoo')
94 run('git','config','branch.master.merge','refs/heads/master')
95 run('git','checkout','master')
97 printf('no git repo found')
99 def cmd_setup_git_dev():
100 git_dir = git_locate()
102 # setup odoo-dev remote
103 run('git','config','--add','remote.odoo-dev.fetch','dummy')
104 run('git','config','--unset-all','remote.odoo-dev.fetch')
105 run('git','config','--add','remote.odoo-dev.fetch','+refs/heads/*:refs/remotes/odoo-dev/heads/*')
106 run('git','config','--add','remote.odoo-dev.fetch','+refs/pull/*:refs/remotes/odoo-dev/pull/*')
107 run('git','remote','update')
109 def cmd_setup_git_review():
110 git_dir = git_locate()
112 # setup odoo-dev remote
113 run('git','config','--add','remote.odoo.fetch','dummy')
114 run('git','config','--unset-all','remote.odoo.fetch')
115 run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/heads/*')
116 run('git','config','--add','remote.odoo.fetch','+refs/tags/*:refs/remotes/odoo/tags/*')
117 run('git','config','--add','remote.odoo.fetch','+refs/pull/*:refs/remotes/odoo/pull/*')
119 def setup_deps_debian(git_dir):
120 debian_control_path = os.path.join(git_dir, 'debian/control')
121 debian_control = open(debian_control_path).read()
122 debs = re.findall('python-[0-9a-z]+',debian_control)
123 debs += ["postgresql"]
124 proc = subprocess.Popen(['sudo','apt-get','install'] + debs, stdin=open('/dev/tty'))
127 def cmd_setup_deps():
128 git_dir = git_locate()
130 if os.path.isfile('/etc/debian_version'):
131 setup_deps_debian(git_dir)
133 def setup_pg_debian(git_dir):
134 cmd = ['sudo','su','-','postgres','-c','createuser -s %s' % os.environ['USER']]
138 git_dir = git_locate()
140 if os.path.isfile('/etc/debian_version'):
141 setup_pg_debian(git_dir)
149 # regsitry of commands
151 cmds = dict([(i[4:],g[i]) for i in g if i.startswith('cmd_')])
152 # if curl URL | python2 then use command setup
153 if len(sys.argv) == 1 and __file__ == '<stdin>':
155 elif len(sys.argv) == 2 and sys.argv[1] in cmds:
161 if __name__ == "__main__":