-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuildconf.py
757 lines (711 loc) · 30.5 KB
/
buildconf.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
#! /usr/bin/env python
from __future__ import print_function
import os
import sys
import yaml
import colorconsole as c
import multiprocessing
import execute
from utils import ignorePackage
import re
rockBranches = ["$ROCK_BRANCH", "$ROCK_FLAVOR"]
def setupCfg(cfg):
# todo: handle this files differently
path = cfg["pyScriptDir"]
# load server information if not already done
if not "server" in cfg:
with open(path+"/server.yml") as f:
cfg["server"] = yaml.safe_load(f)
# load the package information if not already done
path = cfg["devDir"]+"/autoproj/bob"
if not os.path.isdir(path):
execute.makeDir(path)
if not "packages" in cfg and os.path.isfile(path+"/packages.yml"):
with open(path+"/packages.yml") as f:
cfg["packages"] = yaml.safe_load(f)
with open(cfg["devDir"]+"/autoproj/manifest") as f:
manifest = yaml.safe_load(f)
if "exclude_packages" in manifest:
for p in manifest["exclude_packages"]:
cfg["ignorePackages"].append(p)
def listPackages(cfg):
path = cfg["devDir"]+"/autoproj/";
packages = []
wildcard_packages = []
folders = []
with open(path+"manifest") as f:
manifest = yaml.safe_load(f)
for packageSet in manifest["package_sets"]:
if not isinstance(packageSet, dict):
p = os.path.join(path, packageSet)
if os.path.exists(p):
folders.append([p, packageSet])
for d in os.listdir(path+"remotes"):
if os.path.isdir(path+"remotes/"+d):
packages.append([d, ""])
with open(path+"remotes/"+d+"/source.yml") as f:
source = yaml.safe_load(f)
if "version_control" in source:
for p in source["version_control"]:
# some rock configuration files are not well formated
# which results in a list with one key having no value
# instead of a dict
key = ""
items = p.items()
if len(items) == 1:
key, value = list(items)[0]
else:
for k, v in items:
if not v:
key = k
break
if "*" not in key:
packages.append([d, key])
else:
wildcard_packages.append([d, key])
files = getAutobuildFiles(path+"remotes/"+d)
for i in files:
with open(i) as f:
for line in f:
if "_package" in line:
l = line.split("_package")[1]
arrLine = None
if '"' in l:
arrLine = line.split('"')
elif "'" in l:
arrLine = line.split("'")
if arrLine:
if "#" not in arrLine[0]:
packages.append([d, arrLine[1]])
if "metapackage" in line:
l = line.split()
if len(l) == 3:
l1 = l[1].strip().replace('"', "").replace("'", "").replace(',', "")
l2 = l[2].strip().replace('"', "").replace("'", "").replace(',', "")
packages.append([d, l1, l2])
return (packages, wildcard_packages)
def getAutobuildFiles(path):
files = []
if os.path.isdir(path):
for d in os.listdir(path):
if os.path.isfile(path+"/"+d):
if ".autobuild" in d:
files.append(path+"/"+d)
return files
def checkBaseName(package, info):
if "gitPackage" in info:
if "$" in info["gitPackage"] and "*" not in package:
info["basename"] = info["gitPackage"]
info["gitPackage"] = info["gitPackage"].replace("$PACKAGE_BASENAME",
package.split("/")[-1])
info["gitPackage"] = info["gitPackage"].replace("$PACKAGE",
package.split("/")[-1])
def clonePackage(cfg, package, server, gitPackage, branch, commit, recursive=False):
clonePath = package
if package[-2:] == ".*":
arrPackage = package.split("/")[:-1]
p = gitPackage.split("/")[-1].split(".")[0]
if arrPackage[-1] != p:
arrPackage.append(p)
clonePath = "/".join(arrPackage)
if package in cfg["updated"]:
return False
else:
cfg["updated"].append(package)
clonePath = cfg["devDir"]+"/"+clonePath
if os.path.isdir(clonePath):
if cfg["update"]:
print("Updating " + clonePath + " ... " + c.END, end="")
# we ignore the branch if we want to checkout a specific commit
if commit == None:
out, err, r = execute.do(["git", "-C", clonePath, "branch"], cfg)
if r != 0:
cfg["errors"].append("update: "+package)
c.printError("\ncan't get branch of git repo \""+clonePath+"\":\n" + execute.decode(err))
else:
branches = execute.decode(out).splitlines()
current_branch = None
for b in branches:
if b[0] == "*":
current_branch = b.split()[1].strip()
if not branch:
out, err, r = execute.do(["git", "-C", clonePath, "remote", "show", "autobuild | sed -n '/HEAD branch/s/.*: //p'"], cfg)
if r != 0:
cfg["errors"].append("update: "+package)
c.printError("\ncan't get default branch of git repo \""+clonePath+"\":\n" + execute.decode(err))
else:
branch = execute.decode(out).strip()
print(branch + " [" + current_branch + "] " + c.END, end="")
if branch and branch != current_branch:
args = ["-t", "autobuild/"+branch]
for b in branches:
if branch == b.strip():
args = [branch]
break
out, err, r = execute.do(["git", "-C", clonePath, "checkout"]+args, cfg)
if r != 0:
cfg["errors"].append("update: "+package)
c.printError("\ncan't checkout given branch \""+clonePath+"\":\n" + execute.decode(err))
out = None
err = None
r = None
if commit != None:
out, err, r = execute.do(["git", "-C", clonePath, "checkout", commit], cfg)
else:
out, err, r = execute.do(["git", "-C", clonePath, "pull"], cfg)
if r != 0:
cfg["errors"].append("update: "+package)
c.printError("\ncan't update \""+clonePath+"\":\n" + execute.decode(err))
c.printWarning("done")
return True
else:
if not cfg["fetch"]:
c.printError(package+" is not cloned, call bob-fetch to update or clone the packages.")
cfg["errors"].append("missing: "+package)
c.printError("error")
return True
else:
print("Fetching " + clonePath + " ... " + c.END, end="")
sys.stdout.flush()
if server == "archive":
archivePath = "/".join(clonePath.split("/")[:-1])
out, err, r = execute.do(["wget", "-P", archivePath, gitPackage])
if r != 0:
cfg["errors"].append("wget: "+package)
c.printError("\ncan't fetch \""+clonePath+"\":\n" + execute.decode(err))
return True
sourceFile = os.path.join(archivePath, gitPackage.split("/")[-1])
arrFileName = gitPackage.split("/")[-1].split(".")
ending = arrFileName[-1]
folderName = ".".join(arrFileName[:-1])
cmd = []
if ending == "tar":
cmd = ["tar", "-xf", sourceFile, "-C", archivePath]
elif ending == "gz":
cmd = ["tar", "-xzf", sourceFile, "-C", archivePath]
if arrFileName[-2] == "tar":
folderName = ".".join(arrFileName[:-2])
elif ending == "tgz":
cmd = ["tar", "-xzf", sourceFile, "-C", archivePath]
elif ending == "bz2":
cmd = ["tar", "-xjf", sourceFile, "-C", archivePath]
if arrFileName[-2] == "tar":
folderName = ".".join(arrFileName[:-2])
elif ending == "zip":
cmd = ["unzip", sourceFile, "-d", archivePath]
out, err, r = execute.do(cmd)
if r != 0:
cfg["errors"].append("wget: "+package)
c.printError("\ncan't fetch (unpack) \""+clonePath+"\":\n" + execute.decode(err))
c.printError("\ncmd (unpack): \""+" ".join(cmd))
return True
# rename folder
cmd = ["mv", os.path.join(archivePath, folderName), clonePath]
out, err, r = execute.do(cmd)
if r != 0:
cfg["errors"].append("rename folder for: "+package)
c.printError("\ncan't rename (mv) \""+clonePath+"\":\n" + execute.decode(err))
c.printError("\ncmd (rename): \""+" ".join(cmd))
return True
else:
cmd = ["git", "clone", "-o", "autobuild", "-q", server+gitPackage, clonePath]
if branch and commit == None:
cmd += ["-b", branch]
if recursive:
cmd += ["--recursive"]
print(" ".join(cmd))
out, err, r = execute.do(cmd, cfg)
if r != 0:
cfg["errors"].append("clone: "+package)
c.printError("\ncan't clone \""+clonePath+"\":\n" + execute.decode(err))
return True
if commit != None:
out, err, r = execute.do(["git", "-C", clonePath, "checkout", commit], cfg)
if r != 0:
cfg["errors"].append("git checkout: "+package+" "+commit)
c.printError("\ncan't checkout \""+clonePath+"\":\n" + execute.decode(err))
return True
# apply patch if we have one
patch = cfg["pyScriptDir"] + "/patches/" + clonePath.split("/")[-1] + ".patch"
print("check for patches: "+patch, end="")
if os.path.exists(patch):
cmd = ["patch", "-N", "-p0", "-t", "-d", clonePath, "-i", patch]
print(" ".join(cmd))
out, err, r = execute.do(cmd)
print(execute.decode(out))
print(execute.decode(err))
print(r)
c.printWarning("done")
patch = cfg["pyScriptDir"] + "/patches/" + "_".join(clonePath.split("/")[-2:]) + ".patch"
print("check for patches: "+patch, end="")
if os.path.exists(patch):
cmd = ["patch", "-N", "-p0", "-t", "-d", clonePath, "-i", patch]
print(" ".join(cmd))
out, err, r = execute.do(cmd)
print(execute.decode(out))
print(execute.decode(err))
print(r)
c.printWarning("done")
return True
return False
def getServerInfo(cfg, pDict, info):
# todo:
# - parse patches
# - impelment clean tag support
# tag can be used as branches with git clone if no branch with
# the same name exists
setupCfg(cfg)
if len(pDict) == 1:
package, pInfo = list(pDict.items())[0]
info["package"] = package
haveServer = False
if "type" in pInfo:
if pInfo["type"] == "git" and "url" in pInfo:
haveServer = True
info["server"] = pInfo["url"]
info["gitPackage"] = ""
if pInfo["type"] == "archive" and "url" in pInfo:
info["archive"] = pInfo["url"]
if not haveServer:
for key,server in cfg["server"].items():
if key in pInfo:
info["server"] = server
info["gitPackage"] = pInfo[key]
if "branch" in pInfo:
if pInfo["branch"] in rockBranches:
info["branch"] = cfg["rockFlavor"]
else:
info["branch"] = pInfo["branch"]
if "tag" in pInfo:
info["branch"] = pInfo["tag"]
if "commit" in pInfo:
info["commit"] = pInfo["commit"]
if "with_submodules" in pInfo:
info["with_submodules"] = pInfo["with_submodules"]
return True
haveKey = False
haveServer = False
if "branch" in pDict:
if pDict["branch"] in rockBranches:
info["branch"] = cfg["rockFlavor"]
else:
info["branch"] = pDict["branch"]
if "tag" in pDict:
info["branch"] = pDict["tag"]
if "commit" in pDict:
info["commit"] = pDict["commit"]
if "with_submodules" in pDict:
info["with_submodules"] = pDict["with_submodules"]
for key, value in pDict.items():
if not value:
info["package"] = key
if haveServer:
return
haveKey = True
if key in cfg["server"]:
info["server"] = cfg["server"][key]
info["gitPackage"] = value
if haveKey:
return True
haveServer = True
if "type" in pDict:
if pDict["type"] == "git" and "url" in pDict:
info["server"] = pDict["url"]
info["gitPackage"] = ""
return True
#info.clear()
return False
def getPackageInfoHelper(cfg, package, base, info):
matches = {}
path = cfg["devDir"]+"/autoproj/remotes/"+cfg["packages"][base][0]
if not os.path.exists(path):
path = cfg["devDir"]+"/autoproj/"+cfg["packages"][base][0]
if not os.path.exists(path):
cfg["errors"].append("Cannot find path for: "+cfg["packages"][base][0])
c.printError("ERROR: Cannot find path for: "+cfg["packages"][base][0])
return False
with open(os.path.join(path, "source.yml")) as f:
source = yaml.safe_load(f)
if "version_control" in source:
for pDict in source["version_control"]:
info2 = {}
getServerInfo(cfg, pDict, info2)
if "package" in info2:
r = re.compile(info2["package"])
m = r.match(base)
if m and m.group() == base:
i2 = dict(info2)
i2["base"] = package
i2["remote"] = cfg["packages"][base][0]
if "gitPackage" in i2:
if "basename" in matches:
del matches["basename"]
checkBaseName(package, i2)
matches.update(i2)
if "package" in matches:
info.update(matches)
return True
# for key, value in matches.items():
# e = 0
# g = {}
# for l in value:
# if len(l["base"]) > e:
# g = l
# info.update(g)
# return True
return False
def getPackageInfo(cfg, package, info):
# check if we find the packages in the ignore list
if ignorePackage(cfg, package):
return
# check if we have an orogen package
if not cfg["orogen"] and "orogen" in package:
return
# check if the package is known as osdep
if package in cfg["osdeps"]:
return
#if package in cfg["overrides"]:
# return
setupCfg(cfg)
if package in cfg["packages"]:
return getPackageInfoHelper(cfg, package, package, info)
base = package
while "/" in base:
base = base[:base.rindex("/")]
if base+"/.*" in cfg["packages"]:
base = base + "/.*"
#c.printNormal("found wildcard packages: "+package+" ("+base+")")
return getPackageInfoHelper(cfg, package, base, info)
return False
def getPackageInfoFromRemoteFolder(cfg, package, folder, info):
with open(folder+"/source.yml") as f:
source = yaml.safe_load(f)
if "version_control" in source:
for pDict in source["version_control"]:
info2 = {}
if getServerInfo(cfg, pDict, info2):
info.append(info2)
# todo: add parsing of libs.autobuild (which is a ruby script)
matches = {}
files = getAutobuildFiles(folder)
for i in files:
with open(i) as f:
info3 = []
for line in f:
if "_package" in line:
l = line.split("_package")[1]
arrLine = None
if '"' in l:
arrLine = l.split('"')
elif "'" in l:
arrLine = l.split("'")
if arrLine:
if "#" not in arrLine[0]:
p = arrLine[1]
for i in info:
r = re.compile(i["package"])
m = r.match(p)
if m and m.group() == p:
i2 = dict(i)
i2["base"] = i2["package"]
i2["package"] = p
checkBaseName(p, i2)
if i2["package"] in matches:
matches[i2["package"]].update(i2)
else:
matches[i2["package"]] = i2
for key, value in matches.items():
info.append(value)
return True
def fetchPackage(cfg, package, layout_packages):
if package == ".":
return False
print("Check: " + package + " ... " + c.END, end="")
sys.stdout.flush()
setupCfg(cfg)
# check if we find the packages in the ignore list
if ignorePackage(cfg, package):
c.printWarning("done")
return
if (not cfg["orogen"] and "orogen" in package):
c.printWarning("done")
return True
if package in cfg["overrides"] and "fetch" in cfg["overrides"][package]:
le = len(cfg["errors"])
if cfg["fetch"]:
cfg["overrides"][package]["fetch"](cfg)
elif "check" in cfg["overrides"][package]:
cfg["overrides"][package]["check"](cfg)
if len(cfg["errors"]) == le:
layout_packages.append(package)
c.printWarning("done")
return True
else:
cfg["errors"].append("missing: "+package)
c.printError("error")
return False
if package in cfg["osdeps"]:
if cfg["fetch"] and cfg["no_os_deps"] == False:
if len(cfg["osdeps"][package]) > 1:
cfg["osdeps"][package][0](cfg, cfg["osdeps"][package][1])
else:
cfg["osdeps"][package][0](cfg, package)
c.printWarning("done")
return True
#if package in cfg["overrides"] and cfg["overrides"][package] == None:
# print(cfg["overrides"])
#print(package)
path = cfg["devDir"]+"/autoproj/remotes/"
matches = []
if cfg["name_matching"] :
for key, value in cfg["packages"].items():
if package in key and key not in layout_packages:
matches.append(key)
else:
for key, value in cfg["packages"].items():
if package == key and key not in layout_packages:
matches.append(key)
if package not in cfg["packages"]:
result = True
for match in matches:
if not fetchPackage(cfg, match, layout_packages):
result = False
return result
elif package == cfg["packages"][package][0]:
info = []
print("\n ", end="")
if getPackageInfoFromRemoteFolder(cfg, package, path+package, info):
le = len(cfg["errors"])
endM = True
for i in info:
if "$" not in i["gitPackage"]:
if "*" not in i["package"]:
fetchPackage(cfg, i["package"], layout_packages)
if len(cfg["errors"]) > le:
if endM:
c.printError("error")
return False
if endM:
c.printWarning("done")
return True
else:
info = {}
# override package if it is a metapackage
if len(cfg["packages"][package]) == 2:
package = cfg["packages"][package][1]
if getPackageInfo(cfg, package, info):
endM = True
le = len(cfg["errors"])
branch = None
commit = None
server = None
server2 = None
if "archive" in info:
server = "archive"
server2 = info["archive"]
elif not "server" in info:
cfg["errors"].append("fetch: "+package)
return
else:
server = info["server"]
server2 = info["gitPackage"]
if "branch" in info:
branch = info["branch"]
if "commit" in info:
commit = info["commit"]
if package in cfg["overrides"]:
value = cfg["overrides"][package]
if "branch" in value:
branch = value["branch"]
if "url" in value:
server = value["url"]
server2 = ""
if "github" in value:
server2 = value["github"]
else:
for key, value in cfg["overrides"].items():
r = re.compile(key)
m = r.match(package)
if m and m.group() == package:
if "branch" in value:
branch = value["branch"]
if "url" in value:
server = value["url"]
server2 = ""
if "basename" in info:
if "with_submodules" in info and info["with_submodules"]:
if clonePackage(cfg, package, server, server2, branch, commit, True):
endM = False
else:
if clonePackage(cfg, package, server, server2, branch, commit):
endM = False
else:
if "server" in info or "archive" in info:
if "with_submodules" in info and info["with_submodules"]:
if clonePackage(cfg, info["package"], server, server2, branch, commit, True):
endM = False
else:
if clonePackage(cfg, info["package"], server, server2, branch, commit):
endM = False
layout_packages.append(package)
if len(cfg["errors"]) > le:
if endM:
c.printError("error")
return False
if endM:
c.printWarning("done")
return True
cfg["errors"].append("fetch: "+package)
c.printError("error")
return False
def fetchPackages(cfg, layout_packages):
setupCfg(cfg)
updated = []
with open(cfg["devDir"]+"/autoproj/manifest") as f:
manifest = yaml.safe_load(f)
for layout in manifest["layout"]:
fetchPackage(cfg, layout, layout_packages)
# todo: add error handling
def clonePackageSet(cfg, git, realPath, path, cloned, deps, branch=None):
# clone in tmp folder
c.printNormal(" Fetching: "+git)
cmd = ["git", "clone", "-o", "autobuild", git, realPath]
if branch != None:
cmd.append("-b")
cmd.append(branch)
out, err, r = execute.do(cmd)
if not os.path.isdir(realPath+"/.git"):
c.printNormal(execute.decode(out));
c.printError(execute.decode(err));
cfg["errors"].append("clone: "+git)
return
# get the name of the remote
with open(realPath+"/source.yml") as f:
info = yaml.safe_load(f)
#os.system("rm -rf "+path+"remotes/"+info["name"])
os.system("ln -s "+ realPath + " " + path+"remotes/"+info["name"]);
if "imports" in info and info["imports"]:
for i in info["imports"]:
key, value = list(i.items())[0]
realPath = cfg["devDir"]+"/.autoproj/remotes/"+key+"__"+ value.strip().replace("/", "_").replace("-", "_") + "_git"
if i not in deps and not os.path.isdir(realPath):
deps.append(i)
# store the info which package sets we have cloned already
cloned.append(info["name"])
def updatePackageSets(cfg):
# the server configuration are handled in the init.rb for autoproj
setupCfg(cfg)
path = cfg["devDir"]+"/autoproj/";
execute.makeDir(path+"remotes")
execute.makeDir(cfg["devDir"]+"/.autoproj/remotes")
cloned = []
deps = []
with open(path+"manifest") as f:
manifest = yaml.safe_load(f)
for packageSet in manifest["package_sets"]:
if isinstance(packageSet, dict):
key, value = list(packageSet.items())[0]
branch = None
if isinstance(value, dict):
if value["type"] != "git":
continue
url = value["url"]
key = "url"
value = url
if "branch" in value:
branch = value["branch"]
if "branch" in packageSet:
branch = packageSet["branch"]
realPath = cfg["devDir"]+"/.autoproj/remotes/"+key+"__"+ value.strip().replace("/", "_").replace("-", "_") + "_git"
if not os.path.isdir(realPath):
if key == "url":
clonePackageSet(cfg, value.strip(), realPath, path, cloned, deps, branch)
else:
clonePackageSet(cfg, cfg["server"][key]+value.strip()+".git", realPath, path, cloned, deps, branch)
# update remotes that are not actually cloned
for d in os.listdir(path+"remotes"):
if os.path.isdir(path+"remotes/"+d):
if d not in cloned:
if cfg["update"]:
c.printNormal(" Updating: "+d)
out, err, r = execute.do(["git", "-C", path+"remotes/"+d, "pull"])
if r != 0:
cfg["errors"].append("update: "+d)
c.printError("\ncan't update package set \""+d+"\":\n"+execute.decode(err))
if d not in cloned:
with open(path+"remotes/"+d+"/source.yml") as f:
info = yaml.safe_load(f)
if "imports" in info and info["imports"]:
for i in info["imports"]:
key, value = list(i.items())[0]
realPath = cfg["devDir"] + "/.autoproj/remotes/" + key + "__" + value.strip().replace("/", "_").replace("-", "_") + "_git"
# todo: handle the update differently, maybe in clone
if i not in deps and not os.path.isdir(realPath):
deps.append(i)
# handle local_package sets if avialable
for packageSet in manifest["package_sets"]:
if not isinstance(packageSet, dict):
p = os.path.join(path, packageSet, "source.yml")
if os.path.exists(p):
with open(p) as f:
info = yaml.safe_load(f)
if "imports" in info and info["imports"]:
for i in info["imports"]:
key, value = list(i.items())[0]
realPath = cfg["devDir"] + "/.autoproj/remotes/" + key + "__" + value.strip().replace("/", "_").replace("-", "_") + "_git"
# todo: handle the update differently, maybe in clone
if i not in deps and not os.path.isdir(realPath):
deps.append(i)
# now handle deps
while len(deps) > 0:
packageSet = deps.pop(0)
key, value = list(packageSet.items())[0]
realPath = cfg["devDir"]+"/.autoproj/remotes/"+key+"__"+ value.strip().replace("/", "_").replace("-", "_") + "_git"
clonePackageSet(cfg, cfg["server"][key]+value.strip()+".git", realPath, path, cloned, deps)
# last step: write all packages int a file to speed up pybob usage
packages, wildcards = listPackages(cfg)
pDict = {}
with open(path + "/bob/packages.txt", "wb") as f:
for p in packages:
if len(p[1]) > 0:
if sys.version_info.major <= 2:
f.write(p[1] + "\n")
else:
f.write(bytes(p[1] + "\n", "utf-8"))
if len(p) == 3:
pDict[p[1]] = [p[0], p[2]]
else:
pDict[p[1]] = [p[0]]
else:
if sys.version_info.major <= 2:
f.write(p[0] + "\n")
else:
f.write(bytes(p[0] + "\n", "utf-8"))
pDict[p[0]] = [p[0]]
for p in wildcards:
if len(p[1]) > 0:
pDict[p[1]] = [p[0]]
else:
pDict[p[0]] = [p[0]]
with open(path+"/bob/packages.yml", "w") as f:
yaml.dump(pDict, f)
def fetchBuildconf(cfg):
if os.path.isdir(cfg["devDir"]+"/autoproj"):
if cfg["update"]:
c.printNormal(" Update buildconf.")
out, err, r = execute.do(["git", "-C", cfg["devDir"]+"/autoproj", "pull"])
if r != 0:
cfg["errors"].append("update: buildconf")
c.printError("\ncan't update buildconf:\n" + execute.decode(err))
else:
address = cfg["buildconfAddress"]
if len(address) == 0:
c.printError("no address given")
return
branch = cfg["buildconfBranch"]
c.printNormal(" Fetching \""+address+branch+"\" into "+cfg["devDir"]+"/autoproj")
command = ["git", "clone", "-o", "autobuild", address, cfg["devDir"]+"/autoproj"]
if len(branch) > 0:
command.append("-b")
command.append(branch)
execute.do(command)