/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/win32/build_release.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-18 18:18:36 UTC
  • mto: This revision was merged to the branch mainline in revision 4461.
  • Revision ID: john@arbash-meinel.com-20090618181836-biodfkat9a8eyzjz
The new add_inventory_by_delta is returning a CHKInventory when mapping from NULL
Which is completely valid, but 'broke' one of the tests.
So to fix it, changed the test to use CHKInventories on both sides, and add an __eq__
member. The nice thing is that CHKInventory.__eq__ is fairly cheap, since it only
has to check the root keys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/cygdrive/C/Python25/python
 
2
"""A script to help automate the build process."""
 
3
 
 
4
# When preparing a new release, make sure to set all of these to the latest
 
5
# values.
 
6
VERSIONS = {
 
7
    'bzr': '1.12',
 
8
    'qbzr': '0.9.8',
 
9
    'bzrtools': '1.12.0',
 
10
    'bzr-svn': '0.5.2',
 
11
    'bzr-rebase': '0.4.4',
 
12
    'subvertpy': '0.6.4',
 
13
}
 
14
 
 
15
# This will be passed to 'make' to ensure we build with the right python
 
16
PYTHON='/cygdrive/c/Python25/python'
 
17
 
 
18
# Create the final build in this directory
 
19
TARGET_ROOT='release'
 
20
 
 
21
DEBUG_SUBPROCESS = True
 
22
 
 
23
 
 
24
import os
 
25
import shutil
 
26
import subprocess
 
27
import sys
 
28
 
 
29
 
 
30
BZR_EXE = None
 
31
def bzr():
 
32
    global BZR_EXE
 
33
    if BZR_EXE is not None:
 
34
        return BZR_EXE
 
35
    try:
 
36
        subprocess.call(['bzr', '--version'], stdout=subprocess.PIPE,
 
37
                        stderr=subprocess.PIPE)
 
38
        BZR_EXE = 'bzr'
 
39
    except OSError:
 
40
        try:
 
41
            subprocess.call(['bzr.bat', '--version'], stdout=subprocess.PIPE,
 
42
                            stderr=subprocess.PIPE)
 
43
            BZR_EXE = 'bzr.bat'
 
44
        except OSError:
 
45
            raise RuntimeError('Could not find bzr or bzr.bat on your path.')
 
46
    return BZR_EXE
 
47
 
 
48
 
 
49
def call_or_fail(*args, **kwargs):
 
50
    """Call a subprocess, and fail if the return code is not 0."""
 
51
    if DEBUG_SUBPROCESS:
 
52
        print '  calling: "%s"' % (' '.join(args[0]),)
 
53
    p = subprocess.Popen(*args, **kwargs)
 
54
    (out, err) = p.communicate()
 
55
    if p.returncode != 0:
 
56
        raise RuntimeError('Failed to run: %s, %s' % (args, kwargs))
 
57
    return out
 
58
 
 
59
 
 
60
TARGET = None
 
61
def get_target():
 
62
    global TARGET
 
63
    if TARGET is not None:
 
64
        return TARGET
 
65
    out = call_or_fail([sys.executable, get_bzr_dir() + '/bzr',
 
66
                        'version', '--short'], stdout=subprocess.PIPE)
 
67
    version = out.strip()
 
68
    TARGET = os.path.abspath(TARGET_ROOT + '-' + version)
 
69
    return TARGET
 
70
 
 
71
 
 
72
def clean_target():
 
73
    """Nuke the target directory so we know we are starting from scratch."""
 
74
    target = get_target()
 
75
    if os.path.isdir(target):
 
76
        print "Deleting: %s" % (target,)
 
77
        shutil.rmtree(target)
 
78
 
 
79
def get_bzr_dir():
 
80
    return 'bzr.' + VERSIONS['bzr']
 
81
 
 
82
 
 
83
def update_bzr():
 
84
    """Make sure we have the latest bzr in play."""
 
85
    bzr_dir = get_bzr_dir()
 
86
    if not os.path.isdir(bzr_dir):
 
87
        bzr_version = VERSIONS['bzr']
 
88
        bzr_url = 'http://bazaar-vcs.org/bzr/bzr.' + bzr_version
 
89
        print "Getting bzr release %s from %s" % (bzr_version, bzr_url)
 
90
        call_or_fail([bzr(), 'co', bzr_url])
 
91
    else:
 
92
        print "Ensuring %s is up-to-date" % (bzr_dir,)
 
93
        call_or_fail([bzr(), 'update', bzr_dir])
 
94
 
 
95
 
 
96
def create_target():
 
97
    target = get_target()
 
98
    print "Creating target dir: %s" % (target,)
 
99
    call_or_fail([bzr(), 'co', get_bzr_dir(), target])
 
100
 
 
101
 
 
102
def get_plugin_trunk_dir(plugin_name):
 
