Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / solenv / bin / version.py
blob18c04414178d437d8dfab61d9816c25bd9007cd5
1 #!/usr/bin/env python
3 from __future__ import print_function
4 from optparse import OptionParser
5 import os.path
6 import re
7 import sys
9 M = {
10 'juh': 'javaunohelper',
11 'jurt': 'jurt',
12 'officebean': 'bean',
13 'ridl': 'ridljar',
14 'unoil': 'unoil',
15 'unoloader': 'ridljar',
18 parser = OptionParser()
19 _, args = parser.parse_args()
21 if not len(args):
22 parser.error('not enough arguments')
23 elif len(args) > 1:
24 parser.error('too many arguments')
26 DEST = r'\g<1>%s\g<3>' % args[0]
29 def replace_in_file(filename, src_pattern):
30 try:
31 f = open(filename, "r")
32 s = f.read()
33 f.close()
34 s = re.sub(src_pattern, DEST, s)
35 f = open(filename, "w")
36 f.write(s)
37 f.close()
38 except IOError as err:
39 print('error updating %s: %s' % (filename, err), file=sys.stderr)
41 src_pattern = re.compile(r'^(\s*<version>)([-.@\w]+)(</version>\s*)$',
42 re.MULTILINE)
44 for a in ['juh', 'jurt', 'officebean', 'ridl', 'unoil', 'unoloader']:
45 replace_in_file(os.path.join(M[a], 'pom.%s.xml' % a), src_pattern)
47 src_pattern = re.compile(r"^(LIBREOFFICE_VERSION = ')([-.@\w]+)(')$",
48 re.MULTILINE)
49 replace_in_file('solenv/maven/VERSION', src_pattern)