-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion
More file actions
executable file
·80 lines (59 loc) · 3.29 KB
/
version
File metadata and controls
executable file
·80 lines (59 loc) · 3.29 KB
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
#!/usr/bin/env python
import argparse
import package
parser = argparse.ArgumentParser(description = 'Reaver Project CI scripts: version')
parser.add_argument('-c', '--commit', action = 'store_true', help = 'Make a git commit after adding the version.')
subparsers = parser.add_subparsers(dest = 'command')
add_parser = subparsers.add_parser('add', help = 'Add a version to a package.')
add_parser.add_argument('package')
add_parser.add_argument('version')
add_parser.add_argument('-e', '--exception', action = 'append', help = 'Add an exception to specified version. The format is as follows: package1:version1/package2:version2. ' +
'The above specifies that this version is not to be built in combination with package1 in version1 and package2 in version2.\n')
get_parser = subparsers.add_parser('get', help = 'Get all allowed combinations of package versions and its bases.')
get_parser.add_argument('package')
get_parser.add_argument('-b', '--built-bases', action = 'store_true', help = 'Only allow built versions of bases.')
add_built_parser = subparsers.add_parser('add-built', help = 'Add a full version that has been built. Is validated against all available versions.')
add_built_parser.add_argument('package')
add_built_parser.add_argument('version')
get_built_parser = subparsers.add_parser('get-built', help = 'Get all versions that have been built, or all not built versions (if used with -v).')
get_built_parser.add_argument('package')
get_built_parser.add_argument('-v', '--inverted', action = 'store_true', help = 'Invert the selection.')
get_built_parser.add_argument('-V', '--not-built-built-bases', action = 'store_true', help = 'Invert the selection and only select built bases.')
args = parser.parse_args()
if args.command == 'add':
pkg = package.Package(args.package)
version = args.version
exceptions = []
if args.exception is not None:
exceptions = [ dict([ x.split(':') for x in exception.split('/') ]) for exception in args.exception ]
if version not in pkg.versions().keys():
pkg.add_version(version, exceptions)
message = 'Update package %s: add version %s.' % (pkg.name, version)
else:
pkg[version].add_exceptions(exceptions)
message = 'Update package %s: add exceptions to version %s.' % (pkg.name, version)
pkg.save()
elif args.command == 'get':
args.commit = False
pkg = package.Package(args.package)
for version in pkg.combined_versions(built_bases = args.built_bases):
print version
elif args.command == 'add-built':
pkg = package.Package(args.package)
version = args.version
if version not in pkg.combined_versions():
print 'Requested version: %s is not a valid version of package %s.' % (version, pkg.name)
exit(1)
pkg.add_built(version)
message = 'Update package %s: add a built version %s.' % (pkg.name, version)
pkg.save()
elif args.command == 'get-built':
args.commit = False
pkg = package.Package(args.package)
versions = pkg.combined_versions(built_bases = args.not_built_built_bases)
inverted = args.inverted or args.not_built_built_bases
versions = [ version for version in versions if not (version in pkg.built_versions()) == inverted ]
for version in versions:
print version
if args.commit:
package.commit_changes(pkg.name, message)