diff options
Diffstat (limited to 'binary_search_tool/cros_pkg')
-rwxr-xr-x | binary_search_tool/cros_pkg/create_cleanup_script.py | 174 | ||||
-rwxr-xr-x | binary_search_tool/cros_pkg/get_initial_items.sh | 3 | ||||
-rwxr-xr-x | binary_search_tool/cros_pkg/setup.sh | 2 | ||||
-rwxr-xr-x | binary_search_tool/cros_pkg/switch_to_bad.sh | 2 | ||||
-rwxr-xr-x | binary_search_tool/cros_pkg/switch_to_good.sh | 2 | ||||
-rwxr-xr-x | binary_search_tool/cros_pkg/test_setup_usb.sh | 2 |
6 files changed, 97 insertions, 88 deletions
diff --git a/binary_search_tool/cros_pkg/create_cleanup_script.py b/binary_search_tool/cros_pkg/create_cleanup_script.py index 62ee38f1..abfea5eb 100755 --- a/binary_search_tool/cros_pkg/create_cleanup_script.py +++ b/binary_search_tool/cros_pkg/create_cleanup_script.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Copyright 2020 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -13,20 +13,19 @@ undo the changes made by setup.sh, returning everything to its original state. """ -from __future__ import print_function import argparse import sys def Usage(parser, msg): - print('ERROR: ' + msg) - parser.print_help() - sys.exit(1) + print("ERROR: " + msg) + parser.print_help() + sys.exit(1) def Main(argv): - """Generate a script to undo changes done by setup.sh + """Generate a script to undo changes done by setup.sh The script setup.sh makes a change that needs to be undone, namely it creates a soft link making /build/${board} point @@ -40,80 +39,91 @@ def Main(argv): This function takes arguments that tell it exactly what setup.sh actually did, then generates a script to undo those exact changes. - """ - - parser = argparse.ArgumentParser() - parser.add_argument( - '--board', - dest='board', - required=True, - help='Chromeos board for packages/image.') - - parser.add_argument( - '--old_tree_missing', - dest='tree_existed', - action='store_false', - help='Did /build/${BOARD} exist.', - default=True) - - parser.add_argument( - '--renamed_tree', - dest='renamed_tree', - action='store_true', - help='Was /build/${BOARD} saved & renamed.', - default=False) - - parser.add_argument( - '--old_link', - dest='old_link', - help=('The original build tree soft link.')) - - options = parser.parse_args(argv[1:]) - - if options.old_link or options.renamed_tree: - if not options.tree_existed: - Usage( - parser, 'If --tree_existed is False, cannot have ' - '--renamed_tree or --old_link') - - if options.old_link and options.renamed_tree: - Usage(parser, '--old_link and --renamed_tree are incompatible options.') - - if options.tree_existed: - if not options.old_link and not options.renamed_tree: - Usage( - parser, 'If --tree_existed is True, then must have either ' - '--old_link or --renamed_tree') - - out_filename = 'cros_pkg/' + options.board + '_cleanup.sh' - - with open(out_filename, 'w', encoding='utf-8') as out_file: - out_file.write('#!/bin/bash\n\n') - # First, remove the 'new' soft link. - out_file.write('sudo rm /build/%s\n' % options.board) + """ + + parser = argparse.ArgumentParser() + parser.add_argument( + "--board", + dest="board", + required=True, + help="Chromeos board for packages/image.", + ) + + parser.add_argument( + "--old_tree_missing", + dest="tree_existed", + action="store_false", + help="Did /build/${BOARD} exist.", + default=True, + ) + + parser.add_argument( + "--renamed_tree", + dest="renamed_tree", + action="store_true", + help="Was /build/${BOARD} saved & renamed.", + default=False, + ) + + parser.add_argument( + "--old_link", + dest="old_link", + help=("The original build tree soft link."), + ) + + options = parser.parse_args(argv[1:]) + + if options.old_link or options.renamed_tree: + if not options.tree_existed: + Usage( + parser, + "If --tree_existed is False, cannot have " + "--renamed_tree or --old_link", + ) + + if options.old_link and options.renamed_tree: + Usage(parser, "--old_link and --renamed_tree are incompatible options.") + if options.tree_existed: - if options.renamed_tree: - # Old build tree existed and was a real tree, so it got - # renamed. Move the renamed tree back to the original tree. - out_file.write('sudo mv /build/%s.save /build/%s\n' % (options.board, - options.board)) - else: - # Old tree existed and was already a soft link. Re-create the - # original soft link. - original_link = options.old_link - if original_link[0] == "'": - original_link = original_link[1:] - if original_link[-1] == "'": - original_link = original_link[:-1] - out_file.write( - 'sudo ln -s %s /build/%s\n' % (original_link, options.board)) - out_file.write('\n') - # Remove common.sh file - out_file.write('rm common/common.sh\n') - - return 0 - - -if __name__ == '__main__': - retval = Main(sys.argv) - sys.exit(retval) + if not options.old_link and not options.renamed_tree: + Usage( + parser, + "If --tree_existed is True, then must have either " + "--old_link or --renamed_tree", + ) + + out_filename = "cros_pkg/" + options.board + "_cleanup.sh" + + with open(out_filename, "w", encoding="utf-8") as out_file: + out_file.write("#!/bin/bash\n\n") + # First, remove the 'new' soft link. + out_file.write("sudo rm /build/%s\n" % options.board) + if options.tree_existed: + if options.renamed_tree: + # Old build tree existed and was a real tree, so it got + # renamed. Move the renamed tree back to the original tree. + out_file.write( + "sudo mv /build/%s.save /build/%s\n" + % (options.board, options.board) + ) + else: + # Old tree existed and was already a soft link. Re-create the + # original soft link. + original_link = options.old_link + if original_link[0] == "'": + original_link = original_link[1:] + if original_link[-1] == "'": + original_link = original_link[:-1] + out_file.write( + "sudo ln -s %s /build/%s\n" % (original_link, options.board) + ) + out_file.write("\n") + # Remove common.sh file + out_file.write("rm common/common.sh\n") + + return 0 + + +if __name__ == "__main__": + retval = Main(sys.argv) + sys.exit(retval) diff --git a/binary_search_tool/cros_pkg/get_initial_items.sh b/binary_search_tool/cros_pkg/get_initial_items.sh index 49ca3d18..bc0fd2e6 100755 --- a/binary_search_tool/cros_pkg/get_initial_items.sh +++ b/binary_search_tool/cros_pkg/get_initial_items.sh @@ -1,6 +1,6 @@ #!/bin/bash -u # -# Copyright 2015 Google Inc. All Rights Reserved. +# Copyright 2015 Google LLC # # This script is intended to be used by binary_search_state.py, as # part of the binary search triage on ChromeOS packages. This script @@ -13,4 +13,3 @@ source common/common.sh cd ${GOOD_BUILD}/packages find . -name "*.tbz2" - diff --git a/binary_search_tool/cros_pkg/setup.sh b/binary_search_tool/cros_pkg/setup.sh index ae31fa82..30a3a423 100755 --- a/binary_search_tool/cros_pkg/setup.sh +++ b/binary_search_tool/cros_pkg/setup.sh @@ -1,6 +1,6 @@ #!/bin/bash -u # -# Copyright 2015 Google Inc. All Rights Reserved. +# Copyright 2015 Google LLC # # This script is part of the ChromeOS package binary search triage process. # It should be the first script called by the user, after the user has set up diff --git a/binary_search_tool/cros_pkg/switch_to_bad.sh b/binary_search_tool/cros_pkg/switch_to_bad.sh index 126425f4..b4156a0e 100755 --- a/binary_search_tool/cros_pkg/switch_to_bad.sh +++ b/binary_search_tool/cros_pkg/switch_to_bad.sh @@ -1,6 +1,6 @@ #!/bin/bash -u # -# Copyright 2015 Google Inc. All Rights Reserved. +# Copyright 2015 Google LLC # # This script is intended to be used by binary_search_state.py, as # part of the binary search triage on ChromeOS packages. This script diff --git a/binary_search_tool/cros_pkg/switch_to_good.sh b/binary_search_tool/cros_pkg/switch_to_good.sh index a9095e99..5f7c2d77 100755 --- a/binary_search_tool/cros_pkg/switch_to_good.sh +++ b/binary_search_tool/cros_pkg/switch_to_good.sh @@ -1,6 +1,6 @@ #!/bin/bash -u # -# Copyright 2015 Google Inc. All Rights Reserved. +# Copyright 2015 Google LLC # # This script is intended to be used by binary_search_state.py, as # part of the binary search triage on ChromeOS packages. This script diff --git a/binary_search_tool/cros_pkg/test_setup_usb.sh b/binary_search_tool/cros_pkg/test_setup_usb.sh index fec66f8e..54d0baa1 100755 --- a/binary_search_tool/cros_pkg/test_setup_usb.sh +++ b/binary_search_tool/cros_pkg/test_setup_usb.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2016 Google Inc. All Rights Reserved. +# Copyright 2016 Google LLC # # This is a generic ChromeOS package/image test setup script. It is meant to # be used for the package bisection tool, in particular when there is a booting |