-
Notifications
You must be signed in to change notification settings - Fork 1
/
epics-build.py
executable file
·159 lines (143 loc) · 5.99 KB
/
epics-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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env python3
# Name: epics-build.py
# Abs: A tool to build one or more EPICS releases
#
# Packages specified by -p or --package with syntax pkg-name/pkg-version
# Example:
# epics-build -p iocAdmin/R3.1.15-1.0.0 -m autosave/R5.6.2-2.2.0
#
# Supports smart defaults and overrides for:
# * EPICS_MODULES - path to top of EPICS modules directory
# * EPICS_TOP or EPICS_SITE_TOP - path to top of EPICS release area
#
# Auth: 13-Dec-2016, Bruce Hill (bhill)
# Rev: dd-mmm-yyyy, Reviewer's Name (USERNAME)
#
# Requested features to be added:
#
#==============================================================
import sys
import os
import socket
import subprocess
import argparse
import readline
import shutil
import tempfile
import textwrap
import Repo
import gitRepo
import svnRepo
import Releaser
from git_utils import *
from svn_utils import *
from version_utils import *
from eco_version import eco_tools_version
from repo_defaults import *
def build_modules( options ):
status = 0
if options.top:
if not os.path.isdir( options.top ):
print("Invalid --top %s" % options.top)
try:
releases = find_releases( options )
if len(releases) == 0:
status = 1
else:
for release in releases:
result = release.InstallPackage( installTop=options.top, force=options.force, rmFailed=options.rmFailed )
if status == 0:
status = result
except:
print(sys.exc_info()[1])
print('build_modules: Not all packages were installed!')
return 1
return status
def find_releases( options ):
releases = []
for package in options.packages:
release = Releaser.find_release( package, verbose=options.verbose )
if release is None:
print("Error: Could not find packageSpec: %s" % package)
else:
releases += [ release ]
return releases
def buildDependencies( pkgTop, verbose=False ):
status = 0
# Check Dependendents
print("Checking dependents for %s" % ( pkgTop ))
buildDep = getEpicsPkgDependents( pkgTop )
for dep in buildDep:
if dep == 'base':
continue # Just check module dependents
package = "%s/%s" % ( dep, buildDep[dep] )
release = Releaser.find_release( package, verbose=verbose )
if release is None:
print("Error: Could not find package %s" % package)
continue
result = release.InstallPackage( )
if result != 0:
status = 1
return status
def process_options(argv):
if argv is None:
argv = sys.argv[1:]
description = 'epics-build builds one or EPICS module releases.\n'
epilog_fmt = '\nStandard EPICS modules can be specified w/ just the module basename.\n'\
+ 'Similarly, modules or packages which are listed in the eco modulelist\n'\
+ ' %s\n'\
+ 'can be specified w/ just the module or package name.\n'\
+ '\nLonger module repo paths will be checked against GIT_TOP (%s).\n' \
+ 'and also against svn tags top (%s).\n' \
+ 'and also cvs root (%s).\n' \
+ 'i.e. Repo searched for in $TOP/[module-path/]module-name/release-version\n' \
+ '\nExamples:\n' \
+ 'epics-build -p history/R2.6.1\n' \
+ 'epics-build -p asyn/4.31-0.1.0 --top /afs/slac/g/lcls/epics/R3.15.5-1.0/modules\n'
epilog = textwrap.dedent(epilog_fmt % ( gitModulesTxtFile, DEF_GIT_REPO_PATH, DEF_SVN_REPO, DEF_CVS_ROOT ))
parser = argparse.ArgumentParser( description=description, formatter_class=argparse.RawDescriptionHelpFormatter, epilog=epilog )
parser.add_argument( '-p', '--package', dest='packages', action='append', \
help='EPICS module-name/release-version. Ex: asyn/R4.30-1.0.1', default=[] )
# parser.add_argument( '-b', '--base', action='store', help='Use to set EPICS_BASE in RELEASE_SITE' )
parser.add_argument( '-f', '--input_file_path', action='store', help='Read list of module releases from this file' )
parser.add_argument( '-r', '--repo', action='store', help='repo url' )
parser.add_argument( '-t', '--top', action='store', help='Top of release area.' )
parser.add_argument( '--dep', action='store', help='Build dependencies for specified directory.' )
parser.add_argument( '--force', action='store_true', help='Force rebuild.' )
parser.add_argument( '--rmFailed', action='store_true', help='Remove failed builds.' )
parser.add_argument( '-v', '--verbose', action="store_true", help='show more verbose output.' )
parser.add_argument( '--version', action="version", version=eco_tools_version )
options = parser.parse_args( )
return options
def main(argv=None):
options = process_options(argv)
if (options.input_file_path):
try:
in_file = open(options.input_file_path, 'r')
except IOError as e:
sys.stderr.write('Could not open "%s": %s\n' % (options.input_file_path, e.strerror))
return None
# Read in pairs (package release) one per line
for line in in_file:
# Remove comments
line = line.partition('#')[0]
# Add anything that looks like a module release specification
modulePath = line.strip()
(module, release) = os.path.split( modulePath )
if module and release:
options.packages += [ modulePath ]
if options.verbose:
print('Adding: %s' % modulePath)
# repeat above for all lines in file
in_file.close()
if options.dep:
result = buildDependencies( options.dep, verbose=options.verbose )
if result != 0:
return
elif len( options.packages ) == 0:
print('Error: No module/release packages specified!')
return
return build_modules( options )
if __name__ == '__main__':
status = main()
sys.exit(status)