OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Common constants for build scripts | 5 # Common constants for build scripts |
6 # This must evaluate properly for both /bin/bash and /bin/sh | 6 # This must evaluate properly for both /bin/bash and /bin/sh |
7 | 7 |
8 # All scripts should die on error unless commands are specifically excepted | 8 # All scripts should die on error unless commands are specifically excepted |
9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. | 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. |
10 # TODO: Re-enable this once shflags is less prone to dying. | 10 # TODO: Re-enable this once shflags is less prone to dying. |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 path=${1:?} | 355 path=${1:?} |
356 shift | 356 shift |
357 | 357 |
358 if ! sudo umount -d "${path}"; then | 358 if ! sudo umount -d "${path}"; then |
359 warn "Failed to unmount ${path}" | 359 warn "Failed to unmount ${path}" |
360 warn "Doing a lazy unmount" | 360 warn "Doing a lazy unmount" |
361 | 361 |
362 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" | 362 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" |
363 fi | 363 fi |
364 } | 364 } |
| 365 |
| 366 # Sets up symlinks for the developer root. It is necessary to symlink |
| 367 # usr and local since the developer root is mounted at /usr/local and |
| 368 # applications expect to be installed under /usr/local/bin, etc. |
| 369 # This avoids packages installing into /usr/local/usr/local/bin. |
| 370 # ${1} specifies the symlink target for the developer root. |
| 371 # ${2} specifies the symlink target for the var directory. |
| 372 # ${3} specifies the location of the stateful partition. |
| 373 setup_symlinks_on_root() { |
| 374 # Give args better names. |
| 375 local dev_image_target=${1} |
| 376 local var_target=${2} |
| 377 local dev_image_root="${3}/dev_image" |
| 378 |
| 379 # If our var target is actually the standard var, we are cleaning up the |
| 380 # symlinks (could also check for /usr/local for the dev_image_target). |
| 381 if [ ${var_target} = "/var" ]; then |
| 382 echo "Cleaning up /usr/local symlinks for ${dev_image_root}" |
| 383 else |
| 384 echo "Setting up symlinks for /usr/local for ${dev_image_root}" |
| 385 fi |
| 386 |
| 387 # Set up symlinks that should point to ${dev_image_target}. |
| 388 for path in usr local; do |
| 389 if [ -h "${dev_image_root}/${path}" ]; then |
| 390 sudo unlink "${dev_image_root}/${path}" |
| 391 elif [ -e "${dev_image_root}/${path}" ]; then |
| 392 die "${dev_image_root}/${path} should be a symlink if exists" |
| 393 fi |
| 394 sudo ln -s ${dev_image_target} "${dev_image_root}/${path}" |
| 395 done |
| 396 |
| 397 # Setup var symlink. |
| 398 if [ -h "${dev_image_root}/var" ]; then |
| 399 sudo unlink "${dev_image_root}/var" |
| 400 elif [ -e "${dev_image_root}/var" ]; then |
| 401 die "${dev_image_root}/var should be a symlink if it exists" |
| 402 fi |
| 403 |
| 404 sudo ln -s "${var_target}" "${dev_image_root}/var" |
| 405 } |
OLD | NEW |