~cinxgler/openerp/trunk

« back to all changes in this revision

Viewing changes to fabfile.py

  • Committer: Antony Lesuisse
  • Date: 2010-12-31 13:27:14 UTC
  • Revision ID: al@openerp.com-20101231132714-zv3t4ruo92tqxw2s
cleanup and simplifications

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
 
from __future__ import with_statement
3
 
 
4
 
import os
5
 
import imp
6
 
import tempfile
7
 
import shutil
 
2
import imp, os, shutil, subprocess, tempfile
8
3
 
9
4
from fabric.api import env, run, local, cd
10
5
from fabric.operations import put
11
6
 
12
 
MAJOR_VERSION=6
13
 
MINOR_VERSION=0
14
 
REVISION_VERSION=0
15
 
BUILD_VERSION='rc2'
16
 
 
17
 
VERSION='%d.%d.%d' % (MAJOR_VERSION, MINOR_VERSION, REVISION_VERSION)
18
 
if BUILD_VERSION:
19
 
    VERSION='%s-%s' % (VERSION, BUILD_VERSION,)
20
 
 
21
 
SDIST_DIR = os.path.realpath('packaging')
22
 
if not os.path.exists(SDIST_DIR):
23
 
    print "The packaging directory doesn't exist - create it or change the directory in the fabfile"
24
 
    sys.exit()
25
 
TARBALL_PATTERN = 'openerp-*-%s.tar.gz' % VERSION
26
 
EXE_WIN32_PATTERN = 'openerp-*-setup-%s.exe' % VERSION
27
 
WORKING_DIRECTORY = os.getcwd()
 
7
# This should be updated every release
 
8
 
 
9
VERSION_MAJOR='6.0'
 
10
VERSION_FULL='%s.0-rc2'%VERSION_MAJOR
 
11
 
 
12
WINDOWS_IP='172.16.225.128'
 
13
 
 
14
# This should not be updated
28
15
 
29
16
PROJECTS = [
30
17
    ('openobject-server', 'server', os.path.join('bin', 'release.py'), 'server_release.py.mako'),
32
19
    ('openobject-web', 'web', os.path.join('openobject', 'release.py'), 'web_release.py.mako'),
33
20
]
34
21
 
35
 
 
36
 
DOWNLOAD_DIRECTORY = os.path.join('/', 'var', 'www', 'www.openerp.com', 'www', 'download')
37
 
REMOTE_DIRECTORY = os.path.join(DOWNLOAD_DIRECTORY, 'unstable')
38
 
SOURCE_DIRECTORY = os.path.join(REMOTE_DIRECTORY, 'source')
39
 
WIN32_DIRECTORY = os.path.join(REMOTE_DIRECTORY, 'win32')
 
22
DIR_DIST = os.path.realpath('packaging')
 
23
if not os.path.exists(DIR_DIST):
 
24
    os.mkdir(DIST_DIR)
 
25
 
 
26
GLOB_TARBALL = 'openerp-*-%s.tar.gz' % VERSION_FULL
 
27
GLOB_WIN32 = 'openerp-*-setup-%s.exe' % VERSION_FULL
 
28
 
 
29
DIR_WEBSITE = os.path.join('/', 'var', 'www', 'www.openerp.com', 'www', 'download')
 
30
DIR_SOURCE = os.path.join(DIR_WEBSITE, 'unstable', 'source')
 
31
DIR_WIN32 = os.path.join(DIR_WEBSITE, 'unstable', 'win32')
40
32
 
41
33
env.hosts = ['root@openerp.com']
42
34
 
43
 
def show_version():
44
 
    """
45
 
    Make the version defined in this file and the release.py files
46
 
    """
47
 
    print "CURRENT: %r" % (VERSION)
48
 
    for project, project_directory, release_file, _ in PROJECTS:
49
 
        release = imp.load_source(release_file, os.path.join(project_directory, release_file))
50
 
        print "project: %r -- %r" % (project, release.version)
51
 
 
52
35
def update():
53
36
    """
54
37
    Make bzr pull on each branch
64
47
        bzr pull -d client;
65
48
        bzr pull -d server;
66
49
        bzr pull -d web;
67
 
        rsync --exclude .bzr/ -av addons/ server/bin/addons/
 
50
        #rsync --exclude .bzr/ -av addons/ server/bin/addons/
68
51
    """
