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 # |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if image_has_part_tools; then | 184 if image_has_part_tools; then |
185 IMAGE_IS_UNPACKED= | 185 IMAGE_IS_UNPACKED= |
186 else | 186 else |
187 #TODO(hungte) Currently we run unpack_partitions.sh if part_tools are not | 187 #TODO(hungte) Currently we run unpack_partitions.sh if part_tools are not |
188 # found. If the format of unpack_partitions.sh is reliable, we can prevent | 188 # found. If the format of unpack_partitions.sh is reliable, we can prevent |
189 # creating temporary files. See image_part_offset for more information. | 189 # creating temporary files. See image_part_offset for more information. |
190 echo "WARNING: cannot find partition tools. Using unpack_partitions.sh." >&2 | 190 echo "WARNING: cannot find partition tools. Using unpack_partitions.sh." >&2 |
191 IMAGE_IS_UNPACKED=1 | 191 IMAGE_IS_UNPACKED=1 |
192 fi | 192 fi |
193 | 193 |
| 194 mount_esp() { |
| 195 local image="$1" |
| 196 local esp_mountpoint="$2" |
| 197 offset=$(partoffset "${image}" 12) |
| 198 sudo mount -o loop,offset=$(( offset * 512 )) \ |
| 199 "${image}" "${esp_mountpoint}" |
| 200 ESP_MOUNT="${esp_mountpoint}" |
| 201 } |
| 202 |
| 203 umount_esp() { |
| 204 if [ -n "${ESP_MOUNT}" ]; then |
| 205 sudo umount "${ESP_MOUNT}" |
| 206 fi |
| 207 } |
| 208 |
194 generate_img() { | 209 generate_img() { |
195 local outdev="$(readlink -f "$FLAGS_diskimg")" | 210 local outdev="$(readlink -f "$FLAGS_diskimg")" |
196 local sectors="$FLAGS_sectors" | 211 local sectors="$FLAGS_sectors" |
197 | 212 |
198 prepare_img | 213 prepare_img |
199 | 214 |
200 # Get the release image. | 215 # Get the release image. |
201 pushd "${RELEASE_DIR}" >/dev/null | 216 pushd "${RELEASE_DIR}" >/dev/null |
202 | 217 |
203 echo "Release Kernel" | 218 echo "Release Kernel" |
204 image_partition_copy "${RELEASE_IMAGE}" 2 "${outdev}" 4 | 219 image_partition_copy "${RELEASE_IMAGE}" 2 "${outdev}" 4 |
205 | |
206 echo "Release Rootfs" | 220 echo "Release Rootfs" |
207 image_partition_copy "${RELEASE_IMAGE}" 3 "${outdev}" 5 | 221 image_partition_copy "${RELEASE_IMAGE}" 3 "${outdev}" 5 |
208 | |
209 echo "OEM parition" | 222 echo "OEM parition" |
210 image_partition_copy "${RELEASE_IMAGE}" 8 "${outdev}" 8 | 223 image_partition_copy "${RELEASE_IMAGE}" 8 "${outdev}" 8 |
211 | 224 |
212 popd >/dev/null | 225 popd >/dev/null |
213 | 226 |
214 # Go to retrieve the factory test image. | 227 # Go to retrieve the factory test image. |
215 pushd "${FACTORY_DIR}" >/dev/null | 228 pushd "${FACTORY_DIR}" >/dev/null |
216 | 229 |
217 echo "Factory Kernel" | 230 echo "Factory Kernel" |
218 image_partition_copy "${FACTORY_IMAGE}" 2 "${outdev}" 2 | 231 image_partition_copy "${FACTORY_IMAGE}" 2 "${outdev}" 2 |
219 echo "Factory Rootfs" | 232 echo "Factory Rootfs" |
220 image_partition_copy "${FACTORY_IMAGE}" 3 "${outdev}" 3 | 233 image_partition_copy "${FACTORY_IMAGE}" 3 "${outdev}" 3 |
221 echo "Factory Stateful" | 234 echo "Factory Stateful" |
222 image_partition_copy "${FACTORY_IMAGE}" 1 "${outdev}" 1 | 235 image_partition_copy "${FACTORY_IMAGE}" 1 "${outdev}" 1 |
223 echo "EFI Partition" | 236 echo "EFI Partition" |
224 image_partition_copy "${FACTORY_IMAGE}" 12 "${outdev}" 12 | 237 image_partition_copy "${FACTORY_IMAGE}" 12 "${outdev}" 12 |
225 | 238 |
| 239 # TODO(nsanders, wad): consolidate this code into some common code |
| 240 # when cleaning up kernel commandlines. There is code that touches |
| 241 # this in postint/chromeos-setimage and build_image. However none |
| 242 # of the preexisting code actually does what we want here. |
| 243 local tmpesp="$(mktemp -d)" |
| 244 mount_esp "${outdev}" "${tmpesp}" |
| 245 |
| 246 trap "umount_esp" EXIT |
| 247 |
| 248 # Edit boot device default for legacy. |
| 249 # Support both vboot and regular boot. |
| 250 sudo sed -i "s/chromeos-usb.A/chromeos-hd.A/" \ |
| 251 "${tmpesp}"/syslinux/default.cfg |
| 252 sudo sed -i "s/chromeos-vusb.A/chromeos-vhd.A/" \ |
| 253 "${tmpesp}"/syslinux/default.cfg |
| 254 |
| 255 # Edit root fs default for legacy |
| 256 # Somewhat safe as ARM does not support syslinux, I believe. |
| 257 sudo sed -i "s'HDROOTA'/dev/sda3'g" "${tmpesp}"/syslinux/root.A.cfg |
| 258 |
| 259 trap - EXIT |
| 260 |
| 261 umount_esp |
| 262 |
226 echo "Generated Image at $outdev." | 263 echo "Generated Image at $outdev." |
227 echo "Done" | 264 echo "Done" |
228 } | 265 } |
229 | 266 |
230 generate_omaha() { | 267 generate_omaha() { |
231 # Clean up stale config and data files. | 268 # Clean up stale config and data files. |
232 prepare_omaha | 269 prepare_omaha |
233 | 270 |
234 # Get the release image. | 271 # Get the release image. |
235 pushd "${RELEASE_DIR}" >/dev/null | 272 pushd "${RELEASE_DIR}" >/dev/null |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 To run the server: | 396 To run the server: |
360 python2.6 devserver.py --factory_config miniomaha.conf" | 397 python2.6 devserver.py --factory_config miniomaha.conf" |
361 } | 398 } |
362 | 399 |
363 # Main | 400 # Main |
364 if [ -n "$FLAGS_diskimg" ]; then | 401 if [ -n "$FLAGS_diskimg" ]; then |
365 generate_img | 402 generate_img |
366 else | 403 else |
367 generate_omaha | 404 generate_omaha |
368 fi | 405 fi |
OLD | NEW |