From 99e580e21e1345bfaf23c36ec7621f4d76c8bf9e Mon Sep 17 00:00:00 2001 From: Paul Stewart Date: Fri, 6 May 2011 10:12:42 -0700 Subject: [PATCH] Learn board type for package_to_live and image_to_target In both cases move making contact with the remote board to an earlier step and default the "board" option to whatever is reported by the remote. BUG=n0ne TEST=Run without board flag or .default_board Change-Id: I53330ce5ab05b4cff92ac3a384ae0202fc156953 Reviewed-on: http://gerrit.chromium.org/gerrit/433 Reviewed-by: Sam Leffler Tested-by: Paul Stewart --- bin/cros_image_to_target.py | 36 +++++++++++++++++++----------------- bin/cros_package_to_live | 5 +++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/bin/cros_image_to_target.py b/bin/cros_image_to_target.py index 6f1209b1e4..592a5af8ea 100755 --- a/bin/cros_image_to_target.py +++ b/bin/cros_image_to_target.py @@ -605,6 +605,25 @@ def main(argv): if not options.board: options.board = cros_env.GetDefaultBoard() + if options.remote: + cros_env.Info('Contacting client %s' % options.remote) + cros_env.SetRemote(options.remote) + rel = cros_env.GetRemoteRelease() + if not rel: + cros_env.Fatal('Could not retrieve remote lsb-release') + board = rel.get('CHROMEOS_RELEASE_BOARD', '(None)') + if not options.board: + options.board = board + elif board != options.board and not options.force_mismatch: + cros_env.Error('Board %s does not match expected %s' % + (board, options.board)) + cros_env.Error('(Use --force-mismatch option to override this)') + cros_env.Fatal() + + elif not options.server_only: + parser.error('Either --server-only must be specified or ' + '--remote= needs to be given') + if not options.src: options.src = cros_env.GetLatestImage(options.board) if options.src is None: @@ -654,23 +673,6 @@ def main(argv): cros_env.Debug("Update file %s" % update_file) cros_env.Debug("Stateful file %s" % stateful_file) - if options.remote: - cros_env.Info('Contacting client %s' % options.remote) - cros_env.SetRemote(options.remote) - rel = cros_env.GetRemoteRelease() - if not rel: - cros_env.Fatal('Could not retrieve remote lsb-release') - board = rel.get('CHROMEOS_RELEASE_BOARD', '(None)') - if board != options.board and not options.force_mismatch: - cros_env.Error('Board %s does not match expected %s' % - (board, options.board)) - cros_env.Error('(Use --force-mismatch option to override this)') - cros_env.Fatal() - - elif not options.server_only: - parser.error('Either --server-only must be specified or ' - '--remote= needs to be given') - if (not cros_env.GenerateUpdatePayload(image_file, update_file) or not cros_env.BuildStateful(image_file, image_directory, stateful_file)): cros_env.Fatal() diff --git a/bin/cros_package_to_live b/bin/cros_package_to_live index 2430333c36..8239b80b5a 100755 --- a/bin/cros_package_to_live +++ b/bin/cros_package_to_live @@ -62,6 +62,9 @@ if [ -z "${FLAGS_ARGV}" ]; then exit 1 fi +remote_access_init +learn_board + if [ -z "${FLAGS_board}" ]; then echo "Please specify a board using the --board=MyBoard argument" exit 1 @@ -70,8 +73,6 @@ fi set -e trap cleanup EXIT -remote_access_init - eval set -- "${FLAGS_ARGV}" if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then