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

Side by Side Diff: bin/cros_make_factory_package.sh

Issue 6413012: chromeos-installer: delete unused files (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/installer.git@master
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « bin/cros_image_to_vm.sh ('k') | bin/cros_make_image_bootable » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 # 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
9 # configuration that can be installed using a factory install shim.
10 #
11 # miniomaha lives in src/platform/dev/ and miniomaha partition sets live
12 # in src/platform/dev/static.
13
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.
16 . "/usr/lib/crosutils/common.sh"
17
18 # Load functions and constants for chromeos-install
19 . "/usr/lib/installer/chromeos-common.sh"
20
21 get_default_board
22
23 # Flags
24 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built"
25 DEFINE_string factory "" \
26 "Directory and file containing factory image: /path/chromiumos_test_image.bin"
27 DEFINE_string firmware_updater "" \
28 "If set, include the firmware shellball into the server configuration"
29 DEFINE_string release "" \
30 "Directory and file containing release image: /path/chromiumos_image.bin"
31
32
33 # Parse command line
34 FLAGS "$@" || exit 1
35 eval set -- "${FLAGS_ARGV}"
36
37 if [ ! -f "${FLAGS_release}" ] ; then
38 echo "Cannot find image file ${FLAGS_release}"
39 exit 1
40 fi
41
42 if [ ! -f "${FLAGS_factory}" ] ; then
43 echo "Cannot find image file ${FLAGS_factory}"
44 exit 1
45 fi
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
53 # Convert args to paths. Need eval to un-quote the string so that shell
54 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work.
55 OMAHA_DIR=${SRC_ROOT}/platform/dev
56 OMAHA_DATA_DIR=${OMAHA_DIR}/static/
57
58 if [ ${INSIDE_CHROOT} -eq 0 ]; then
59 echo "Caching sudo authentication"
60 sudo -v
61 echo "Done"
62 fi
63
64 # Use this image as the source image to copy
65 RELEASE_DIR=`dirname ${FLAGS_release}`
66 FACTORY_DIR=`dirname ${FLAGS_factory}`
67 RELEASE_IMAGE=`basename ${FLAGS_release}`
68 FACTORY_IMAGE=`basename ${FLAGS_factory}`
69
70
71 prepare_omaha() {
72 sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-test.gz
73 sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-release.gz
74 rm -rf ${OMAHA_DATA_DIR}/efi.gz
75 rm -rf ${OMAHA_DATA_DIR}/oem.gz
76 rm -rf ${OMAHA_DATA_DIR}/state.gz
77 rm -rf ${OMAHA_DIR}/miniomaha.conf
78 }
79
80 prepare_dir() {
81 sudo rm -rf rootfs-test.gz
82 sudo rm -rf rootfs-release.gz
83 rm -rf efi.gz
84 rm -rf oem.gz
85 rm -rf state.gz
86 }
87
88
89 # Clean up stale config and data files.
90 prepare_omaha
91
92 # Get the release image.
93 pushd ${RELEASE_DIR} > /dev/null
94 echo "Generating omaha release image from ${FLAGS_release}"
95 echo "Generating omaha factory image from ${FLAGS_factory}"
96 echo "Output omaha image to ${OMAHA_DATA_DIR}"
97 echo "Output omaha config to ${OMAHA_DIR}/miniomaha.conf"
98
99 prepare_dir
100
101 sudo ./unpack_partitions.sh ${RELEASE_IMAGE} &> /dev/null
102 release_hash=`sudo /usr/bin/cros_mk_memento_images.sh part_2 \
103 part_3 | grep hash | awk '{print $4}'`
104 sudo chmod a+rw update.gz
105 mv update.gz rootfs-release.gz
106 mv rootfs-release.gz ${OMAHA_DATA_DIR}
107 echo "release: ${release_hash}"
108
109 cat part_8 | gzip -9 > oem.gz
110 oem_hash=`cat oem.gz | openssl sha1 -binary | openssl base64`
111 mv oem.gz ${OMAHA_DATA_DIR}
112 echo "oem: ${oem_hash}"
113
114 cat part_12 | gzip -9 > efi.gz
115 efi_hash=`cat efi.gz | openssl sha1 -binary | openssl base64`
116 mv efi.gz ${OMAHA_DATA_DIR}
117 echo "efi: ${efi_hash}"
118
119 popd > /dev/null
120
121 # Go to retrieve the factory test image.
122 pushd ${FACTORY_DIR} > /dev/null
123 prepare_dir
124
125
126 sudo ./unpack_partitions.sh ${FACTORY_IMAGE} &> /dev/null
127 test_hash=`sudo /usr/bin/cros_mk_memento_images.sh part_2 part_3 \
128 | grep hash | awk '{print $4}'`
129 sudo chmod a+rw update.gz
130 mv update.gz rootfs-test.gz
131 mv rootfs-test.gz ${OMAHA_DATA_DIR}
132 echo "test: ${test_hash}"
133
134 cat part_1 | gzip -9 > state.gz
135 state_hash=`cat state.gz | openssl sha1 -binary | openssl base64`
136 mv state.gz ${OMAHA_DATA_DIR}
137 echo "state: ${state_hash}"
138
139 popd > /dev/null
140
141 if [ ! -z ${FLAGS_firmware_updater} ] ; then
142 SHELLBALL="${FLAGS_firmware_updater}"
143 if [ ! -f "$SHELLBALL" ]; then
144 echo "Failed to find firmware updater: $SHELLBALL."
145 exit 1
146 fi
147
148 cat $SHELLBALL | gzip -9 > firmware.gz
149 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64`
150 mv firmware.gz ${OMAHA_DATA_DIR}
151 echo "firmware: ${firmware_hash}"
152 fi
153
154 echo -n "
155 config = [
156 {
157 'qual_ids': set([\"${FLAGS_board}\"]),
158 'factory_image': 'rootfs-test.gz',
159 'factory_checksum': '${test_hash}',
160 'release_image': 'rootfs-release.gz',
161 'release_checksum': '${release_hash}',
162 'oempartitionimg_image': 'oem.gz',
163 'oempartitionimg_checksum': '${oem_hash}',
164 'efipartitionimg_image': 'efi.gz',
165 'efipartitionimg_checksum': '${efi_hash}',
166 'stateimg_image': 'state.gz',
167 'stateimg_checksum': '${state_hash}'," > ${OMAHA_DIR}/miniomaha.conf
168
169 if [ ! -z "${FLAGS_firmware_updater}" ] ; then
170 echo -n "
171 'firmware_image': 'firmware.gz',
172 'firmware_checksum': '${firmware_hash}'," >> ${OMAHA_DIR}/miniomaha.conf
173 fi
174
175 echo -n "
176 },
177 ]
178 " >> ${OMAHA_DIR}/miniomaha.conf
179
180 echo "The miniomaha server lives in src/platform/dev"
181 echo "to validate the configutarion, run:"
182 echo " python2.6 devserver.py --factory_config miniomaha.conf \
183 --validate_factory_config"
184 echo "To run the server:"
185 echo " python2.6 devserver.py --factory_config miniomaha.conf"
OLDNEW
« no previous file with comments | « bin/cros_image_to_vm.sh ('k') | bin/cros_make_image_bootable » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698