OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 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 |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # This script is a wrapper around every part of the build system that corrupts |
| 8 # the pristine image for various purposes. |
| 9 |
| 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 |
| 12 # creation happen in random places, to the new build system, where we keep all |
| 13 # of them in one place. |
| 14 |
| 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, |
| 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: |
| 19 # 1) Wrapping around various other scripts, providing a way to call them from |
| 20 # this script. |
| 21 # 2) Make this script consume the wrapped scripts and provide legacy symlinks, |
| 22 # that do exactly the same thing as the old scripts. |
| 23 |
| 24 #------ These are the scripts we're trying to kill --------# |
| 25 |
| 26 function mod_image_for_test() { |
| 27 $(dirname ${0})/mod_image_for_test.sh $* || return $? |
| 28 } |
| 29 |
| 30 function mod_image_for_recovery() { |
| 31 $(dirname ${0})/mod_image_for_recovery.sh $* || return $? |
| 32 } |
| 33 |
| 34 function mod_image_for_dev_recovery() { |
| 35 $(dirname ${0})/mod_image_for_dev_recovery.sh $* || return $? |
| 36 } |
| 37 |
| 38 function customize_rootfs() { |
| 39 $(dirname ${0})/customize_rootfs $* || return $? |
| 40 } |
| 41 |
| 42 #-------------------------- Tools -------------------------# |
| 43 |
| 44 function board_to_arch() { |
| 45 . "/build/${1}/etc/make.conf.board_setup" || return 1 |
| 46 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') |
| 47 case "${TC_ARCH}" in |
| 48 (arm*) echo "arm";; |
| 49 (*86) echo "x86";; |
| 50 (*) error "Unable to determine ARCH from toolchain: ${CHOST}"; return 1;; |
| 51 esac |
| 52 } |
| 53 |
| 54 #--------------------------- Main -------------------------# |
| 55 |
| 56 function corrupt_for_recovery() { |
| 57 : |
| 58 } |
| 59 function corrupt_for_dev_recovery() { |
| 60 : |
| 61 } |
| 62 function corrupt_for_dev_install() { |
| 63 : |
| 64 } |
| 65 function corrupt_for_factory_installer_shim() { |
| 66 : |
| 67 } |
| 68 function corrupt_for_factory_test() { |
| 69 : |
| 70 } |
| 71 function corrupt_for_test() { |
| 72 : |
| 73 } |
| 74 |
| 75 function main() { |
| 76 . "$(dirname "$0")/common.sh" |
| 77 get_default_board |
| 78 |
| 79 # Flag definitions: |
| 80 DEFINE_string corruption_type "" \ |
| 81 "The type of corruption to invoke upon the slashfs." |
| 82 DEFINE_string board "${DEFAULT_BOARD}" \ |
| 83 "The board to build an image for." |
| 84 DEFINE_string slashfs "" \ |
| 85 "The path to root file system to corrupt." |
| 86 |
| 87 # Parse command line. |
| 88 FLAGS "$@" || return 1 |
| 89 |
| 90 # Sanity checking. |
| 91 if [ -z "${FLAGS_corruption_type}" ]; then |
| 92 echo "Please specify corruption type"; return 1 |
| 93 fi |
| 94 if [ -z "${FLAGS_board}" ]; then |
| 95 echo "You must specify board"; return 1 |
| 96 fi |
| 97 |
| 98 # Customize_rootfs needs arch, we need to get it somehow. |
| 99 ARCH="$(board_to_arch ${FLAGS_board})" || return 1 |
| 100 |
| 101 ################################################### |
| 102 # Parametric corruption of the slashfs starts here. |
| 103 ################################################### |
| 104 #customize_rootfs --board="${FLAGS_board}" --target="${ARCH}" \ |
| 105 # --root="${FLAGS_slashroot}" |
| 106 |
| 107 case ${FLAGS_corruption_type} in |
| 108 (recovery) corrupt_for_recovery ;; |
| 109 (dev_recovery) corrupt_for_dev_recovery ;; |
| 110 (dev_install) corrupt_for_dev_install ;; |
| 111 (factory_installer_shim) corrupt_for_factory_installer_shim ;; |
| 112 (factory_test) corrupt_for_factory_test ;; |
| 113 (test) corrupt_for_test ;; |
| 114 esac |
| 115 return $? |
| 116 } |
| 117 |
| 118 case "$(basename $0)" in |
| 119 # (mod_image_for_test.sh) mod_image_for_test $* || return $?;; |
| 120 # (mod_image_for_recovery.sh) mod_image_for_recovery $* || return $?;; |
| 121 # (mod_image_for_dev_recovery.sh) mod_image_for_dev_recovery $* || return $?;; |
| 122 # (customize_rootfs) customize_rootfs $* || return $?;; |
| 123 (image_hacks.sh) main $* || return $?;; # normal invocation |
| 124 (*) echo "$0: Unknown invocation!"; exit 1 ;; |
| 125 esac |
OLD | NEW |