103
    return '%s/trunk' % (plugin_name,)
 
104
 
 
105
 
 
106
def get_plugin_release_dir(plugin_name):
 
107
    return '%s/%s' % (plugin_name, VERSIONS[plugin_name])
 
108
 
 
109
 
 
110
def get_plugin_trunk_branch(plugin_name):
 
111
    return 'lp:%s' % (plugin_name,)
 
112
 
 
113
 
 
114
def update_plugin_trunk(plugin_name):
 
115
    trunk_dir = get_plugin_trunk_dir(plugin_name)
 
116
    if not os.path.isdir(trunk_dir):
 
117
        plugin_trunk = get_plugin_trunk_branch(plugin_name)
 
118
        print "Getting latest %s trunk" % (plugin_name,)
 
119
        call_or_fail([bzr(), 'co', plugin_trunk,
 
120
                      trunk_dir])
 
121
    else:
 
122
        print "Ensuring %s is up-to-date" % (trunk_dir,)
 
123
        call_or_fail([bzr(), 'update', trunk_dir])
 
124
    return trunk_dir
 
125
 
 
126
 
 
127
def _plugin_tag_name(plugin_name):
 
128
    if plugin_name in ('bzr-svn', 'bzr-rebase', 'subvertpy'):
 
129
        return '%s-%s' % (plugin_name, VERSIONS[plugin_name])
 
130
    # bzrtools and qbzr use 'release-X.Y.Z'
 
131
    return 'release-' + VERSIONS[plugin_name]
 
132
 
 
133
 
 
134
def update_plugin(plugin_name):
 
135
    release_dir = get_plugin_release_dir(plugin_name)
 
136
    if not os.path.isdir(plugin_name):
 
137
        if plugin_name in ('bzr-svn', 'bzr-rebase'):
 
138
            # bzr-svn uses a different repo format
 
139
            call_or_fail([bzr(), 'init-repo', '--rich-root-pack', plugin_name])
 
140
        else:
 
141
            os.mkdir(plugin_name)
 
142
    if os.path.isdir(release_dir):
 
143
        print "Removing existing dir: %s" % (release_dir,)
 
144
        shutil.rmtree(release_dir)
 
145
    # First update trunk
 
146
    trunk_dir = update_plugin_trunk(plugin_name)
 
147
    # Now create the tagged directory
 
148
    tag_name = _plugin_tag_name(plugin_name)
 
149
    print "Creating the branch %s" % (release_dir,)
 
150
    call_or_fail([bzr(), 'co', '-rtag:%s' % (tag_name,),
 
151
                  trunk_dir, release_dir])
 
152
    return release_dir
 
153
 
 
154
 
 
155
def install_plugin(plugin_name):
 
156
    release_dir = update_plugin(plugin_name)
 
157
    # at least bzrtools doesn't like you to call 'setup.py' unless you are in
 
158
    # that directory specifically, so we cd, rather than calling it from
 
159
    # outside
 
160
    print "Installing %s" % (release_dir,)
 
161
    call_or_fail([sys.executable, 'setup.py', 'install', '-O1',
 
162
                  '--install-lib=%s' % (get_target(),)],
 
163
                 cwd=release_dir)
 
164
 
 
165
 
 
166
def update_tbzr():
 
167
    tbzr_loc = os.environ.get('TBZR', None)
 
168
    if tbzr_loc is None:
 
169
        raise ValueError('You must set TBZR to the location of tortoisebzr.')
 
170
    print 'Updating %s' % (tbzr_loc,)
 
171
    call_or_fail([bzr(), 'update', tbzr_loc])
 
172
 
 
173
 
 
174
def build_installer():
 
175
    target = get_target()
 
176
    print
 
177
    print
 
178
    print '*' * 60
 
179
    print 'Building standalone installer'
 
180
    call_or_fail(['make', 'PYTHON=%s' % (PYTHON,), 'installer'],
 
181
                 cwd=target)
 
182
 
 
183
 
 
184
def main(args):
 
185
    import optparse
 
186
 
 
187
    p = optparse.OptionParser(usage='%prog [OPTIONS]')
 
188
    opts, args = p.parse_args(args)
 
189
 
 
190
    update_bzr()
 
191
    update_tbzr()
 
192
    clean_target()
 
193
    create_target()
 
194
    install_plugin('subvertpy')
 
195
    install_plugin('bzrtools')
 
196
    install_plugin('qbzr')
 
197
    install_plugin('bzr-svn')
 
198
    install_plugin('bzr-rebase')
 
199
 
 
200
    build_installer()
 
201
 
 
202
 
 
203
if __name__ == '__main__':
 
204
    main(sys.argv[1:])
 
205
 
 
206
# vim: ts=4 sw=4 sts=4 et ai