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

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

Issue 2075019: Cleanup of adding pristine image and fixing of symlinks in developer image. (Closed) Base URL: ssh://git@chromiumos-git//chromeos
Patch Set: Created 10 years, 7 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
OLDNEW
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 shift 362 shift
363 363
364 if ! sudo umount -d "${path}"; then 364 if ! sudo umount -d "${path}"; then
365 warn "Failed to unmount ${path}" 365 warn "Failed to unmount ${path}"
366 warn "Doing a lazy unmount" 366 warn "Doing a lazy unmount"
367 367
368 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" 368 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}"
369 fi 369 fi
370 } 370 }
371 371
372 # Fixes symlinks that are incorrectly prefixed with the build root ${1}
373 # rather than the real running root '/'.
374 # TODO(sosa) - Merge setup - cleanup below with this method.
375 fix_broken_symlinks() {
376 local build_root="${1}"
377 local symlinks=$(find "${build_root}/usr/local" -lname "${build_root}/*")
378 for symlink in ${symlinks}; do
379 echo "Fixing ${symlink}"
380 local target=$(ls -l "${symlink}" | cut -f 2 -d '>')
381 # Trim spaces from target (bashism).
382 target=${target/ /}
383 # Make new target (removes rootfs prefix).
384 new_target=$(echo ${target} | sed "s#${build_root}##")
385
386 echo "Fixing symlink ${symlink}"
387 sudo unlink "${symlink}"
388 sudo ln -sf "${new_target}" "${symlink}"
389 done
390 }
391
372 # Sets up symlinks for the developer root. It is necessary to symlink 392 # Sets up symlinks for the developer root. It is necessary to symlink
373 # usr and local since the developer root is mounted at /usr/local and 393 # usr and local since the developer root is mounted at /usr/local and
374 # applications expect to be installed under /usr/local/bin, etc. 394 # applications expect to be installed under /usr/local/bin, etc.
375 # This avoids packages installing into /usr/local/usr/local/bin. 395 # This avoids packages installing into /usr/local/usr/local/bin.
376 # ${1} specifies the symlink target for the developer root. 396 # ${1} specifies the symlink target for the developer root.
377 # ${2} specifies the symlink target for the var directory. 397 # ${2} specifies the symlink target for the var directory.
378 # ${3} specifies the location of the stateful partition. 398 # ${3} specifies the location of the stateful partition.
379 setup_symlinks_on_root() { 399 setup_symlinks_on_root() {
380 # Give args better names. 400 # Give args better names.
381 local dev_image_target=${1} 401 local dev_image_target=${1}
(...skipping 20 matching lines...) Expand all
402 422
403 # Setup var symlink. 423 # Setup var symlink.
404 if [ -h "${dev_image_root}/var" ]; then 424 if [ -h "${dev_image_root}/var" ]; then
405 sudo unlink "${dev_image_root}/var" 425 sudo unlink "${dev_image_root}/var"
406 elif [ -e "${dev_image_root}/var" ]; then 426 elif [ -e "${dev_image_root}/var" ]; then
407 die "${dev_image_root}/var should be a symlink if it exists" 427 die "${dev_image_root}/var should be a symlink if it exists"
408 fi 428 fi
409 429
410 sudo ln -s "${var_target}" "${dev_image_root}/var" 430 sudo ln -s "${var_target}" "${dev_image_root}/var"
411 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698