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 build a bootable keyfob-based chromeos system image from within | 7 # Script to build a bootable keyfob-based chromeos system image from within |
8 # a chromiumos setup. This assumes that all needed packages have been built into | 8 # a chromiumos setup. This assumes that all needed packages have been built into |
9 # the given target's root with binary packages turned on. This script will | 9 # the given target's root with binary packages turned on. This script will |
10 # build the Chrome OS image using only pre-built binary packages. | 10 # build the Chrome OS image using only pre-built binary packages. |
(...skipping 18 matching lines...) Expand all Loading... |
29 "Directory in which to place image result directories (named by version)" | 29 "Directory in which to place image result directories (named by version)" |
30 DEFINE_boolean replace $FLAGS_FALSE \ | 30 DEFINE_boolean replace $FLAGS_FALSE \ |
31 "Overwrite existing output, if any." | 31 "Overwrite existing output, if any." |
32 DEFINE_boolean withdev $FLAGS_TRUE \ | 32 DEFINE_boolean withdev $FLAGS_TRUE \ |
33 "Include useful developer friendly utilities in the image." | 33 "Include useful developer friendly utilities in the image." |
34 DEFINE_boolean installmask $FLAGS_TRUE \ | 34 DEFINE_boolean installmask $FLAGS_TRUE \ |
35 "Use INSTALL_MASK to shrink the resulting image." | 35 "Use INSTALL_MASK to shrink the resulting image." |
36 DEFINE_integer jobs -1 \ | 36 DEFINE_integer jobs -1 \ |
37 "How many packages to build in parallel at maximum." | 37 "How many packages to build in parallel at maximum." |
38 DEFINE_boolean statefuldev $FLAGS_FALSE \ | 38 DEFINE_boolean statefuldev $FLAGS_FALSE \ |
39 "Install development packages on stateful partition -- still experimental" | 39 "Install development packages on stateful partition rather than the rootfs" |
40 DEFINE_string to "" \ | 40 DEFINE_string to "" \ |
41 "The target image file or device" | 41 "The target image file or device" |
42 DEFINE_boolean withtest $FLAGS_FALSE \ | 42 DEFINE_boolean withtest $FLAGS_FALSE \ |
43 "Include packages required for testing and prepare image for testing" | 43 "Include packages required for testing and prepare image for testing" |
44 | 44 |
45 # Parse command line. | 45 # Parse command line. |
46 FLAGS "$@" || exit 1 | 46 FLAGS "$@" || exit 1 |
47 eval set -- "${FLAGS_ARGV}" | 47 eval set -- "${FLAGS_ARGV}" |
48 | 48 |
49 # Only now can we die on error. shflags functions leak non-zero error codes, | 49 # Only now can we die on error. shflags functions leak non-zero error codes, |
50 # so will die prematurely if 'set -e' is specified before now. | 50 # so will die prematurely if 'set -e' is specified before now. |
51 set -e | 51 set -e |
52 | 52 |
53 if [ -z "$FLAGS_board" ] ; then | 53 if [ -z "$FLAGS_board" ] ; then |
54 error "--board is required." | 54 error "--board is required." |
55 exit 1 | 55 exit 1 |
56 fi | 56 fi |
57 | 57 |
58 # Sanity check: statefuldev cannot be true if withdev is false. | |
59 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] && | |
60 [ $FLAGS_withdev -eq $FLAGS_FALSE ] ; then | |
61 echo "ERROR: statefuldev flag cannot be set to true without withdev" | |
62 exit 1 | |
63 fi | |
64 | |
65 # Determine build version. | 58 # Determine build version. |
66 . "${SCRIPTS_DIR}/chromeos_version.sh" | 59 . "${SCRIPTS_DIR}/chromeos_version.sh" |
67 | 60 |
68 # Use canonical path since some tools (e.g. mount) do not like symlinks. | 61 # Use canonical path since some tools (e.g. mount) do not like symlinks. |
69 # Append build attempt to output directory. | 62 # Append build attempt to output directory. |
70 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" | 63 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" |
71 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}" | 64 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}" |
72 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" | 65 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" |
73 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" | 66 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" |
74 OUTPUT_IMG=${FLAGS_to:-${OUTPUT_DIR}/chromiumos_image.bin} | 67 OUTPUT_IMG=${FLAGS_to:-${OUTPUT_DIR}/chromiumos_image.bin} |
75 | 68 |
76 BOARD="${FLAGS_board}" | 69 BOARD="${FLAGS_board}" |
77 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" | 70 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" |
78 | 71 |
79 LOOP_DEV= | 72 LOOP_DEV= |
| 73 STATEFUL_LOOP_DEV= |
80 | 74 |
81 # What cross-build are we targeting? | 75 # What cross-build are we targeting? |
82 . "${BOARD_ROOT}/etc/make.conf.board_setup" | 76 . "${BOARD_ROOT}/etc/make.conf.board_setup" |
83 LIBC_VERSION=${LIBC_VERSION:-"2.10.1-r1"} | 77 LIBC_VERSION=${LIBC_VERSION:-"2.10.1-r1"} |
84 | 78 |
85 # Figure out ARCH from the given toolchain. | 79 # Figure out ARCH from the given toolchain. |
86 # TODO: Move to common.sh as a function after scripts are switched over. | 80 # TODO: Move to common.sh as a function after scripts are switched over. |
87 TC_ARCH=$(echo "$CHOST" | awk -F'-' '{ print $1 }') | 81 TC_ARCH=$(echo "$CHOST" | awk -F'-' '{ print $1 }') |
88 case "$TC_ARCH" in | 82 case "$TC_ARCH" in |
89 arm*) | 83 arm*) |
(...skipping 22 matching lines...) Expand all Loading... |
112 echo "Or use --replace if you want to overwrite this directory." | 106 echo "Or use --replace if you want to overwrite this directory." |
113 exit 1 | 107 exit 1 |
114 fi | 108 fi |
115 fi | 109 fi |
116 | 110 |
117 # Create the output directory. | 111 # Create the output directory. |
118 mkdir -p "$OUTPUT_DIR" | 112 mkdir -p "$OUTPUT_DIR" |
119 | 113 |
120 cleanup_rootfs_loop() { | 114 cleanup_rootfs_loop() { |
121 sudo umount "$LOOP_DEV" | 115 sudo umount "$LOOP_DEV" |
122 sleep 1 # in case $LOOP_DEV is in use (TODO: Try umount -l?). | 116 sleep 1 # in case $LOOP_DEV is in use. |
123 sudo losetup -d "$LOOP_DEV" | 117 sudo losetup -d "$LOOP_DEV" |
124 } | 118 } |
125 | 119 |
126 cleanup_stateful_fs_loop() { | 120 cleanup_stateful_fs_loop() { |
127 sudo umount "$STATEFUL_LOOP_DEV" | 121 sudo umount "${ROOT_FS_DIR}/usr/local" |
| 122 sudo umount "${ROOT_FS_DIR}/var" |
| 123 sudo umount "${STATEFUL_DIR}" |
128 sleep 1 # follows from cleanup_root_fs_loop. | 124 sleep 1 # follows from cleanup_root_fs_loop. |
129 sudo losetup -d "$STATEFUL_LOOP_DEV" | 125 sudo losetup -d "$STATEFUL_LOOP_DEV" |
130 } | 126 } |
131 | 127 |
132 cleanup_esp_loop() { | 128 cleanup_esp_loop() { |
133 sudo umount "$ESP_DIR" | 129 sudo umount "$ESP_DIR" |
134 } | 130 } |
135 | 131 |
136 cleanup() { | 132 cleanup() { |
137 # Disable die on error. | 133 # Disable die on error. |
138 set +e | 134 set +e |
139 | 135 |
140 # Unmount stateful partition from usr/local if bound. | |
141 if [ -s "$ROOT_FS_DIR/usr/local/bin" ] ; then | |
142 sudo umount $ROOT_FS_DIR/usr/local | |
143 fi | |
144 | |
145 if [[ -n "$STATEFUL_LOOP_DEV" ]]; then | 136 if [[ -n "$STATEFUL_LOOP_DEV" ]]; then |
146 cleanup_stateful_fs_loop | 137 cleanup_stateful_fs_loop |
147 fi | 138 fi |
148 | 139 |
149 if [[ -n "$LOOP_DEV" ]]; then | 140 if [[ -n "$LOOP_DEV" ]]; then |
150 cleanup_rootfs_loop | 141 cleanup_rootfs_loop |
151 fi | 142 fi |
152 | 143 |
153 if [[ -n "$ESP_DIR" ]]; then | 144 if [[ -n "$ESP_DIR" ]]; then |
154 cleanup_esp_loop | 145 cleanup_esp_loop |
155 fi | 146 fi |
156 | 147 |
157 # Turn die on error back on. | 148 # Turn die on error back on. |
158 set -e | 149 set -e |
159 } | 150 } |
160 | 151 |
| 152 # ${DEV_IMAGE_ROOT} specifies the location of where developer packages will |
| 153 # be installed on the stateful dir. On a Chromium OS system, this will |
| 154 # translate to /usr/local |
| 155 DEV_IMAGE_ROOT= |
| 156 |
| 157 # Sets up symlinks for the stateful partition based on the root specified by |
| 158 # ${1} and var directory specified by ${2}. |
| 159 setup_symlinks_on_root() { |
| 160 echo "Setting up symlinks on the stateful partition rooted at ${1} with"\ |
| 161 "var directory located at ${2}" |
| 162 |
| 163 for path in usr local; do |
| 164 if [ -h "${DEV_IMAGE_ROOT}/${path}" ] ; then |
| 165 sudo unlink "${DEV_IMAGE_ROOT}/${path}" |
| 166 elif [ -e "${DEV_IMAGE_ROOT}/${path}" ] ; then |
| 167 echo "*** ERROR: ${DEV_IMAGE_ROOT}/${path} should be a symlink if exists" |
| 168 return 1 |
| 169 fi |
| 170 sudo ln -s ${1} "${DEV_IMAGE_ROOT}/${path}" |
| 171 done |
| 172 |
| 173 # Setup var. Var is on the stateful partition at /var for both non-developer |
| 174 # builds and developer builds. |
| 175 if [ -h "${DEV_IMAGE_ROOT}/var" ] ; then |
| 176 sudo unlink "${DEV_IMAGE_ROOT}/var" |
| 177 elif [ -e "${DEV_IMAGE_ROOT}/var" ] ; then |
| 178 echo "*** ERROR: ${DEV_IMAGE_ROOT}/var should be a symlink if it exists" |
| 179 return 1 |
| 180 fi |
| 181 |
| 182 sudo ln -s "${2}" "${DEV_IMAGE_ROOT}/var" |
| 183 } |
| 184 |
161 trap cleanup EXIT | 185 trap cleanup EXIT |
162 | 186 |
163 mkdir -p "$ROOT_FS_DIR" | 187 mkdir -p "$ROOT_FS_DIR" |
164 | 188 |
165 # Create and format the root file system. | 189 # Create and format the root file system. |
166 | 190 |
167 # Check for loop device before creating image. | 191 # Check for loop device before creating image. |
168 LOOP_DEV=$(sudo losetup -f) | 192 LOOP_DEV=$(sudo losetup -f) |
169 if [ -z "$LOOP_DEV" ] ; then | 193 if [ -z "$LOOP_DEV" ] ; then |
170 echo "No free loop device. Free up a loop device or reboot. exiting. " | 194 echo "No free loop device. Free up a loop device or reboot. exiting. " |
(...skipping 24 matching lines...) Expand all Loading... |
195 dd if=/dev/zero of="$STATEFUL_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) | 219 dd if=/dev/zero of="$STATEFUL_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) |
196 sudo losetup "$STATEFUL_LOOP_DEV" "$STATEFUL_IMG" | 220 sudo losetup "$STATEFUL_LOOP_DEV" "$STATEFUL_IMG" |
197 sudo mkfs.ext3 "$STATEFUL_LOOP_DEV" | 221 sudo mkfs.ext3 "$STATEFUL_LOOP_DEV" |
198 sudo tune2fs -L "C-STATE" -U "$UUID" -c 0 -i 0 \ | 222 sudo tune2fs -L "C-STATE" -U "$UUID" -c 0 -i 0 \ |
199 "$STATEFUL_LOOP_DEV" | 223 "$STATEFUL_LOOP_DEV" |
200 | 224 |
201 # Mount the stateful partition. | 225 # Mount the stateful partition. |
202 mkdir -p "$STATEFUL_DIR" | 226 mkdir -p "$STATEFUL_DIR" |
203 sudo mount "$STATEFUL_LOOP_DEV" "$STATEFUL_DIR" | 227 sudo mount "$STATEFUL_LOOP_DEV" "$STATEFUL_DIR" |
204 | 228 |
| 229 # Set dev image root now that we have mounted the stateful partition we created |
| 230 DEV_IMAGE_ROOT="$STATEFUL_DIR/dev_image" |
| 231 |
205 # Turn root file system into bootable image. | 232 # Turn root file system into bootable image. |
206 if [[ "$ARCH" = "x86" ]]; then | 233 if [[ "$ARCH" = "x86" ]]; then |
207 # Setup extlinux configuration. | 234 # Setup extlinux configuration. |
208 # TODO: For some reason the /dev/disk/by-uuid is not being generated by udev | 235 # TODO: For some reason the /dev/disk/by-uuid is not being generated by udev |
209 # in the initramfs. When we figure that out, switch to root=UUID=$UUID. | 236 # in the initramfs. When we figure that out, switch to root=UUID=$UUID. |
210 sudo mkdir -p "$ROOT_FS_DIR"/boot | 237 sudo mkdir -p "$ROOT_FS_DIR"/boot |
211 # TODO(adlr): use initramfs for booting. | 238 # TODO(adlr): use initramfs for booting. |
212 cat <<EOF | sudo dd of="$ROOT_FS_DIR"/boot/extlinux.conf | 239 cat <<EOF | sudo dd of="$ROOT_FS_DIR"/boot/extlinux.conf |
213 DEFAULT chromeos-usb | 240 DEFAULT chromeos-usb |
214 PROMPT 0 | 241 PROMPT 0 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 273 |
247 INSTALL_MASK="" | 274 INSTALL_MASK="" |
248 if [[ $FLAGS_installmask -eq $FLAGS_FALSE ]] ; then | 275 if [[ $FLAGS_installmask -eq $FLAGS_FALSE ]] ; then |
249 INSTALL_MASK="$DEFAULT_INSTALL_MASK" | 276 INSTALL_MASK="$DEFAULT_INSTALL_MASK" |
250 fi | 277 fi |
251 | 278 |
252 if [[ $FLAGS_jobs -ne -1 ]]; then | 279 if [[ $FLAGS_jobs -ne -1 ]]; then |
253 EMERGE_JOBS="--jobs=$FLAGS_jobs" | 280 EMERGE_JOBS="--jobs=$FLAGS_jobs" |
254 fi | 281 fi |
255 | 282 |
256 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then | 283 # Prepare stateful partition with some pre-created directories |
257 # Creating stateful partition. | 284 sudo mkdir -p "${DEV_IMAGE_ROOT}" |
258 echo "Setting up symlinks for stateful partition install" | 285 sudo mkdir -p "${STATEFUL_DIR}/var" |
259 DEV_IMAGE_ROOT="$STATEFUL_DIR/dev_image" | |
260 sudo mkdir -p "$DEV_IMAGE_ROOT/usr" | |
261 | 286 |
262 # Setup symlinks in stateful partition. | 287 # Create symlinks so that /usr/local/usr based directories are symlinked to |
263 for path in bin include lib libexec sbin share; do | 288 # /usr/local/ directories e.g. /usr/local/usr/bin -> /usr/local/bin, etc. |
264 sudo mkdir "$DEV_IMAGE_ROOT/$path" | 289 setup_symlinks_on_root "${DEV_IMAGE_ROOT}" "${STATEFUL_DIR}/var" |
265 sudo ln -s "$DEV_IMAGE_ROOT/$path" "$DEV_IMAGE_ROOT/usr/$path" | |
266 done | |
267 | 290 |
268 # Setup symlinks that don't conform to above model. | 291 # Perform binding rather than symlinking because directories must exist |
269 sudo ln -s "$DEV_IMAGE_ROOT/lib" "$DEV_IMAGE_ROOT/usr/lib64" | 292 # on rootfs so that we can bind at run-time since rootfs is read-only |
270 sudo ln -s "$DEV_IMAGE_ROOT" "$DEV_IMAGE_ROOT/usr/local" | 293 echo "Binding directories from stateful partition onto the rootfs" |
271 | 294 sudo mkdir -p "${ROOT_FS_DIR}/usr/local" |
272 # Bind to rootfs. | 295 sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local" |
273 echo "Binding stateful partition to rootfs's /usr/local" | 296 sudo mkdir -p "${ROOT_FS_DIR}/var" |
274 sudo mkdir -p "$ROOT_FS_DIR/usr/local" | 297 sudo mount --bind "${STATEFUL_DIR}/var" "${ROOT_FS_DIR}/var" |
275 sudo mount -n --bind "$DEV_IMAGE_ROOT" "$ROOT_FS_DIR/usr/local" | |
276 fi | |
277 | 298 |
278 # We "emerge --root=$ROOT_FS_DIR --root-deps=rdeps --usepkgonly" all of the | 299 # We "emerge --root=$ROOT_FS_DIR --root-deps=rdeps --usepkgonly" all of the |
279 # runtime packages for chrome os. This builds up a chrome os image from binary | 300 # runtime packages for chrome os. This builds up a chrome os image from binary |
280 # packages with runtime dependencies only. We use INSTALL_MASK to trim the | 301 # packages with runtime dependencies only. We use INSTALL_MASK to trim the |
281 # image size as much as possible. | 302 # image size as much as possible. |
282 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ | 303 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ |
283 --root="$ROOT_FS_DIR" --root-deps=rdeps \ | 304 --root="$ROOT_FS_DIR" --root-deps=rdeps \ |
284 --usepkgonly chromeos $EMERGE_JOBS | 305 --usepkgonly chromeos $EMERGE_JOBS |
285 | 306 |
286 # Determine the root dir for development packages. | 307 # Determine the root dir for development packages. |
(...skipping 10 matching lines...) Expand all Loading... |
297 sudo cp -a "$(which ldd)" "${ROOT_DEV_DIR}/usr/bin" | 318 sudo cp -a "$(which ldd)" "${ROOT_DEV_DIR}/usr/bin" |
298 fi | 319 fi |
299 | 320 |
300 # Install packages required for testing. | 321 # Install packages required for testing. |
301 if [[ $FLAGS_withtest -eq $FLAGS_TRUE ]] ; then | 322 if [[ $FLAGS_withtest -eq $FLAGS_TRUE ]] ; then |
302 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ | 323 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ |
303 --root="$ROOT_DEV_DIR" --root-deps=rdeps \ | 324 --root="$ROOT_DEV_DIR" --root-deps=rdeps \ |
304 --usepkgonly chromeos-test $EMERGE_JOBS | 325 --usepkgonly chromeos-test $EMERGE_JOBS |
305 fi | 326 fi |
306 | 327 |
307 # Clean up links setup for stateful install of extra packages. | |
308 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then | |
309 # Fix symlinks so they work on live system. | |
310 for path in bin include lib libexec sbin share; do | |
311 sudo unlink $DEV_IMAGE_ROOT/usr/$path | |
312 sudo ln -s /usr/local/$path $DEV_IMAGE_ROOT/usr/$path | |
313 done | |
314 | |
315 # Fix exceptions. | |
316 sudo unlink "$DEV_IMAGE_ROOT/usr/lib64" | |
317 sudo unlink "$DEV_IMAGE_ROOT/usr/local" | |
318 | |
319 sudo ln -s "/usr/local/lib" "$DEV_IMAGE_ROOT/usr/lib64" | |
320 sudo ln -s "/usr/local" "$DEV_IMAGE_ROOT/usr/local" | |
321 | |
322 #TODO(sosa@chromium.org) - /usr/bin/xterm symlink not created in stateful. | |
323 sudo ln -sf "/usr/local/bin/aterm" "/usr/bin/xterm" | |
324 fi | |
325 | |
326 # Perform any customizations on the root file system that are needed. | 328 # Perform any customizations on the root file system that are needed. |
327 WITH_DEV="" | 329 WITH_DEV="" |
328 if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]]; then | 330 if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]]; then |
329 WITH_DEV="--withdev" | 331 WITH_DEV="--withdev" |
330 fi | 332 fi |
331 | 333 |
332 # Extract the kernel from the root filesystem for use by the GPT image. Legacy | 334 # Extract the kernel from the root filesystem for use by the GPT image. Legacy |
333 # BIOS will use the kernel in the rootfs (via syslinux), Chrome OS BIOS will | 335 # BIOS will use the kernel in the rootfs (via syslinux), Chrome OS BIOS will |
334 # use the kernel partition. | 336 # use the kernel partition. |
335 sudo cp -f "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" | 337 sudo cp -f "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" |
(...skipping 15 matching lines...) Expand all Loading... |
351 sudo cp ${ROOT_FS_DIR}/boot/vmlinuz ${ESP_DIR}/efi/boot/vmlinuz | 353 sudo cp ${ROOT_FS_DIR}/boot/vmlinuz ${ESP_DIR}/efi/boot/vmlinuz |
352 cat <<EOF | sudo dd of=${ESP_DIR}/efi/boot/grub.cfg | 354 cat <<EOF | sudo dd of=${ESP_DIR}/efi/boot/grub.cfg |
353 set timeout=2 | 355 set timeout=2 |
354 set default=0 | 356 set default=0 |
355 | 357 |
356 menuentry "32-bit serial" { | 358 menuentry "32-bit serial" { |
357 linux /efi/boot/vmlinuz earlyprintk=serial,ttyS0,115200 i915.modeset=0 console
=ttyS0,115200 acpi=off init=/sbin/init boot=local rootwait root=/dev/sda3 ro nor
esume noswap loglevel=7 | 359 linux /efi/boot/vmlinuz earlyprintk=serial,ttyS0,115200 i915.modeset=0 console
=ttyS0,115200 acpi=off init=/sbin/init boot=local rootwait root=/dev/sda3 ro nor
esume noswap loglevel=7 |
358 } | 360 } |
359 EOF | 361 EOF |
360 | 362 |
361 #TODO(sosa@chromium.org) - Does it make sense to leave /usr/local bound here? | |
362 "${SCRIPTS_DIR}/customize_rootfs" \ | 363 "${SCRIPTS_DIR}/customize_rootfs" \ |
363 --root="$ROOT_FS_DIR" \ | 364 --root="$ROOT_FS_DIR" \ |
364 --target="$ARCH" \ | 365 --target="$ARCH" \ |
365 --board="$BOARD" \ | 366 --board="$BOARD" \ |
366 $WITH_DEV | 367 $WITH_DEV |
367 | 368 |
368 # Check that the image has been correctly created. | 369 # Check that the image has been correctly created. |
369 "${SCRIPTS_DIR}/test_image" \ | 370 "${SCRIPTS_DIR}/test_image" \ |
370 --root="$ROOT_FS_DIR" \ | 371 --root="$ROOT_FS_DIR" \ |
371 --target="$ARCH" | 372 --target="$ARCH" |
372 | 373 |
373 # Set dev_mode flag and update library cache. | 374 # Enable dev mode on the target system and re-run ldconfig |
| 375 # for rootfs's ld.so.cache |
374 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then | 376 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then |
| 377 # Flag will mount /usr/local on target device |
| 378 sudo mkdir -p "$ROOT_FS_DIR/root" |
375 sudo touch "$ROOT_FS_DIR/root/.dev_mode" | 379 sudo touch "$ROOT_FS_DIR/root/.dev_mode" |
| 380 |
| 381 # Re-run ldconfig to fix /etc/ldconfig.so.cache |
376 sudo /sbin/ldconfig -r "$ROOT_FS_DIR" | 382 sudo /sbin/ldconfig -r "$ROOT_FS_DIR" |
| 383 |
| 384 #TODO(sosa@chromium.org) - /usr/bin/xterm symlink not created in stateful. |
| 385 sudo ln -sf "/usr/local/bin/aterm" "/usr/bin/xterm" |
377 fi | 386 fi |
378 | 387 |
379 # Only bound if installing dev to stateful. | 388 # Clean up symlinks so they work on a running target rooted at "/". |
380 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then | 389 # Here development packages are rooted at /usr/local. However, do not |
381 sudo umount "$ROOT_FS_DIR/usr/local" | 390 # create /usr/local or /var on host (already exist on target). |
382 fi | 391 setup_symlinks_on_root "/usr/local" "/var" |
383 | 392 |
384 # Cleanup loop devices. | 393 # Cleanup loop devices. |
385 cleanup_esp_loop | 394 cleanup |
386 cleanup_stateful_fs_loop | |
387 cleanup_rootfs_loop | |
388 | 395 |
389 # Create the GPT-formatted image | 396 # Create the GPT-formatted image |
390 ${SCRIPTS_DIR}/build_gpt.sh \ | 397 ${SCRIPTS_DIR}/build_gpt.sh \ |
391 --arch=${ARCH} --board=${FLAGS_board} --board_root=${BOARD_ROOT} \ | 398 --arch=${ARCH} --board=${FLAGS_board} --board_root=${BOARD_ROOT} \ |
392 "${OUTPUT_DIR}" "${OUTPUT_IMG}" | 399 "${OUTPUT_DIR}" "${OUTPUT_IMG}" |
393 | 400 |
394 # Clean up temporary files. | 401 # Clean up temporary files. |
395 rm -f "${ROOT_FS_IMG}" "${STATEFUL_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \ | 402 rm -f "${ROOT_FS_IMG}" "${STATEFUL_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \ |
396 "${ESP_IMG}" | 403 "${ESP_IMG}" |
397 rmdir "${ROOT_FS_DIR}" "${STATEFUL_DIR}" "${ESP_DIR}" | 404 rmdir "${ROOT_FS_DIR}" "${STATEFUL_DIR}" "${ESP_DIR}" |
398 | 405 |
399 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" | 406 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" |
400 echo "Done. Image created in ${OUTPUT_DIR}" | 407 echo "Done. Image created in ${OUTPUT_DIR}" |
401 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 408 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
402 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb" | 409 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb" |
403 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" | 410 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" |
404 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" | 411 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" |
405 echo "from the scripts directory where you entered the chroot." | 412 echo "from the scripts directory where you entered the chroot." |
406 | 413 |
407 trap - EXIT | 414 trap - EXIT |
OLD | NEW |