OLD | NEW |
---|---|
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 Loading... | |
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('cros_generate_update_payload', |
Paul Stewart
2011/02/24 18:49:39
These changes force the user to run from within th
| |
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('cros_generate_stateful_update_payload', |
225 'cros_generate_stateful_update_payload'), | |
226 '--image=%s' % src, '--output=%s' % dst_dir) | 225 '--image=%s' % src, '--output=%s' % dst_dir) |
227 | 226 |
228 def GetSize(self, filename): | 227 def GetSize(self, filename): |
229 return os.path.getsize(filename) | 228 return os.path.getsize(filename) |
230 | 229 |
231 def GetHash(self, filename): | 230 def GetHash(self, filename): |
232 return self.cmd.RunPipe([['openssl', 'sha1', '-binary'], | 231 return self.cmd.RunPipe([['openssl', 'sha1', '-binary'], |
233 ['openssl', 'base64']], | 232 ['openssl', 'base64']], |
234 infile=filename, | 233 infile=filename, |
235 capture=True, oneline=True) | 234 capture=True, oneline=True) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 # this will make the client read the files we have set up | 335 # this will make the client read the files we have set up |
337 self.ssh_cmd.Run('/usr/bin/update_engine_client', '--update', | 336 self.ssh_cmd.Run('/usr/bin/update_engine_client', '--update', |
338 '--omaha_url', update_url, remote_tunnel=(port, port), | 337 '--omaha_url', update_url, remote_tunnel=(port, port), |
339 outfile=update_log) | 338 outfile=update_log) |
340 | 339 |
341 if self.GetUpdateStatus() != 'UPDATE_STATUS_UPDATED_NEED_REBOOT': | 340 if self.GetUpdateStatus() != 'UPDATE_STATUS_UPDATED_NEED_REBOOT': |
342 self.Error('Client update failed') | 341 self.Error('Client update failed') |
343 return False | 342 return False |
344 | 343 |
345 self.Info('Update complete - running update script on client') | 344 self.Info('Update complete - running update script on client') |
346 self.ssh_cmd.Copy(self.CrosUtilsPath('../platform/dev/stateful_update'), | 345 self.ssh_cmd.Copy('/usr/bin/stateful_update', |
347 '/tmp') | 346 '/tmp') |
348 if not self.ssh_cmd.Run('/tmp/stateful_update', url_base, | 347 if not self.ssh_cmd.Run('/tmp/stateful_update', url_base, |
349 remote_tunnel=(port, port)): | 348 remote_tunnel=(port, port)): |
350 self.Error('Client stateful update failed') | 349 self.Error('Client stateful update failed') |
351 return False | 350 return False |
352 | 351 |
353 self.Info('Rebooting client') | 352 self.Info('Rebooting client') |
354 if not self.ClientReboot(): | 353 if not self.ClientReboot(): |
355 self.Error('Client may not have successfully rebooted...') | 354 self.Error('Client may not have successfully rebooted...') |
356 return False | 355 return False |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 | 713 |
715 if child: | 714 if child: |
716 os.kill(child, 15) | 715 os.kill(child, 15) |
717 | 716 |
718 cros_env.Info('Server exiting with status %d' % exit_status) | 717 cros_env.Info('Server exiting with status %d' % exit_status) |
719 sys.exit(exit_status) | 718 sys.exit(exit_status) |
720 | 719 |
721 | 720 |
722 if __name__ == '__main__': | 721 if __name__ == '__main__': |
723 main(sys.argv) | 722 main(sys.argv) |
OLD | NEW |