Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: src/scripts/make_factory_package.sh

Issue 2366001: Pack firmware into an image and do update in factory install process. (Closed) Base URL: ssh://git@chromiumos-git/chromiumos
Patch Set: add 2 emtpy firmware images Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/platform/memento_softwareupdate/memento_updater.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 \
28 "If set, include the firmware image to the server configuration"
27 DEFINE_string release "" \ 29 DEFINE_string release "" \
28 "Directory and file containing release image: /path/chromiumos_image.bin" 30 "Directory and file containing release image: /path/chromiumos_image.bin"
29 31
30 32
31 # Parse command line 33 # Parse command line
32 FLAGS "$@" || exit 1 34 FLAGS "$@" || exit 1
33 eval set -- "${FLAGS_ARGV}" 35 eval set -- "${FLAGS_ARGV}"
34 36
35 if [ ! -f "${FLAGS_release}" ] ; then 37 if [ ! -f "${FLAGS_release}" ] ; then
36 echo "Cannot find image file ${FLAGS_release}" 38 echo "Cannot find image file ${FLAGS_release}"
37 exit 1 39 exit 1
38 fi 40 fi
39 41
40 if [ ! -f "${FLAGS_factory}" ] ; then 42 if [ ! -f "${FLAGS_factory}" ] ; then
41 echo "Cannot find image file ${FLAGS_factory}" 43 echo "Cannot find image file ${FLAGS_factory}"
42 exit 1 44 exit 1
43 fi 45 fi
44 46
45 # Convert args to paths. Need eval to un-quote the string so that shell 47 # Convert args to paths. Need eval to un-quote the string so that shell
46 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. 48 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work.
47 OMAHA_DIR=${SRC_ROOT}/platform/dev 49 OMAHA_DIR=${SRC_ROOT}/platform/dev
48 OMAHA_DATA_DIR=${OMAHA_DIR}/static/ 50 OMAHA_DATA_DIR=${OMAHA_DIR}/static/
51 FIRMWARE_DIR=${SRC_ROOT}/platform/firmware/${FLAGS_board}
49 52
50 if [ ${INSIDE_CHROOT} -eq 0 ]; then 53 if [ ${INSIDE_CHROOT} -eq 0 ]; then
51 echo "Caching sudo authentication" 54 echo "Caching sudo authentication"
52 sudo -v 55 sudo -v
53 echo "Done" 56 echo "Done"
54 fi 57 fi
55 58
56 # Use this image as the source image to copy 59 # Use this image as the source image to copy
57 RELEASE_DIR=`dirname ${FLAGS_release}` 60 RELEASE_DIR=`dirname ${FLAGS_release}`
58 FACTORY_DIR=`dirname ${FLAGS_factory}` 61 FACTORY_DIR=`dirname ${FLAGS_factory}`
(...skipping 16 matching lines...) Expand all
75 rm -rf efi.gz 78 rm -rf efi.gz
76 rm -rf oem.gz 79 rm -rf oem.gz
77 rm -rf state.gz 80 rm -rf state.gz
78 } 81 }
79 82
80 83
81 # Clean up stale config and data files. 84 # Clean up stale config and data files.
82 prepare_omaha 85 prepare_omaha
83 86
84 # Get the release image. 87 # Get the release image.
85 pushd ${RELEASE_DIR} 88 pushd ${RELEASE_DIR} > /dev/null
86 echo "Generating omaha release image from ${FLAGS_release}" 89 echo "Generating omaha release image from ${FLAGS_release}"
87 echo "Generating omaha factory image from ${FLAGS_factory}" 90 echo "Generating omaha factory image from ${FLAGS_factory}"
88 echo "Output omaha image to ${OMAHA_DATA_DIR}" 91 echo "Output omaha image to ${OMAHA_DATA_DIR}"
89 echo "Output omaha config to ${OMAHA_DIR}/miniomaha.conf" 92 echo "Output omaha config to ${OMAHA_DIR}/miniomaha.conf"
90 93
91 prepare_dir 94 prepare_dir
92 95
93 sudo ./unpack_partitions.sh ${RELEASE_IMAGE} &> /dev/null 96 sudo ./unpack_partitions.sh ${RELEASE_IMAGE} &> /dev/null
94 release_hash=`sudo ${SCRIPTS_DIR}/mk_memento_images.sh part_2 part_3 \ 97 release_hash=`sudo ${SCRIPTS_DIR}/mk_memento_images.sh part_2 part_3 \
95 | grep hash | awk '{print $4}'` 98 | grep hash | awk '{print $4}'`
96 sudo chmod a+rw update.gz 99 sudo chmod a+rw update.gz
97 mv update.gz rootfs-release.gz 100 mv update.gz rootfs-release.gz
98 mv rootfs-release.gz ${OMAHA_DATA_DIR} 101 mv rootfs-release.gz ${OMAHA_DATA_DIR}
99 echo "release: ${release_hash}" 102 echo "release: ${release_hash}"
100 103
101 cat part_8 | gzip -9 > oem.gz 104 cat part_8 | gzip -9 > oem.gz
102 oem_hash=`cat oem.gz | openssl sha1 -binary | openssl base64` 105 oem_hash=`cat oem.gz | openssl sha1 -binary | openssl base64`
103 mv oem.gz ${OMAHA_DATA_DIR} 106 mv oem.gz ${OMAHA_DATA_DIR}
104 echo "oem: ${oem_hash}" 107 echo "oem: ${oem_hash}"
105 108
106 cat part_12 | gzip -9 > efi.gz 109 cat part_12 | gzip -9 > efi.gz
107 efi_hash=`cat efi.gz | openssl sha1 -binary | openssl base64` 110 efi_hash=`cat efi.gz | openssl sha1 -binary | openssl base64`
108 mv efi.gz ${OMAHA_DATA_DIR} 111 mv efi.gz ${OMAHA_DATA_DIR}
109 echo "efi: ${efi_hash}" 112 echo "efi: ${efi_hash}"
110 113
111 popd 114 popd > /dev/null
112 115
113 # Go to retrieve the factory test image. 116 # Go to retrieve the factory test image.
114 pushd ${FACTORY_DIR} 117 pushd ${FACTORY_DIR} > /dev/null
115 prepare_dir 118 prepare_dir
116 119
117 120
118 sudo ./unpack_partitions.sh ${FACTORY_IMAGE} &> /dev/null 121 sudo ./unpack_partitions.sh ${FACTORY_IMAGE} &> /dev/null
119 test_hash=`sudo ${SCRIPTS_DIR}//mk_memento_images.sh part_2 part_3 \ 122 test_hash=`sudo ${SCRIPTS_DIR}//mk_memento_images.sh part_2 part_3 \
120 | grep hash | awk '{print $4}'` 123 | grep hash | awk '{print $4}'`
121 sudo chmod a+rw update.gz 124 sudo chmod a+rw update.gz
122 mv update.gz rootfs-test.gz 125 mv update.gz rootfs-test.gz
123 mv rootfs-test.gz ${OMAHA_DATA_DIR} 126 mv rootfs-test.gz ${OMAHA_DATA_DIR}
124 echo "test: ${test_hash}" 127 echo "test: ${test_hash}"
125 128
126 cat part_1 | gzip -9 > state.gz 129 cat part_1 | gzip -9 > state.gz
127 state_hash=`cat state.gz | openssl sha1 -binary | openssl base64` 130 state_hash=`cat state.gz | openssl sha1 -binary | openssl base64`
128 mv state.gz ${OMAHA_DATA_DIR} 131 mv state.gz ${OMAHA_DATA_DIR}
129 echo "state: ${state_hash}" 132 echo "state: ${state_hash}"
130 133
131 echo " 134 popd > /dev/null
135
136 if [ ${FLAGS_include_firmware} -eq ${FLAGS_TRUE} ] ; then
137 pushd ${FIRMWARE_DIR} > /dev/null
138
139 ./pack_firmware.sh | gzip -9 > firmware.gz
140 if [ "${PIPESTATUS[*]}" != "0 0" ]; then
141 echo "Failed to pack the firmware image."
142 exit 1
143 fi
144 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64`
145 mv firmware.gz ${OMAHA_DATA_DIR}
146 echo "firmware: ${firmware_hash}"
147
148 popd > /dev/null
149 fi
150
151 echo -n "
132 config = [ 152 config = [
133 { 153 {
134 'qual_ids': set([\"${FLAGS_board}\"]), 154 'qual_ids': set([\"${FLAGS_board}\"]),
135 'factory_image': 'rootfs-test.gz', 155 'factory_image': 'rootfs-test.gz',
136 'factory_checksum': '${test_hash}', 156 'factory_checksum': '${test_hash}',
137 'release_image': 'rootfs-release.gz', 157 'release_image': 'rootfs-release.gz',
138 'release_checksum': '${release_hash}', 158 'release_checksum': '${release_hash}',
139 'oempartitionimg_image': 'oem.gz', 159 'oempartitionimg_image': 'oem.gz',
140 'oempartitionimg_checksum': '${oem_hash}', 160 'oempartitionimg_checksum': '${oem_hash}',
141 'efipartitionimg_image': 'efi.gz', 161 'efipartitionimg_image': 'efi.gz',
142 'efipartitionimg_checksum': '${efi_hash}', 162 'efipartitionimg_checksum': '${efi_hash}',
143 'stateimg_image': 'state.gz', 163 'stateimg_image': 'state.gz',
144 'stateimg_checksum': '${state_hash}' 164 'stateimg_checksum': '${state_hash}'," > ${OMAHA_DIR}/miniomaha.conf
165
166 if [ ! -z ${FLAGS_include_firmware} ] ; then
167 echo -n "
168 'firmware_image': 'firmware.gz',
169 'firmware_checksum': '${firmware_hash}'," >> ${OMAHA_DIR}/miniomaha.conf
170 fi
171
172 echo -n "
145 }, 173 },
146 ] 174 ]
147 " > ${OMAHA_DIR}/miniomaha.conf 175 " >> ${OMAHA_DIR}/miniomaha.conf
148 176
149 popd
150 echo "The miniomaha server lives in src/platform/dev" 177 echo "The miniomaha server lives in src/platform/dev"
151 echo "to validate the configutarion, run:" 178 echo "to validate the configutarion, run:"
152 echo " python2.6 devserver.py --factory_config miniomaha.conf \ 179 echo " python2.6 devserver.py --factory_config miniomaha.conf \
153 --validate_factory_config" 180 --validate_factory_config"
154 echo "To run the server:" 181 echo "To run the server:"
155 echo " python2.6 devserver.py --factory_config miniomaha.conf" 182 echo " python2.6 devserver.py --factory_config miniomaha.conf"
OLDNEW
« no previous file with comments | « src/platform/memento_softwareupdate/memento_updater.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698