diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-05-20 22:21:18 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-21 22:24:57 +0100 |
commit | 02986886fc40c0fcd33359a279ba9520fd5cac2a (patch) | |
tree | d4a6fa26db845620bf438096d4c1685ebd584e06 /scripts | |
parent | 0111181bbb942ab63389fcf29028e93598a23f08 (diff) | |
download | poky-02986886fc40c0fcd33359a279ba9520fd5cac2a.tar.gz |
devtool: sdk-update: drop support for local updates
Having two code paths here makes maintenance difficult, and it doesn't
seem likely that you would use the local case in real usage anyway, so
drop the local support entirely.
This should allow us to resolve [YOCTO #9301].
(From OE-Core rev: 7a4c9c96fee4fb514c2b69b52e811c4f896a16f1)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/devtool/sdk.py | 188 |
1 files changed, 76 insertions, 112 deletions
diff --git a/scripts/lib/devtool/sdk.py b/scripts/lib/devtool/sdk.py index 46fd12bdb2..922277b79f 100644 --- a/scripts/lib/devtool/sdk.py +++ b/scripts/lib/devtool/sdk.py | |||
@@ -107,7 +107,7 @@ def check_manifest(fn, basepath): | |||
107 | return changedfiles | 107 | return changedfiles |
108 | 108 | ||
109 | def sdk_update(args, config, basepath, workspace): | 109 | def sdk_update(args, config, basepath, workspace): |
110 | # Fetch locked-sigs.inc file from remote/local destination | 110 | """Entry point for devtool sdk-update command""" |
111 | updateserver = args.updateserver | 111 | updateserver = args.updateserver |
112 | if not updateserver: | 112 | if not updateserver: |
113 | updateserver = config.get('SDK', 'updateserver', '') | 113 | updateserver = config.get('SDK', 'updateserver', '') |
@@ -122,10 +122,9 @@ def sdk_update(args, config, basepath, workspace): | |||
122 | else: | 122 | else: |
123 | logger.debug("Found conf/locked-sigs.inc in %s" % basepath) | 123 | logger.debug("Found conf/locked-sigs.inc in %s" % basepath) |
124 | 124 | ||
125 | if ':' in updateserver: | 125 | if not '://' in updateserver: |
126 | is_remote = True | 126 | logger.error("Update server must be a URL") |
127 | else: | 127 | return -1 |
128 | is_remote = False | ||
129 | 128 | ||
130 | layers_dir = os.path.join(basepath, 'layers') | 129 | layers_dir = os.path.join(basepath, 'layers') |
131 | conf_dir = os.path.join(basepath, 'conf') | 130 | conf_dir = os.path.join(basepath, 'conf') |
@@ -139,120 +138,85 @@ def sdk_update(args, config, basepath, workspace): | |||
139 | finally: | 138 | finally: |
140 | tinfoil.shutdown() | 139 | tinfoil.shutdown() |
141 | 140 | ||
142 | if not is_remote: | 141 | tmpsdk_dir = tempfile.mkdtemp() |
143 | # devtool sdk-update /local/path/to/latest/sdk | 142 | try: |
144 | new_locked_sig_file_path = os.path.join(updateserver, 'conf/locked-sigs.inc') | 143 | os.makedirs(os.path.join(tmpsdk_dir, 'conf')) |
145 | if not os.path.exists(new_locked_sig_file_path): | 144 | new_locked_sig_file_path = os.path.join(tmpsdk_dir, 'conf', 'locked-sigs.inc') |
146 | logger.error("%s doesn't exist or is not an extensible SDK" % updateserver) | 145 | # Fetch manifest from server |
147 | return -1 | 146 | tmpmanifest = os.path.join(tmpsdk_dir, 'conf', 'sdk-conf-manifest') |
148 | else: | 147 | ret = subprocess.call("wget -q -O %s %s/conf/sdk-conf-manifest" % (tmpmanifest, updateserver), shell=True) |
149 | logger.debug("Found conf/locked-sigs.inc in %s" % updateserver) | 148 | changedfiles = check_manifest(tmpmanifest, basepath) |
150 | update_dict = generate_update_dict(new_locked_sig_file_path, old_locked_sig_file_path) | 149 | if not changedfiles: |
151 | logger.debug("update_dict = %s" % update_dict) | 150 | logger.info("Already up-to-date") |
152 | newsdk_path = updateserver | ||
153 | sstate_dir = os.path.join(newsdk_path, 'sstate-cache') | ||
154 | if not os.path.exists(sstate_dir): | ||
155 | logger.error("sstate-cache directory not found under %s" % newsdk_path) | ||
156 | return 1 | ||
157 | sstate_objects = get_sstate_objects(update_dict, sstate_dir) | ||
158 | logger.debug("sstate_objects = %s" % sstate_objects) | ||
159 | if len(sstate_objects) == 0: | ||
160 | logger.info("No need to update.") | ||
161 | return 0 | 151 | return 0 |
162 | logger.info("Installing sstate objects into %s", basepath) | 152 | # Update metadata |
163 | install_sstate_objects(sstate_objects, updateserver.rstrip('/'), basepath) | 153 | logger.debug("Updating metadata via git ...") |
164 | logger.info("Updating configuration files") | 154 | #Check for the status before doing a fetch and reset |
165 | new_conf_dir = os.path.join(updateserver, 'conf') | 155 | if os.path.exists(os.path.join(basepath, 'layers/.git')): |
166 | shutil.rmtree(conf_dir) | 156 | out = subprocess.check_output("git status --porcelain", shell=True, cwd=layers_dir) |
167 | shutil.copytree(new_conf_dir, conf_dir) | 157 | if not out: |
168 | logger.info("Updating layers") | 158 | ret = subprocess.call("git fetch --all; git reset --hard", shell=True, cwd=layers_dir) |
169 | new_layers_dir = os.path.join(updateserver, 'layers') | ||
170 | shutil.rmtree(layers_dir) | ||
171 | ret = subprocess.call("cp -a %s %s" % (new_layers_dir, layers_dir), shell=True) | ||
172 | if ret != 0: | ||
173 | logger.error("Copying %s to %s failed" % (new_layers_dir, layers_dir)) | ||
174 | return ret | ||
175 | else: | ||
176 | # devtool sdk-update http://myhost/sdk | ||
177 | tmpsdk_dir = tempfile.mkdtemp() | ||
178 | try: | ||
179 | os.makedirs(os.path.join(tmpsdk_dir, 'conf')) | ||
180 | new_locked_sig_file_path = os.path.join(tmpsdk_dir, 'conf', 'locked-sigs.inc') | ||
181 | # Fetch manifest from server | ||
182 | tmpmanifest = os.path.join(tmpsdk_dir, 'conf', 'sdk-conf-manifest') | ||
183 | ret = subprocess.call("wget -q -O %s %s/conf/sdk-conf-manifest" % (tmpmanifest, updateserver), shell=True) | ||
184 | changedfiles = check_manifest(tmpmanifest, basepath) | ||
185 | if not changedfiles: | ||
186 | logger.info("Already up-to-date") | ||
187 | return 0 | ||
188 | # Update metadata | ||
189 | logger.debug("Updating metadata via git ...") | ||
190 | #Check for the status before doing a fetch and reset | ||
191 | if os.path.exists(os.path.join(basepath, 'layers/.git')): | ||
192 | out = subprocess.check_output("git status --porcelain", shell=True, cwd=layers_dir) | ||
193 | if not out: | ||
194 | ret = subprocess.call("git fetch --all; git reset --hard", shell=True, cwd=layers_dir) | ||
195 | else: | ||
196 | logger.error("Failed to update metadata as there have been changes made to it. Aborting."); | ||
197 | logger.error("Changed files:\n%s" % out); | ||
198 | return -1 | ||
199 | else: | 159 | else: |
200 | ret = -1 | 160 | logger.error("Failed to update metadata as there have been changes made to it. Aborting."); |
161 | logger.error("Changed files:\n%s" % out); | ||
162 | return -1 | ||
163 | else: | ||
164 | ret = -1 | ||
165 | if ret != 0: | ||
166 | ret = subprocess.call("git clone %s/layers/.git" % updateserver, shell=True, cwd=tmpsdk_dir) | ||
167 | if ret != 0: | ||
168 | logger.error("Updating metadata via git failed") | ||
169 | return ret | ||
170 | logger.debug("Updating conf files ...") | ||
171 | for changedfile in changedfiles: | ||
172 | ret = subprocess.call("wget -q -O %s %s/%s" % (changedfile, updateserver, changedfile), shell=True, cwd=tmpsdk_dir) | ||
201 | if ret != 0: | 173 | if ret != 0: |
202 | ret = subprocess.call("git clone %s/layers/.git" % updateserver, shell=True, cwd=tmpsdk_dir) | 174 | logger.error("Updating %s failed" % changedfile) |
203 | if ret != 0: | 175 | return ret |
204 | logger.error("Updating metadata via git failed") | ||
205 | return ret | ||
206 | logger.debug("Updating conf files ...") | ||
207 | for changedfile in changedfiles: | ||
208 | ret = subprocess.call("wget -q -O %s %s/%s" % (changedfile, updateserver, changedfile), shell=True, cwd=tmpsdk_dir) | ||
209 | if ret != 0: | ||
210 | logger.error("Updating %s failed" % changedfile) | ||
211 | return ret | ||
212 | 176 | ||
213 | # Check if UNINATIVE_CHECKSUM changed | 177 | # Check if UNINATIVE_CHECKSUM changed |
214 | uninative = False | 178 | uninative = False |
215 | if 'conf/local.conf' in changedfiles: | 179 | if 'conf/local.conf' in changedfiles: |
216 | def read_uninative_checksums(fn): | 180 | def read_uninative_checksums(fn): |
217 | chksumitems = [] | 181 | chksumitems = [] |
218 | with open(fn, 'r') as f: | 182 | with open(fn, 'r') as f: |
219 | for line in f: | 183 | for line in f: |
220 | if line.startswith('UNINATIVE_CHECKSUM'): | 184 | if line.startswith('UNINATIVE_CHECKSUM'): |
221 | splitline = re.split(r'[\[\]"\']', line) | 185 | splitline = re.split(r'[\[\]"\']', line) |
222 | if len(splitline) > 3: | 186 | if len(splitline) > 3: |
223 | chksumitems.append((splitline[1], splitline[3])) | 187 | chksumitems.append((splitline[1], splitline[3])) |
224 | return chksumitems | 188 | return chksumitems |
225 | 189 | ||
226 | oldsums = read_uninative_checksums(os.path.join(basepath, 'conf/local.conf')) | 190 | oldsums = read_uninative_checksums(os.path.join(basepath, 'conf/local.conf')) |
227 | newsums = read_uninative_checksums(os.path.join(tmpsdk_dir, 'conf/local.conf')) | 191 | newsums = read_uninative_checksums(os.path.join(tmpsdk_dir, 'conf/local.conf')) |
228 | if oldsums != newsums: | 192 | if oldsums != newsums: |
229 | uninative = True | 193 | uninative = True |
230 | for buildarch, chksum in newsums: | 194 | for buildarch, chksum in newsums: |
231 | uninative_file = os.path.join('downloads', 'uninative', chksum, '%s-nativesdk-libc.tar.bz2' % buildarch) | 195 | uninative_file = os.path.join('downloads', 'uninative', chksum, '%s-nativesdk-libc.tar.bz2' % buildarch) |
232 | mkdir(os.path.join(tmpsdk_dir, os.path.dirname(uninative_file))) | 196 | mkdir(os.path.join(tmpsdk_dir, os.path.dirname(uninative_file))) |
233 | ret = subprocess.call("wget -q -O %s %s/%s" % (uninative_file, updateserver, uninative_file), shell=True, cwd=tmpsdk_dir) | 197 | ret = subprocess.call("wget -q -O %s %s/%s" % (uninative_file, updateserver, uninative_file), shell=True, cwd=tmpsdk_dir) |
234 | 198 | ||
235 | # Ok, all is well at this point - move everything over | 199 | # Ok, all is well at this point - move everything over |
236 | tmplayers_dir = os.path.join(tmpsdk_dir, 'layers') | 200 | tmplayers_dir = os.path.join(tmpsdk_dir, 'layers') |
237 | if os.path.exists(tmplayers_dir): | 201 | if os.path.exists(tmplayers_dir): |
238 | shutil.rmtree(layers_dir) | 202 | shutil.rmtree(layers_dir) |
239 | shutil.move(tmplayers_dir, layers_dir) | 203 | shutil.move(tmplayers_dir, layers_dir) |
240 | for changedfile in changedfiles: | 204 | for changedfile in changedfiles: |
241 | destfile = os.path.join(basepath, changedfile) | 205 | destfile = os.path.join(basepath, changedfile) |
242 | os.remove(destfile) | 206 | os.remove(destfile) |
243 | shutil.move(os.path.join(tmpsdk_dir, changedfile), destfile) | 207 | shutil.move(os.path.join(tmpsdk_dir, changedfile), destfile) |
244 | os.remove(os.path.join(conf_dir, 'sdk-conf-manifest')) | 208 | os.remove(os.path.join(conf_dir, 'sdk-conf-manifest')) |
245 | shutil.move(tmpmanifest, conf_dir) | 209 | shutil.move(tmpmanifest, conf_dir) |
246 | if uninative: | 210 | if uninative: |
247 | shutil.rmtree(os.path.join(basepath, 'downloads', 'uninative')) | 211 | shutil.rmtree(os.path.join(basepath, 'downloads', 'uninative')) |
248 | shutil.move(os.path.join(tmpsdk_dir, 'downloads', 'uninative'), os.path.join(basepath, 'downloads')) | 212 | shutil.move(os.path.join(tmpsdk_dir, 'downloads', 'uninative'), os.path.join(basepath, 'downloads')) |
249 | 213 | ||
250 | if not sstate_mirrors: | 214 | if not sstate_mirrors: |
251 | with open(os.path.join(conf_dir, 'site.conf'), 'a') as f: | 215 | with open(os.path.join(conf_dir, 'site.conf'), 'a') as f: |
252 | f.write('SCONF_VERSION = "%s"\n' % site_conf_version) | 216 | f.write('SCONF_VERSION = "%s"\n' % site_conf_version) |
253 | f.write('SSTATE_MIRRORS_append = " file://.* %s/sstate-cache/PATH \\n "\n' % updateserver) | 217 | f.write('SSTATE_MIRRORS_append = " file://.* %s/sstate-cache/PATH \\n "\n' % updateserver) |
254 | finally: | 218 | finally: |
255 | shutil.rmtree(tmpsdk_dir) | 219 | shutil.rmtree(tmpsdk_dir) |
256 | 220 | ||
257 | if not args.skip_prepare: | 221 | if not args.skip_prepare: |
258 | # Find all potentially updateable tasks | 222 | # Find all potentially updateable tasks |