Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(979)

Side by Side Diff: bin/cros_image_to_target.py

Issue 6576023: scripts: call devserver/payload generators from chroot & delete moved scripts (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Keep bits of old start_devserver Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Create and copy update image to target host. 7 """Create and copy update image to target host.
8 8
9 auto-update and devserver change out from beneath us often enough 9 auto-update and devserver change out from beneath us often enough
10 that despite having to duplicate a litte code, it seems that the 10 that despite having to duplicate a litte code, it seems that the
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return (os.path.exists(dst) and 199 return (os.path.exists(dst) and
200 os.path.getmtime(dst) >= os.path.getmtime(src)) 200 os.path.getmtime(dst) >= os.path.getmtime(src))
201 201
202 def GenerateUpdatePayload(self, src, dst): 202 def GenerateUpdatePayload(self, src, dst):
203 """Generate an update image from a build-image output file.""" 203 """Generate an update image from a build-image output file."""
204 204
205 if self.GetCached(src, dst): 205 if self.GetCached(src, dst):
206 self.Info('Using cached update image %s' % dst) 206 self.Info('Using cached update image %s' % dst)
207 return True 207 return True
208 208
209 if not self.cmd.Run(self.CrosUtilsPath('cros_generate_update_payload'), 209 if not self.cmd.Run(self.ChrootPath('/usr/bin/cros_generate_update_payload') ,
210 '--image=%s' % src, '--output=%s' % dst, 210 '--image=%s' % src, '--output=%s' % dst,
211 '--patch_kernel'): 211 '--patch_kernel'):
212 self.Error('generate_payload failed') 212 self.Error('generate_payload failed')
213 return False 213 return False
214 214
215 return True 215 return True
216 216
217 def BuildStateful(self, src, dst_dir, dst_file): 217 def BuildStateful(self, src, dst_dir, dst_file):
218 """Create a stateful partition update image.""" 218 """Create a stateful partition update image."""
219 219
220 if self.GetCached(src, dst_file): 220 if self.GetCached(src, dst_file):
221 self.Info('Using cached stateful %s' % dst_file) 221 self.Info('Using cached stateful %s' % dst_file)
222 return True 222 return True
223 223
224 return self.cmd.Run(self.CrosUtilsPath( 224 return self.cmd.Run(
225 'cros_generate_stateful_update_payload'), 225 self.ChrootPath('/usr/bin/cros_generate_stateful_update_payload'),
226 '--image=%s' % src, '--output=%s' % dst_dir) 226 '--image=%s' % src, '--output=%s' % dst_dir)
227 227
228 def GetSize(self, filename): 228 def GetSize(self, filename):
229 return os.path.getsize(filename) 229 return os.path.getsize(filename)
230 230
231 def GetHash(self, filename): 231 def GetHash(self, filename):
232 return self.cmd.RunPipe([['openssl', 'sha1', '-binary'], 232 return self.cmd.RunPipe([['openssl', 'sha1', '-binary'],
233 ['openssl', 'base64']], 233 ['openssl', 'base64']],
234 infile=filename, 234 infile=filename,
235 capture=True, oneline=True) 235 capture=True, oneline=True)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 # this will make the client read the files we have set up 336 # this will make the client read the files we have set up
337 self.ssh_cmd.Run('/usr/bin/update_engine_client', '--update', 337 self.ssh_cmd.Run('/usr/bin/update_engine_client', '--update',
338 '--omaha_url', update_url, remote_tunnel=(port, port), 338 '--omaha_url', update_url, remote_tunnel=(port, port),
339 outfile=update_log) 339 outfile=update_log)
340 340
341 if self.GetUpdateStatus() != 'UPDATE_STATUS_UPDATED_NEED_REBOOT': 341 if self.GetUpdateStatus() != 'UPDATE_STATUS_UPDATED_NEED_REBOOT':
342 self.Error('Client update failed') 342 self.Error('Client update failed')
343 return False 343 return False
344 344
345 self.Info('Update complete - running update script on client') 345 self.Info('Update complete - running update script on client')
346 self.ssh_cmd.Copy(self.CrosUtilsPath('../platform/dev/stateful_update'), 346 self.ssh_cmd.Copy(self.ChrootPath('/usr/bin/stateful_update'),
347 '/tmp') 347 '/tmp')
348 if not self.ssh_cmd.Run('/tmp/stateful_update', url_base, 348 if not self.ssh_cmd.Run('/tmp/stateful_update', url_base,
349 remote_tunnel=(port, port)): 349 remote_tunnel=(port, port)):
350 self.Error('Client stateful update failed') 350 self.Error('Client stateful update failed')
351 return False 351 return False
352 352
353 self.Info('Rebooting client') 353 self.Info('Rebooting client')
354 if not self.ClientReboot(): 354 if not self.ClientReboot():
355 self.Error('Client may not have successfully rebooted...') 355 self.Error('Client may not have successfully rebooted...')
356 return False 356 return False
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 715
716 if child: 716 if child:
717 os.kill(child, 15) 717 os.kill(child, 15)
718 718
719 cros_env.Info('Server exiting with status %d' % exit_status) 719 cros_env.Info('Server exiting with status %d' % exit_status)
720 sys.exit(exit_status) 720 sys.exit(exit_status)
721 721
722 722
723 if __name__ == '__main__': 723 if __name__ == '__main__':
724 main(sys.argv) 724 main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698