| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 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 # This script is a wrapper around every part of the build system that corrupts | 7 # This script is a wrapper around every part of the build system that corrupts |
| 8 # the pristine image for various purposes. | 8 # the pristine image for various purposes. |
| 9 | 9 |
| 10 # The purpose of this script is to allow a smooth transition from the old | 10 # The purpose of this script is to allow a smooth transition from the old |
| 11 # build system, where random corruptions of the pipelined approach to image | 11 # build system, where random corruptions of the pipelined approach to image |
| 12 # creation happen in random places, to the new build system, where we keep all | 12 # creation happen in random places, to the new build system, where we keep all |
| 13 # of them in one place. | 13 # of them in one place. |
| 14 | 14 |
| 15 # To avoid code duplication and preservation of the old build system until the | 15 # To avoid code duplication and preservation of the old build system until the |
| 16 # release of chromite, we need to import all the "corrupting" code into here, | 16 # release of chromite, we need to import all the "corrupting" code into here, |
| 17 # but provide "legacy" interfaces to this code so that it can be used in | 17 # but provide "legacy" interfaces to this code so that it can be used in |
| 18 # exactly identical way. This is done in 2 phases: | 18 # exactly identical way. This is done in 2 phases: |
| 19 # 1) Wrapping around various other scripts, providing a way to call them from | 19 # 1) Wrapping around various other scripts, providing a way to call them from |
| 20 # this script. | 20 # this script. |
| 21 # 2) Make this script consume the wrapped scripts and provide legacy symlinks, | 21 # 2) Make this script consume the wrapped scripts and provide legacy symlinks, |
| 22 # that do exactly the same thing as the old scripts. | 22 # that do exactly the same thing as the old scripts. |
| 23 | 23 |
| 24 #------ These are the scripts we're trying to kill --------# | 24 #------ These are the scripts we're trying to kill --------# |
| 25 | 25 |
| 26 # --- BEGIN COMMON.SH BOILERPLATE --- |
| 27 # Load common CrOS utilities. Inside the chroot this file is installed in |
| 28 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 29 # location. |
| 30 find_common_sh() { |
| 31 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
| 32 local path |
| 33 |
| 34 SCRIPT_ROOT= |
| 35 for path in "${common_paths[@]}"; do |
| 36 if [ -r "${path}/common.sh" ]; then |
| 37 SCRIPT_ROOT=${path} |
| 38 break |
| 39 fi |
| 40 done |
| 41 } |
| 42 |
| 43 find_common_sh |
| 44 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 45 # --- END COMMON.SH BOILERPLATE --- |
| 46 |
| 26 function mod_image_for_test() { | 47 function mod_image_for_test() { |
| 27 $(dirname ${0})/mod_image_for_test.sh $* || return $? | 48 "${SCRIPTS_DIR}/mod_image_for_test.sh" "$@" || return $? |
| 28 } | 49 } |
| 29 | 50 |
| 30 function mod_image_for_recovery() { | 51 function mod_image_for_recovery() { |
| 31 $(dirname ${0})/mod_image_for_recovery.sh $* || return $? | 52 "${SCRIPTS_DIR}/mod_image_for_recovery.sh" "$@" || return $? |
| 32 } | 53 } |
| 33 | 54 |
| 34 function mod_image_for_dev_recovery() { | 55 function mod_image_for_dev_recovery() { |
| 35 $(dirname ${0})/mod_image_for_dev_recovery.sh $* || return $? | 56 "${SCRIPTS_DIR}/mod_image_for_dev_recovery.sh" "$@" || return $? |
| 36 } | 57 } |
| 37 | 58 |
| 38 function customize_rootfs() { | 59 function customize_rootfs() { |
| 39 $(dirname ${0})/customize_rootfs $* || return $? | 60 "${SCRIPTS_DIR}/customize_rootfs" "$@" || return $? |
| 40 } | 61 } |
| 41 | 62 |
| 42 #-------------------------- Tools -------------------------# | 63 #-------------------------- Tools -------------------------# |
| 43 | 64 |
| 44 function board_to_arch() { | 65 function board_to_arch() { |
| 45 . "/build/${1}/etc/make.conf.board_setup" || return 1 | 66 . "/build/${1}/etc/make.conf.board_setup" || return 1 |
| 46 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') | 67 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') |
| 47 case "${TC_ARCH}" in | 68 case "${TC_ARCH}" in |
| 48 (arm*) echo "arm";; | 69 (arm*) echo "arm";; |
| 49 (*86) echo "x86";; | 70 (*86) echo "x86";; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 : | 87 : |
| 67 } | 88 } |
| 68 function corrupt_for_factory_test() { | 89 function corrupt_for_factory_test() { |
| 69 : | 90 : |
| 70 } | 91 } |
| 71 function corrupt_for_test() { | 92 function corrupt_for_test() { |
| 72 : | 93 : |
| 73 } | 94 } |
| 74 | 95 |
| 75 function main() { | 96 function main() { |
| 76 . "$(dirname "$0")/common.sh" | |
| 77 get_default_board | 97 get_default_board |
| 78 | 98 |
| 79 # Flag definitions: | 99 # Flag definitions: |
| 80 DEFINE_string corruption_type "" \ | 100 DEFINE_string corruption_type "" \ |
| 81 "The type of corruption to invoke upon the slashfs." | 101 "The type of corruption to invoke upon the slashfs." |
| 82 DEFINE_string board "${DEFAULT_BOARD}" \ | 102 DEFINE_string board "${DEFAULT_BOARD}" \ |
| 83 "The board to build an image for." | 103 "The board to build an image for." |
| 84 DEFINE_string slashfs "" \ | 104 DEFINE_string slashfs "" \ |
| 85 "The path to root file system to corrupt." | 105 "The path to root file system to corrupt." |
| 86 | 106 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 109 (dev_recovery) corrupt_for_dev_recovery ;; | 129 (dev_recovery) corrupt_for_dev_recovery ;; |
| 110 (dev_install) corrupt_for_dev_install ;; | 130 (dev_install) corrupt_for_dev_install ;; |
| 111 (factory_installer_shim) corrupt_for_factory_installer_shim ;; | 131 (factory_installer_shim) corrupt_for_factory_installer_shim ;; |
| 112 (factory_test) corrupt_for_factory_test ;; | 132 (factory_test) corrupt_for_factory_test ;; |
| 113 (test) corrupt_for_test ;; | 133 (test) corrupt_for_test ;; |
| 114 esac | 134 esac |
| 115 return $? | 135 return $? |
| 116 } | 136 } |
| 117 | 137 |
| 118 case "$(basename $0)" in | 138 case "$(basename $0)" in |
| 119 # (mod_image_for_test.sh) mod_image_for_test $* || return $?;; | 139 # (mod_image_for_test.sh) mod_image_for_test "$@" || return $?;; |
| 120 # (mod_image_for_recovery.sh) mod_image_for_recovery $* || return $?;; | 140 # (mod_image_for_recovery.sh) mod_image_for_recovery "$@" || return $?;; |
| 121 # (mod_image_for_dev_recovery.sh) mod_image_for_dev_recovery $* || return $?;; | 141 # (mod_image_for_dev_recovery.sh) mod_image_for_dev_recovery "$@" || return $?;
; |
| 122 # (customize_rootfs) customize_rootfs $* || return $?;; | 142 # (customize_rootfs) customize_rootfs "$@" || return $?;; |
| 123 (image_hacks.sh) main $* || return $?;; # normal invocation | 143 (image_hacks.sh) main "$@" || return $?;; # normal invocation |
| 124 (*) echo "$0: Unknown invocation!"; exit 1 ;; | 144 (*) echo "$0: Unknown invocation!"; exit 1 ;; |
| 125 esac | 145 esac |
| OLD | NEW |