Skip to content

Commit ce7810b

Browse files
committed
split up local and remote dep management, avoided doubles in source.yml
1 parent 6c3eade commit ce7810b

File tree

1 file changed

+69
-38
lines changed

1 file changed

+69
-38
lines changed

bin/esrocos_fetch_dependencies

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -69,75 +69,106 @@ manifest.write("manifest.xml")
6969

7070
print "DONE"
7171

72-
# GENERATE SOURCE ENTRIES FOR UNKNOWN DEPS
73-
print "trying to open existing overrides.yml"
7472

75-
#open overrides.yml
73+
# ADVERTISE LOCAL DEPS IN LOCAL.AUTOBUILD
74+
# ADVERTISE REMOTE DEPS IN UNIVERSE PACKAGE SET
7675

77-
path = os.environ['AUTOPROJ_CURRENT_ROOT']+"/autoproj/overrides.yml"
76+
localpath = os.environ['AUTOPROJ_CURRENT_ROOT']+"/autoproj/"+project_name+".autobuild"
77+
remotepath = os.environ['AUTOPROJ_CURRENT_ROOT']+"/autoproj/remotes/esrocos.universe/"+project_name+".autobuild"
78+
79+
try:
80+
with open(localpath, 'w') as localout, open(remotepath, 'w') as remoteout:
81+
localout.write('import_package "'+project_name+'"\n')
82+
for dep in pkg_deps:
83+
name = ''
84+
remote = False
85+
for key in dep:
86+
if key == 'github':
87+
remote = True
88+
if not dep[key]:
89+
name = key
90+
if remote:
91+
remoteout.write('import_package "'+name+'"\n')
92+
else:
93+
localout.write('import_package "'+name+'"\n')
94+
95+
except IOError as err:
96+
print "could not write to file, exit..."
97+
sys.exit()
98+
99+
print "DONE"
100+
101+
# GENERATE SOURCE ENTRIES FOR REMOTE DEPS
102+
print "trying to open existing source.yml"
103+
104+
#open universe source.yml
105+
106+
path = os.environ['AUTOPROJ_CURRENT_ROOT']+"/autoproj/remotes/esrocos.universe/source.yml"
78107
data = {}
79108

80109
try:
81-
with open(path, 'r') as overrides:
82-
print "parsing yml data"
83-
data = yaml.load(overrides)
110+
with open(path, 'r') as sources:
111+
print "parsing source.yml data"
112+
data = yaml.load(sources)
113+
if not data['version_control']:
114+
data['version_control'] = []
84115
except IOError as err:
85-
print "did not find existing overrides.yml..."
116+
print "did not find existing source.yml..."
86117
data = {'version_control':[]}
87118

88-
# manipulate overrides.yml
119+
# create hash map of existing entries to avoid doubles
120+
121+
existing_deps = {}
122+
for dep in data['version_control']:
123+
for key in dep:
124+
if not dep[key]:
125+
existing_deps[key] = True
126+
127+
# manipulate source.yml data
89128

90129
for dep in pkg_deps:
130+
name = ''
131+
remote = False
132+
91133
for key in dep:
92-
if key == 'github':
93-
data['version_control'].append(dep)
134+
if key == 'github':
135+
remote = True
136+
if not dep[key]:
137+
name = key
138+
139+
if remote and not existing_deps[name]:
140+
data['version_control'].append(dep)
94141

95-
# write back to overrides.yml
142+
# write back to source.yml
96143
try:
97144
with open(path, 'w') as outfile:
98145
yaml.dump(data, outfile, default_flow_style=False, allow_unicode=True)
99146
except IOError as err:
100147
print "could not write to file, aborting..."
101148
sys.exit()
102149

103-
# ADVERTISE LOCAL AND REMOTE DEPS IN LOCAL.AUTOBUILD
104-
path = os.environ['AUTOPROJ_CURRENT_ROOT']+"/autoproj/"+project_name+".autobuild"
105-
106-
try:
107-
with open(path, 'w') as outfile:
108-
outfile.write('import_package "'+project_name+'"\n')
109-
for dep in pkg_deps:
110-
for key in dep:
111-
if not dep[key]:
112-
outfile.write('import_package "'+key+'"\n')
113-
114-
except IOError as err:
115-
print "could not write to file, exit..."
116-
sys.exit()
117-
118-
print "DONE"
119-
120150
# AUP
121151

122152
aup_arguments = ["autoproj","update"]
123153

124154
call(aup_arguments)
125155

126-
sys.exit()
127-
128-
# REMOVE tmp FILES
156+
# REMOVE OLD FILES AND RESET CHANGES
129157

130-
print "DONE"
158+
#print "clean tmp files...",
131159

132-
# remove manifest
160+
#remote_autobuild_path = os.environ['AUTOPROJ_CURRENT_ROOT']+"/autoproj/remotes/esrocos.universe/"+project_name+".autobuild"
161+
#local_autobuild_path = os.environ['AUTOPROJ_CURRENT_ROOT']+"/autoproj/"+project_name+".autobuild"
162+
#manifest_path = "manifest.xml"
133163

134-
os.remove(path)
164+
#os.remove(manifest_path)
165+
#os.remove(local_autobuild_path)
166+
#os.remove(remote_autobuild_path)
135167

136-
# remove overrides.yml
168+
#print "DONE"
137169

138-
os.remove(path)
139170

140-
print "clean tmp files...",
171+
sys.exit()
141172

142173
# COPY ASN
143174

0 commit comments

Comments
 (0)