| 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 # Script to generate a factory install partition set and miniomaha.conf | 7 # Script to generate a factory install partition set and miniomaha.conf |
| 8 # file from a release image and a factory image. This creates a server | 8 # file from a release image and a factory image. This creates a server |
| 9 # configuration that can be installed using a factory install shim. | 9 # configuration that can be installed using a factory install shim. |
| 10 # | 10 # |
| 11 # miniomaha lives in src/platform/dev/ and miniomaha partition sets live | 11 # miniomaha lives in src/platform/dev/ and miniomaha partition sets live |
| 12 # in src/platform/dev/static. | 12 # in src/platform/dev/static. |
| 13 | 13 |
| 14 # Load common constants. This should be the first executable line. | 14 # Load common constants. This should be the first executable line. |
| 15 # The path to common.sh should be relative to your script's location. | 15 # The path to common.sh should be relative to your script's location. |
| 16 . "$(dirname "$0")/common.sh" | 16 . "$(dirname "$0")/common.sh" |
| 17 | 17 |
| 18 # Load functions and constants for chromeos-install | 18 # Load functions and constants for chromeos-install |
| 19 . "$(dirname "$0")/chromeos-common.sh" | 19 . "$(dirname "$0")/chromeos-common.sh" |
| 20 | 20 |
| 21 get_default_board | 21 get_default_board |
| 22 | 22 |
| 23 # Flags | 23 # Flags |
| 24 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built" | 24 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built" |
| 25 DEFINE_string factory "" \ | 25 DEFINE_string factory "" \ |
| 26 "Directory and file containing factory image: /path/chromiumos_test_image.bin" | 26 "Directory and file containing factory image: /path/chromiumos_test_image.bin" |
| 27 DEFINE_boolean include_firmware $FLAGS_FALSE \ | 27 DEFINE_string firmware_updater "" \ |
| 28 "If set, include the firmware image to the server configuration" | 28 "If set, include the firmware shellball into the server configuration" |
| 29 DEFINE_string release "" \ | 29 DEFINE_string release "" \ |
| 30 "Directory and file containing release image: /path/chromiumos_image.bin" | 30 "Directory and file containing release image: /path/chromiumos_image.bin" |
| 31 | 31 |
| 32 | 32 |
| 33 # Parse command line | 33 # Parse command line |
| 34 FLAGS "$@" || exit 1 | 34 FLAGS "$@" || exit 1 |
| 35 eval set -- "${FLAGS_ARGV}" | 35 eval set -- "${FLAGS_ARGV}" |
| 36 | 36 |
| 37 if [ ! -f "${FLAGS_release}" ] ; then | 37 if [ ! -f "${FLAGS_release}" ] ; then |
| 38 echo "Cannot find image file ${FLAGS_release}" | 38 echo "Cannot find image file ${FLAGS_release}" |
| 39 exit 1 | 39 exit 1 |
| 40 fi | 40 fi |
| 41 | 41 |
| 42 if [ ! -f "${FLAGS_factory}" ] ; then | 42 if [ ! -f "${FLAGS_factory}" ] ; then |
| 43 echo "Cannot find image file ${FLAGS_factory}" | 43 echo "Cannot find image file ${FLAGS_factory}" |
| 44 exit 1 | 44 exit 1 |
| 45 fi | 45 fi |
| 46 | 46 |
| 47 if [ ! -z "${FLAGS_firmware_updater}" ] && \ |
| 48 [ ! -f "${FLAGS_firmware_updater}" ] ; then |
| 49 echo "Cannot find firmware file ${FLAGS_firmware_updater}" |
| 50 exit 1 |
| 51 fi |
| 52 |
| 47 # Convert args to paths. Need eval to un-quote the string so that shell | 53 # Convert args to paths. Need eval to un-quote the string so that shell |
| 48 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. | 54 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. |
| 49 OMAHA_DIR=${SRC_ROOT}/platform/dev | 55 OMAHA_DIR=${SRC_ROOT}/platform/dev |
| 50 OMAHA_DATA_DIR=${OMAHA_DIR}/static/ | 56 OMAHA_DATA_DIR=${OMAHA_DIR}/static/ |
| 51 FIRMWARE_DIR=${SRC_ROOT}/platform/firmware/${FLAGS_board} | |
| 52 | 57 |
| 53 if [ ${INSIDE_CHROOT} -eq 0 ]; then | 58 if [ ${INSIDE_CHROOT} -eq 0 ]; then |
| 54 echo "Caching sudo authentication" | 59 echo "Caching sudo authentication" |
| 55 sudo -v | 60 sudo -v |
| 56 echo "Done" | 61 echo "Done" |
| 57 fi | 62 fi |
| 58 | 63 |
| 59 # Use this image as the source image to copy | 64 # Use this image as the source image to copy |
| 60 RELEASE_DIR=`dirname ${FLAGS_release}` | 65 RELEASE_DIR=`dirname ${FLAGS_release}` |
| 61 FACTORY_DIR=`dirname ${FLAGS_factory}` | 66 FACTORY_DIR=`dirname ${FLAGS_factory}` |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 mv rootfs-test.gz ${OMAHA_DATA_DIR} | 131 mv rootfs-test.gz ${OMAHA_DATA_DIR} |
| 127 echo "test: ${test_hash}" | 132 echo "test: ${test_hash}" |
| 128 | 133 |
| 129 cat part_1 | gzip -9 > state.gz | 134 cat part_1 | gzip -9 > state.gz |
| 130 state_hash=`cat state.gz | openssl sha1 -binary | openssl base64` | 135 state_hash=`cat state.gz | openssl sha1 -binary | openssl base64` |
| 131 mv state.gz ${OMAHA_DATA_DIR} | 136 mv state.gz ${OMAHA_DATA_DIR} |
| 132 echo "state: ${state_hash}" | 137 echo "state: ${state_hash}" |
| 133 | 138 |
| 134 popd > /dev/null | 139 popd > /dev/null |
| 135 | 140 |
| 136 if [ ${FLAGS_include_firmware} -eq ${FLAGS_TRUE} ] ; then | 141 if [ ! -z ${FLAGS_firmware_updater} ] ; then |
| 137 pushd ${FIRMWARE_DIR} > /dev/null | 142 SHELLBALL="${FLAGS_firmware_updater}" |
| 138 | 143 if [ ! -f "$SHELLBALL" ]; then |
| 139 ./pack_firmware.sh | gzip -9 > firmware.gz | 144 echo "Failed to find firmware updater: $SHELLBALL." |
| 140 if [ "${PIPESTATUS[*]}" != "0 0" ]; then | |
| 141 echo "Failed to pack the firmware image." | |
| 142 exit 1 | 145 exit 1 |
| 143 fi | 146 fi |
| 147 |
| 148 cat $SHELLBALL | gzip -9 > firmware.gz |
| 144 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` | 149 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` |
| 145 mv firmware.gz ${OMAHA_DATA_DIR} | 150 mv firmware.gz ${OMAHA_DATA_DIR} |
| 146 echo "firmware: ${firmware_hash}" | 151 echo "firmware: ${firmware_hash}" |
| 147 | |
| 148 popd > /dev/null | |
| 149 fi | 152 fi |
| 150 | 153 |
| 151 echo -n " | 154 echo -n " |
| 152 config = [ | 155 config = [ |
| 153 { | 156 { |
| 154 'qual_ids': set([\"${FLAGS_board}\"]), | 157 'qual_ids': set([\"${FLAGS_board}\"]), |
| 155 'factory_image': 'rootfs-test.gz', | 158 'factory_image': 'rootfs-test.gz', |
| 156 'factory_checksum': '${test_hash}', | 159 'factory_checksum': '${test_hash}', |
| 157 'release_image': 'rootfs-release.gz', | 160 'release_image': 'rootfs-release.gz', |
| 158 'release_checksum': '${release_hash}', | 161 'release_checksum': '${release_hash}', |
| 159 'oempartitionimg_image': 'oem.gz', | 162 'oempartitionimg_image': 'oem.gz', |
| 160 'oempartitionimg_checksum': '${oem_hash}', | 163 'oempartitionimg_checksum': '${oem_hash}', |
| 161 'efipartitionimg_image': 'efi.gz', | 164 'efipartitionimg_image': 'efi.gz', |
| 162 'efipartitionimg_checksum': '${efi_hash}', | 165 'efipartitionimg_checksum': '${efi_hash}', |
| 163 'stateimg_image': 'state.gz', | 166 'stateimg_image': 'state.gz', |
| 164 'stateimg_checksum': '${state_hash}'," > ${OMAHA_DIR}/miniomaha.conf | 167 'stateimg_checksum': '${state_hash}'," > ${OMAHA_DIR}/miniomaha.conf |
| 165 | 168 |
| 166 if [ ${FLAGS_include_firmware} -eq ${FLAGS_TRUE} ] ; then | 169 if [ ! -z "${FLAGS_firmware_updater}" ] ; then |
| 167 echo -n " | 170 echo -n " |
| 168 'firmware_image': 'firmware.gz', | 171 'firmware_image': 'firmware.gz', |
| 169 'firmware_checksum': '${firmware_hash}'," >> ${OMAHA_DIR}/miniomaha.conf | 172 'firmware_checksum': '${firmware_hash}'," >> ${OMAHA_DIR}/miniomaha.conf |
| 170 fi | 173 fi |
| 171 | 174 |
| 172 echo -n " | 175 echo -n " |
| 173 }, | 176 }, |
| 174 ] | 177 ] |
| 175 " >> ${OMAHA_DIR}/miniomaha.conf | 178 " >> ${OMAHA_DIR}/miniomaha.conf |
| 176 | 179 |
| 177 echo "The miniomaha server lives in src/platform/dev" | 180 echo "The miniomaha server lives in src/platform/dev" |
| 178 echo "to validate the configutarion, run:" | 181 echo "to validate the configutarion, run:" |
| 179 echo " python2.6 devserver.py --factory_config miniomaha.conf \ | 182 echo " python2.6 devserver.py --factory_config miniomaha.conf \ |
| 180 --validate_factory_config" | 183 --validate_factory_config" |
| 181 echo "To run the server:" | 184 echo "To run the server:" |
| 182 echo " python2.6 devserver.py --factory_config miniomaha.conf" | 185 echo " python2.6 devserver.py --factory_config miniomaha.conf" |
| OLD | NEW |