-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.py
executable file
·126 lines (100 loc) · 4.56 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
"""
build.py - Strip the trunk connotation from the version number, bump the number, branch,
build a distribution, and finally check in the version number bump change.
Can do local builds with -lt
(c) Copyright 2005 Philip Jenvey
[See end of file]
"""
import optparse, os, re, setup, sys
from build_util import *
__id__ = '$Id$'
UPLOAD_HOST = 'groovie.org'
UPLOAD_HOST_DIR = '/usr/local/www/hellanzb.com/distfiles/'
try:
parser = optparse.OptionParser()
parser.add_option('-l', '--local', action='store_true', dest='local',
help='Do a local build (don\'t commit version changes)')
parser.add_option('-t', '--trunk', action='store_true', dest='trunk',
help='Assume this is a trunk build, and do not bump the version number')
options, args = parser.parse_args()
if sys.version <= '2.5':
assertIsExe('sha256')
if not options.local:
assertIsExe('svn')
# If not local, make sure the working copy is up to date with the repository!
if not options.local:
assertUpToDate()
versionFile = open(VERSION_FILENAME)
versionLine = versionFile.read()
versionLine = versionLine.rstrip()
versionFile.close()
assert(versionLine[0:len('version')] == 'version', 'version file is broken!')
versionLine = re.sub(r'^.*\ \'', r'', versionLine)
version = re.sub(r'\'', r'', versionLine)
if version.endswith('-trunk'):
if not options.trunk:
# Bump the version to a stable number
version = version[0:-len('-trunk'):]
writeVersion(version)
# branch if doing a release
if not options.trunk and not options.local:
# branch the codebase, and make our working copy that branch
origRepository = getRepository()
# NOTE: This will switch our working directory to the new branch
branchRelease(version)
# Build
print 'Building version: ' + version
if os.path.isfile('MANIFEST'):
os.remove('MANIFEST')
# overwrite setup's version to the new, and build the distributions
setup.version = version
buildDist()
buildPort(version)
buildDPort(version)
if not options.trunk and not options.local:
print 'Switching back to trunk'
os.system('svn switch ' + origRepository)
if not options.trunk:
# Append -trunk back to the number
newVersion = bumpVersion(version) + '-trunk'
writeVersion(newVersion)
# Check in changes to trunk
if not options.local and not options.trunk:
print 'Checking in new version number: ' + newVersion
os.system('svn ci -m "New build, version: ' + version + ' trunk now: ' + \
newVersion + '" ' + VERSION_FILENAME)
print 'Deploying new build to host: ' + UPLOAD_HOST
uploadToHost(version, UPLOAD_HOST, UPLOAD_HOST_DIR)
else:
print 'Error: Version number: ' + version + ' is not the trunk!'
sys.exit(1)
except IndexError:
sys.exit(1)
"""
Copyright (c) 2005 Philip Jenvey <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author or contributors may not be used to endorse or
promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
$Id$
"""