69
52
    for i in cmd.split('\n'):
70
53
        print i
71
54
        os.system(i)
72
55
 
73
 
def sdist():
74
 
    """
75
 
    Generate the sources
76
 
    """
77
 
    from subprocess import Popen, call
78
 
    for project in PROJECTS:
79
 
        project_name = project[0]
80
 
        project_directory = project[1]
81
 
 
82
 
        directory = os.path.abspath(project_directory)
83
 
        print "project: %s - %s" % (project_name, directory,)
84
 
        Popen(['python', os.path.join(directory, 'setup.py'), 'sdist', '-d', os.path.abspath(SDIST_DIR)],
85
 
              cwd=directory).communicate()
86
 
 
87
 
def upload_tar():
88
 
    """
89
 
    Upload the tarballs (source)
90
 
    """
91
 
    run('mkdir %s -p' % SOURCE_DIRECTORY)
92
 
    put(os.path.join(SDIST_DIR, TARBALL_PATTERN), SOURCE_DIRECTORY)
93
 
 
94
 
def upload_win32():
95
 
    """
96
 
    Upload the Windows Installers
97
 
    """
98
 
    run('mkdir %s -p' % WIN32_DIRECTORY)
99
 
    put(os.path.join(SDIST_DIR, EXE_WIN32_PATTERN), WIN32_DIRECTORY)
100
 
 
101
 
def update_local_current():
102
 
    """
103
 
    Update the local CURRENT file with the new version
104
 
    """
105
 
    local('echo %s > %s' % (VERSION, os.path.join(SDIST_DIR, 'CURRENT')))
106
 
 
107
56
def update_release_files():
108
57
    """
109
58
    Update the release files
116
65
        template = MakoTemplate(filename=template_file)
117
66
        file_pointer = open(release_file, 'w')
118
67
        file_pointer.write(
119
 
            template.render(VERSION=VERSION,
120
 
                            MAJOR_VERSION='%d.%d' % (MAJOR_VERSION, MINOR_VERSION)
121
 
                           )
 
68
            template.render(VERSION_FULL=VERSION_FULL, VERSION_MAJOR)
122
69
        )
123
70
        file_pointer.close()
124
71
        print "release_file: %r" % release_file
125
72
 
 
73
def sdist():
 
74
    """
 
75
    Generate the sources
 
76
    """
 
77
    for project in PROJECTS:
 
78
        directory = os.path.abspath(project[1])
 
79
        cmd=['python', os.path.join(directory, 'setup.py'), 'sdist', '-d', os.path.abspath(DIR_DIST)]
 
80
        print cmd
 
81
        subprocess.Popen(cmd, cwd=directory).communicate()
 
82
 
126
83
def update_current():
127
84
    """
128
 
    Update the CURRENT file with the new version
129
 
    """
130
 
    run('echo %s > %s' % (VERSION, os.path.join(DOWNLOAD_DIRECTORY, 'CURRENT')))
131
 
    run('chown www-data:www-data %s -R' % DOWNLOAD_DIRECTORY)
 
85
    Update the local CURRENT file with the new version
 
86
    """
 
87
    local('echo %s > %s' % (VERSION_FULL, os.path.join(DIR_DIST, 'CURRENT')))
 
88
 
 
89
def upload_tar():
 
90
    """
 
91
    Upload the tarballs (source)
 
92
    """
 
93
    run('mkdir %s -p' % DIR_SOURCE)
 
94
    put(os.path.join(DIR_DIST, GLOB_TARBALL), DIR_SOURCE)
 
95
 
 
96
def upload_win32():
 
97
    """
 
98
    Upload the Windows Installers
 
99
    """
 
100
    run('mkdir %s -p' % DIR_WIN32)
 
101
    put(os.path.join(DIR_DIST, GLOB_WIN32), DIR_WIN32)
132
102
 
133
103
def upload():
134
104
    """
135
105
    Upload the Windows Installer and the tarballs
136
106
    """
 
107
    update_current()
137
108
    upload_tar()
138
109
    upload_win32()
139
 
    update_current()
140
110
 
141
111
def update_planets():
142
112
    """
149
119
    update()
150
120
    update_release_files()
151
121
    sdist()
152
 
    update_local_current()
153
122
    update_current()
154
123
    #upload()
155
124