-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_reactos_soruces.py
More file actions
executable file
·132 lines (99 loc) · 4.17 KB
/
get_reactos_soruces.py
File metadata and controls
executable file
·132 lines (99 loc) · 4.17 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
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
# get_reactos_sources .py: Script to checkout the React OS sources
# Copyright (C) 2016 Pablo De Nápoli <pdenapo@gmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Dependencies: svn
from __future__ import print_function
import subprocess
import argparse
import os
import json
import sys
import xml.etree.ElementTree as etree
def get_svn_info_xml_file():
""" This function runs the "svn info" command on the React OS subversion repository, with outpoot in xml format in the file svn_info.xml in the current directory. """
svn_info_xml_file = open('svn_info.xml', 'w')
print('Running svn info for getting the current React OS version')
subprocess.call(['svn', 'info', '--xml',
'svn://svn.reactos.org/reactos'],
stdout=svn_info_xml_file)
svn_info_xml_file.close()
def get_current_revision():
""" This function gets the current revision number from the React OS subversion repository."""
get_svn_info_xml_file()
tree = etree.parse('svn_info.xml')
root = tree.getroot()
entry = root.find('entry')
revision = entry.get('revision')
return revision
def svn_checkout_reactos_trunk(revision, src_dir):
""" This function runs the "svn ckeckout" command to get the React OS sources """
print('Running svn checkout for revision', revision, 'into',
src_dir)
subprocess.call([
'svn',
'checkout',
'--revision',
revision,
'svn://svn.reactos.org/reactos/trunk',
src_dir,
])
def svn_update_reactos_trunk(revision, src_dir):
""" This function runs the "svn update" to update the React OS sources to a given revision """
print('Running svn update for revision', revision, 'into', src_dir)
subprocess.call(['svn', 'update', '--revision', revision, src_dir])
def check_if_inside_RosBE():
try:
output = subprocess.check_output(['version'])
except OSError:
print('Error running the version command.')
return False
print(output)
if output.find('ReactOS'):
return True
else:
return False
if __name__ == '__main__':
# We parse the command-line arguments
parser = \
argparse.ArgumentParser(description='Checkout the ReactOS sources.'
)
parser.add_argument('--revision', dest='revision',
help='for which revision? [default=current revision]'
)
parser.add_argument('--config', dest='config_file_name',
help='configuration file to read',
default='config.json')
#parser.add_argument('--compile', action='store_const', const=True,
# help='Compile React OS from the sources')
args = parser.parse_args()
# We use a configuration file with json format for several configuration parameters.
if os.path.isfile(args.config_file_name):
try:
config = json.load(open(args.config_file_name))
except ValueError:
print('Error parsing the configuration file',
args.config_file_name)
sys.exit(3)
else:
print('Configuration file', args.config_file_name,
' does not exist.')
sys.exit(4)
revision = args.revision
if revision == None:
revision = get_current_revision()
src_dir = os.path.abspath(config['reactos_src_dir'])
if os.path.exists(config['reactos_src_dir'] + '/reactos'):
svn_update_reactos_trunk(revision, src_dir)
else:
svn_checkout_reactos_trunk(revision, src_dir)