-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_project_manager.py
executable file
·909 lines (712 loc) · 26.9 KB
/
update_project_manager.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
#!/usr/bin/env python
#
# Copyright 2013, Intel Inc.
#
# 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; version 2 of the License.
#
# 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 Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# author: Ronan Le Martret ronan@fridu.net
import sys
import os
import re
import subprocess
import shlex
import fcntl
import os
import time
import select
import errno
import ConfigParser
from xml.etree import ElementTree
import signal
try:
import cmdln
except:
print 'Error spec2yocto require "python-cmdln" please install it.'
sys.exit( 1 )
TERMINAL_COLORS = {"black": "\033[30;1m",
"red": "\033[31;1m",
"green": "\033[32;1m",
"yellow": "\033[33;1m",
"blue": "\033[34;1m",
"magenta": "\033[35;1m",
"cyan": "\033[36;1m",
"white": "\033[37;1m",
"default": "\033[0m"}
TO_EXIT=False
def signal_handler(signal, frame):
global TO_EXIT
TO_EXIT=True
print 'You pressed Ctrl+C!'
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
def colorize( text, color = "green" ):
"""
Return a colorized copy of `text`.
See Utils.TERMINAL_COLORS.keys() for available colors.
"""
return TERMINAL_COLORS.get( color, "" ) + text + TERMINAL_COLORS["default"]
class SubprocessCrt( object ):
'''
usefull class to control subprocess
'''
def __init__( self ):
'''
Initialize subprocess.
'''
self.output_res = ""
self.__idle_time = 0
def get_last_res( self ):
'''
return the last subprocess output.
'''
return self.output_res
def __read_subprocess_output( self, outputs, f_stdout, f_stderr ):
'''
read the stdout, stderr of the subprocess
'''
timed_out = True
select_timeout = 60
for file_d in select.select( [f_stdout, f_stderr], [], [], select_timeout )[0]:
timed_out = False
output = file_d.read()
if f_stdout == file_d:
self.output_res += output
else:
if ( len( output ) > 0 ):
print "ERROR ****", output, len( output )
for line in output.split( "\n" ):
if not line == b"" or not output.endswith( "\n" ):
outputs[file_d]["EOF"] = False
if line == b"" and not output.endswith( "\n" ):
outputs[file_d]["EOF"] = True
elif line != "" :
res_clean = line.decode( "utf8", "replace" ).rstrip()
if timed_out:
self.__idle_time += select_timeout
else:
self.__idle_time = 0
def exec_subprocess( self, command ):
'''
Execute the "command" in a sub process,
the "command" must be a valid bash command.
_args and _kwargs are for compatibility.
'''
self.output_res = ""
# need Python 2.7.3 to do shlex.split(command)
splitted_command = shlex.split( str( command ) )
a_process = subprocess.Popen( splitted_command,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE )
f_stdout = a_process.stdout
f_stderr = a_process.stderr
flags = fcntl.fcntl( f_stdout, fcntl.F_GETFL )
if not f_stdout.closed:
fcntl.fcntl( f_stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK )
flags = fcntl.fcntl( f_stderr, fcntl.F_GETFL )
if not f_stderr.closed:
fcntl.fcntl( f_stderr, fcntl.F_SETFL, flags | os.O_NONBLOCK )
outputs = {f_stdout: {"EOF": False},
f_stderr: {"EOF": False}}
while ( ( not outputs[f_stdout]["EOF"] and
not outputs[f_stderr]["EOF"] ) or
( a_process.poll() == None ) ):
try:
self.__read_subprocess_output( outputs, f_stdout, f_stderr )
except select.error as error:
# see http://bugs.python.org/issue9867
if error.args[0] == errno.EINTR:
print "Got select.error: %s" % unicode( error )
continue
else:
raise Exception()
# maybe a_process.wait() is better ?
poll_res = a_process.poll()
if poll_res != 0:
return poll_res
return self.output_res
class update_project_manager_config( object ):
'''
Parse the file "spec2yocto_configure",
'''
def __init__( self ):
self.__config_parser = ConfigParser.ConfigParser()
self.__config_parser.optionxform = str
file_conf = "/etc/TizenManifestManager/update_project.conf"
if os.path.isfile( file_conf ):
self.__config_file = open( file_conf , 'rw' )
self.__config_parser.readfp( self.__config_file )
else:
self.__config_file = None
def __get_list( self, section, option, default_value ):
'''
generic function to get list value.
'''
if ( section in self.__config_parser.sections() ) and \
( option in self.__config_parser.options( section ) ):
tmp_res = str( self.__config_parser.get( section, option ) )
return tmp_res.split( "," )
else:
return default_value
def print_list_project( self ):
'''
function to print list of project.
'''
if self.__config_file is not None:
print " ".join( self.__config_parser.sections() )
return 0
def print_arch( self, project ):
'''
function to print arch of project.
'''
val = self.__get_list( project, "arch", [""] )
print val[0]
def get_manifest_list( self, project ):
'''
function to print arch of project.
'''
val = self.__get_list( project, "manifest", [] )
return val
def print_manifest_file( self, project, manifest ):
'''
function to print arch of project.
'''
val = self.__get_list( project, manifest, [""] )
print val[0]
def print_alias_file( self, project ):
'''
function to print arch of project.
'''
val = self.__get_list( project, "alias", None )
if val is not None:
print val[0]
def print_blacklist_file( self, project ):
'''
function to print arch of project.
'''
val = self.__get_list( project, "blacklist", None )
if val is not None:
print val[0]
def print_constraints_file( self, project ):
'''
function to print constraints of project.
'''
val = self.__get_list( project, "constraints", None )
if val is not None:
print val[0]
def clean_path( raw_name ):
return os.path.basename(raw_name)
def parse_manifest_xml( src, remote_dico={}, packages_dico={}, alias_dico={} ):
primaryFile = open( src, "r" )
primaryXML = primaryFile.read()
primaryFile.close()
aElement = ElementTree.fromstring( primaryXML )
default_remote=None
for value in aElement:
for project in value.getiterator():
if project.tag == "project":
git_name = project.attrib['name']
if 'path' in project.attrib:
git_path = project.attrib['path']
else:
git_path = git_name
# remove .git extension if any
git_path = re.sub("\.git$","",git_path)
git_name = re.sub("\.git$","",git_name)
revision = clean_revision( project.attrib['revision'] )
if 'remote' in project.attrib:
remote=project.attrib['remote']
else:
remote = default_remote
packages_dico[clean_path( git_path)] = Git_Package(git_name, git_path, revision, remote)
if '{http://tizen.org}origin_name' in project.attrib and \
'{http://tizen.org}origin_revision' in project.attrib and \
'{http://tizen.org}origin_remote' in project.attrib:
tzname = project.attrib['{http://tizen.org}origin_name']
tzrevision = project.attrib['{http://tizen.org}origin_revision']
tzremote = project.attrib['{http://tizen.org}origin_remote']
packages_dico[clean_path( git_path)].set_origin(tzname,tzrevision,tzremote)
elif project.tag == "default":
default_remote = project.attrib['remote']
elif project.tag == "remote":
fetch = project.attrib['fetch']
name = project.attrib['name']
remote_dico[name]=fetch
elif project.tag == "{http://tizen.org}alias":
scr = project.attrib['scr']
name = project.attrib['name']
if scr not in alias_dico.keys():
alias_dico[scr]=[]
if name not in alias_dico[scr]:
alias_dico[scr].append(name)
else:
print "ERROR",project.tag
if default_remote is not None:
for attr in packages_dico.keys():
if packages_dico[attr].remote is None:
packages_dico[attr].remote=default_remote
return remote_dico, packages_dico, alias_dico
def get_package_manifest_xml( src ):
remote_dico, packages_dico, alias_dico = parse_manifest_xml( src )
packages_list=packages_dico.keys()
for package_name in packages_list:
if package_name in alias_dico.keys():
for p_alias in alias_dico[package_name]:
packages_list.append(p_alias)
packages_list.sort()
return packages_list
def project_is_disable( meta_project_file ):
primaryFile = open( meta_project_file, "r" )
primaryXML = primaryFile.read()
primaryFile.close()
aElement = ElementTree.fromstring( primaryXML )
packages_list = []
for value in aElement:
for project in value.getiterator():
if project.tag == "build":
for build in value.getiterator():
if (build.tag == "disable") and not build.attrib:
print "yes"
return 0
def print_list_package( src):
packages_list = get_package_manifest_xml( src )
print "\n".join( packages_list )
def parse_alias_file( src ):
aliasFile = open( src, "r" )
aliastxt=aliasFile.read()
aliasFile.close()
res={}
for line in aliastxt.split("\n"):
tmp_res= line.split(" ")
if len(tmp_res)>=2:
res[ tmp_res[0] ] = tmp_res[1:]
return res
def parse_blacklist_file( src ):
aliasFile = open( src, "r" )
aliastxt=aliasFile.read()
aliasFile.close()
res=[]
for line in aliastxt.split("\n"):
res.append(line)
return res
def clean_revision( raw_name ):
if "-" in raw_name:
return raw_name.split( "-" )[0]
else:
return raw_name
start_manifext_xml='''<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:tz="http://tizen.org">\n'''
end_manifext_xml='''</manifest>'''
def generate_manifest(remote_dico, packages_dico, alias_dico={}, blacklist_list=[]):
file_res = start_manifext_xml
list_package_tmp = packages_dico.keys()
list_package_tmp.sort()
default_remote="tizen-gerrit"
for remote in remote_dico.keys():
fetch=remote_dico[remote]
if ( fetch == "None" ):
fetch="ssh://review.tizen.org"
have_remote=False
for package_name in list_package_tmp:
if packages_dico[package_name].remote == remote:
have_remote=True
break
if have_remote:
file_res+=" <remote fetch=\"%s\" name=\"%s\" />\n" % (fetch,remote)
if default_remote not in remote_dico.keys():
default_remote=None
else:
file_res+=" <default remote=\"%s\"/>\n" % default_remote
list_package=[]
for package_name in list_package_tmp:
if package_name not in blacklist_list:
list_package.append(package_name)
if package_name in alias_dico.keys():
for p_alias in alias_dico[package_name]:
file_res+=" <tz:alias scr=\"%s\" name=\"%s\"/>\n" % (package_name,p_alias)
list_package.sort()
for package_name in list_package:
file_res+=packages_dico[package_name].get_xml_line(default_remote)
file_res+=end_manifext_xml
return file_res
def merge_manifest(blacklist_file,alias_file,manifest_xml_srcs,manifest_xml_dst):
if alias_file is not None or alias_file == "":
alias_dico= parse_alias_file( alias_file )
else:
alias_dico={}
if blacklist_file is not None or blacklist_file == "":
blacklist_list=parse_blacklist_file(blacklist_file)
else:
blacklist_list=[]
packages_dico={}
remote_dico={}
for manifest_xml_src in manifest_xml_srcs:
remote_dico, packages_dico, alias_dico = parse_manifest_xml(manifest_xml_src, remote_dico, packages_dico, alias_dico )
res=generate_manifest(remote_dico, packages_dico, alias_dico, blacklist_list)
file_res= open(manifest_xml_dst,"w")
file_res.write(res)
file_res.close()
return 0
def create_package_from_manifest(project_dir, manifest_xml_src):
project_dir = os.path.abspath( project_dir )
manifest_xml_src = os.path.abspath( manifest_xml_src )
if not os.path.isdir( project_dir ):
error_message = "%s is not a directory."
print error_message % ( project_dir )
sys.exit( 1 )
remote_dico, packages_dico, alias_dico = parse_manifest_xml( manifest_xml_src )
for package_name in packages_dico.keys():
git_package= packages_dico[package_name]
fetch=remote_dico[git_package.remote]
if "//" in fetch:
fetch=fetch.split("//")[1]
write_package_service( fetch,
project_dir,
package_name,
git_package.name,
git_package.revision )
if package_name in alias_dico.keys():
for package_alias in alias_dico[package_name]:
print "package_alias",package_alias
write_package_service( fetch,
project_dir,
package_alias,
git_package.name,
git_package.revision )
_service_template_1 = """<services>
<service name="gbs">
<param name="url">%s:%s</param>
<param name="revision">%s</param>
<param name="spec">%s</param>
</service>
</services>"""
_service_template_2 = """<services>
<service name="gbs">
<param name="url">%s:%s</param>
<param name="revision">%s</param>
</service>
</services>"""
_service_template_tizen = """<services>
<service name='gbs'>
<param name='revision'>%s</param>
<param name='url'>ssh://%s/%s</param>
</service>
</services>"""
def create_service( fetch, git_name, revision, package_name ):
return _service_template_tizen% ( revision, fetch, git_name )
#if package_name is None:
# return _service_template_2 % ( fetch, git_name, revision )
#else:
# return _service_template_1 % ( fetch, git_name, revision, package_name )
def write_package_service( fetch, project_dir, package_name , git_name, package_revision ):
service = create_service( fetch, git_name, package_revision, package_name )
pkgPath = project_dir + "/" + package_name
pkgPathSrv = pkgPath + "/_service"
if not os.path.isdir( pkgPath ):
os.mkdir( pkgPath )
g = open( pkgPathSrv, 'w' )
g.write( service )
g.close()
def cleanTag_line(tag_line):
if "\t" in tag_line:
return tag_line.split("\t")[0] , tag_line.split("\t")[1].replace("refs/tags/","")
else:
return None,tag_line
def getLastTag(tag_list):
dicoresult={}
for tag_line in tag_list.split("\n"):
if "accepted/" in tag_line or "submit/" in tag_line:
sha, clean_tag= cleanTag_line(tag_line)
date_tag=getTagDate(clean_tag)
if date_tag is not None and date_tag.endswith("^{}"):
dicoresult[ date_tag[:-3] ]=[ sha, clean_tag[:-3] ]
return dicoresult
class Git_Package:
def __init__(self,git_name, git_path, revision, remote):
self.path=git_path
self.name=git_name
self.revision=revision
self.remote=remote
self.tz_origin_name=None
self.tz_origin_revision=None
self.tz_origin_remote=None
def set_origin(self,name,revision,remote):
self.tz_origin_name=name
self.tz_origin_revision=revision
self.tz_origin_remote=remote
def __have_origin(self):
return self.tz_origin_name is not None and \
self.tz_origin_revision is not None and \
self.tz_origin_remote is not None
def get_update_package(self):
if self.__have_origin():
return Git_Package(self.tz_origin_name, self.path, self.tz_origin_revision, self.tz_origin_remote)
else:
return self
def get_xml_line(self,default_remote=None):
if default_remote is None or default_remote != self.remote:
remote_tag = "remote=\"%s\"" % self.remote
else:
remote_tag = ""
if self.__have_origin():
remote_origin = "tz:origin_name=\"%s\" tz:origin_revision=\"%s\" tz:origin_remote=\"%s\"" %(self.tz_origin_name, self.tz_origin_revision, self.tz_origin_remote)
else:
remote_origin = ""
xml_line = " <project name=\"%s\" path=\"%s\" revision=\"%s\" %s %s />\n" % (self.name, clean_path( self.path ), self.revision, remote_tag, remote_origin)
return xml_line
class CommitRemote:
def __init__(self):
self.tag=None
self.alias_tag=None
self.commit=None
self.alias_commit=None
self.date_tag=None
self.alias_sha=None
self.sha=None
def setCommitValue(self,date_tag,sha) :
if date_tag.endswith("^{}"):
self.alias_tag=date_tag
self.tag=self.alias_tag[:-3]
self.alias_sha=sha
else:
self.tag=date_tag
self.sha=sha
self.date_tag=getTagDate(self.tag)
def getSha(self):
if self.alias_sha is not None:
return self.alias_sha
else:
return self.sha
class CommitCollection:
def __init__(self, gitTag):
self.commit_dico = {}
self.__origin_tag = gitTag
self.__origin_date_tag = getTagDate(gitTag)
self.__origin_sha = None
def __have_a_valid_date(self,test_date=None):
#What is a valid date?
#TODO ???
if test_date is None:
test_date=self.__origin_date_tag
if test_date is None:
return False
if len("20121215.161330") == len(test_date) and \
test_date.count(".") == 1:
return True
return False
def initFromString(self, tag_list):
for tag_line in tag_list.split("\n"):
sha, clean_tag= cleanTag_line(tag_line)
commit_key=clean_tag
if commit_key.endswith("^{}"):
commit_key=commit_key[:-3]
if commit_key not in self.commit_dico.keys():
self.commit_dico[commit_key]=CommitRemote()
self.commit_dico[commit_key].setCommitValue(clean_tag,sha)
def __check_origin_sha(self):
for commit_key in self.commit_dico.keys():
if commit_key == self.__origin_tag:
self.__origin_sha = self.commit_dico[commit_key].getSha()
return True
elif self.commit_dico[commit_key].getSha() == self.__origin_tag:
return True
return False
def get_candidates(self):
res=[]
for commit_key in self.commit_dico.keys():
if commit_key.startswith("accepted/") and "/tizen/" in commit_key:
if self.commit_dico[commit_key].getSha() != self.__origin_sha:
res.append(commit_key)
return res
def have_newer_tag(self):
if self.__origin_date_tag is not None and not self.__have_a_valid_date():
return False
if not self.__check_origin_sha():
print "No sha for commit origine"
return False
candidates_list=self.get_candidates()
self.newer_commit=None
self.newer_commit_date=None
for candidate in candidates_list:
if self.__have_a_valid_date(self.commit_dico[candidate].date_tag) and \
self.is_newer(candidate):
self.newer_commit = candidate
self.newer_commit_date=self.commit_dico[candidate].date_tag
return self.newer_commit is not None
def getLastTag(self):
return self.commit_dico[self.newer_commit].tag
def is_newer(self, candidate):
candidate_date=self.commit_dico[candidate].date_tag
if candidate_date is None:
return False
elif self.__origin_date_tag is None and self.newer_commit is None:
return True
elif self.newer_commit is None:
return candidate_date > self.__origin_date_tag
else:
return (candidate_date > self.__origin_date_tag ) and ( candidate_date > self.newer_commit_date)
def getTagDate(clean_tag):
if not "/tizen/" in clean_tag:
return None
else:
return clean_tag.split("/")[-1]
def checkRemote(remote_dico,packages_dico):
global TO_EXIT
subProcessor=SubprocessCrt()
list_package=packages_dico.keys()
list_package.sort()
i=1
for package_name in list_package:
if TO_EXIT:
break
print "package %s %s/%s" % ( package_name, i, len(list_package) )
git_package = packages_dico[package_name].get_update_package()
packages_dico[package_name]=git_package
remote=remote_dico[git_package.remote]
if "//" in remote:
remote=remote.split("//")[1]
cmd="git ls-remote --tags %s:%s" % (remote, git_package.name)
try:
tag_list=subProcessor.exec_subprocess(cmd)
res=0
except:
print cmd," failed"
if type(tag_list) == type(-1):
i=i+1
continue
commitCol=CommitCollection( packages_dico[package_name].revision)
commitCol.initFromString(tag_list)
if commitCol.have_newer_tag():
lastTag=commitCol.getLastTag()
print "Tag ",lastTag," is newer then ",packages_dico[package_name].revision
packages_dico[package_name].revision = lastTag
i=i+1
return packages_dico
def update_manifest(manifest_src, manifest_dst ):
remote_dico, packages_dico, alias_dico = parse_manifest_xml( manifest_src )
packages_dico=checkRemote(remote_dico,packages_dico)
res=generate_manifest(remote_dico, packages_dico, alias_dico)
file_res= open(manifest_dst,"w")
file_res.write(res)
file_res.close()
return 0
class update_project_manager_commandline( cmdln.Cmdln ):
name = "update_project_manager"
version = "0.1"
UPM_CONFIG = update_project_manager_config()
def do_list_project( self, subcmd, opts):
"""${cmd_name}: return the project list.
${cmd_usage}--
${cmd_option_list}
"""
self.UPM_CONFIG.print_list_project()
def do_get_manifest_list( self, subcmd, opts, project ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
res = self.UPM_CONFIG.get_manifest_list( project )
print " ".join( res )
def do_get_arch( self, subcmd, opts, project ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
self.UPM_CONFIG.print_arch( project )
def do_list_package( self, subcmd, opts, manifest_path ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
print_list_package( manifest_path )
def do_project_is_disable( self, subcmd, opts,meta_project_file ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
project_is_disable( meta_project_file )
def do_get_manifest_file( self, subcmd, opts, project,manifest ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
self.UPM_CONFIG.print_manifest_file( project, manifest )
def do_get_alias_file( self, subcmd, opts, project ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
self.UPM_CONFIG.print_alias_file( project )
def do_get_blacklist_file( self, subcmd, opts, project ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
self.UPM_CONFIG.print_blacklist_file( project )
def do_get_constraints_file( self, subcmd, opts, project ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
self.UPM_CONFIG.print_constraints_file( project )
def do_update_manifest( self, subcmd, opts, manifest_src, manifest_dst ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
return update_manifest(manifest_src, manifest_dst )
@cmdln.option( "--blacklist",
action = "store",
default = None,
help = "blacklist file." )
@cmdln.option( "--alias",
action = "store",
default = None,
help = "alias file." )
@cmdln.option( "--manifest_dst",
action = "store",
default = None,
help = "manifest xml file dst." )
def do_merge_project_manifest( self, subcmd, opts, *manifest ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
res=merge_manifest(opts.blacklist, opts.alias, list(manifest), opts.manifest_dst)
return res
@cmdln.option( "--project_dir",
action = "store",
default = os.curdir,
help = "manifest xml file dst." )
def do_create_package_from_manifest( self, subcmd, opts, manifest ):
"""${cmd_name}: return the proto directory.
${cmd_usage}--
${cmd_option_list}
"""
res=create_package_from_manifest(opts.project_dir, manifest)
return res
def main():
commandline = update_project_manager_commandline()
try:
res = commandline.main()
except ValueError as ve:
print
print >> sys.stderr, colorize( str( ve ), "red" )
res = 1
except EnvironmentError as ioe:
print
print >> sys.stderr, colorize( str( ioe ), "red" )
res = 1
sys.exit( res )
if __name__ == '__main__':
main()