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

Side by Side Diff: enter_chroot.sh

Issue 6480005: Update chroot for chromite if needed. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Moved chromite fixes directly into enter_chroot. 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 enter the chroot environment 7 # Script to enter the chroot environment
8 8
9 # --- BEGIN COMMON.SH BOILERPLATE --- 9 # --- BEGIN COMMON.SH BOILERPLATE ---
10 # Load common CrOS utilities. Inside the chroot this file is installed in 10 # Load common CrOS utilities. Inside the chroot this file is installed in
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 # sort the list of mounts in reverse order, to ensure umount of 295 # sort the list of mounts in reverse order, to ensure umount of
296 # cascading mounts in proper order 296 # cascading mounts in proper order
297 for i in \ 297 for i in \
298 $(mount | grep -F "on $MOUNTED_PATH/" | sort -r | awk '{print $3}'); do 298 $(mount | grep -F "on $MOUNTED_PATH/" | sort -r | awk '{print $3}'); do
299 safe_umount "$i" 299 safe_umount "$i"
300 done 300 done
301 fi 301 fi
302 ) 200>>"$LOCKFILE" || die "teardown_env failed" 302 ) 200>>"$LOCKFILE" || die "teardown_env failed"
303 } 303 }
304 304
305 # This function does extra "fixups" of the chroot. It's a lot like
306 # chroot_hacks_from_outside() in common.sh, except that it is only called
307 # from enter_chroot.sh (chroot_hacks_from_outside is also called from
308 # make_chroot.sh). This function was created because common.sh is on lockdown
309 # and can't be changed.
310 #
311 # NOTE: the need for this type of "fixup" should be going away. If everything
312 # in the chroot is versioned and nothing is generated, there is no need to
313 # handle partly fixing up generated files.
314 #
315 # Please put date information so it's easy to keep track of when
316 # old hacks can be retired and so that people can detect when a
317 # hack triggered when it shouldn't have.
318 function chroot_hacks_too() {
319 local chroot_home="${FLAGS_chroot}/home/${USER}"
320
321 # Add chromite stuff if not already done.
322 if ! grep -q "^PATH=.*/trunk/chromite/bin" "${chroot_home}/.bashrc"; then
323 info "Upgrading old chroot (pre 2011-02-09) - adding chromite to path"
324 echo "PATH=\$PATH:/home/${USER}/trunk/chromite/bin" >> \
325 "${chroot_home}/.bashrc"
326 fi
327 if ! [ -L "${chroot_home}/.local/lib/python2.6/site-packages/chromite" ]; then
328 info "Upgrading old chroot (pre 2011-02-09) - add chromite to site-packages"
329 mkdir -p "${chroot_home}/.local/lib/python2.6/site-packages"
330 ln -s ../../../../trunk/chromite \
331 "${chroot_home}/.local/lib/python2.6/site-packages/"
332 fi
333 }
334
335
305 if [ $FLAGS_mount -eq $FLAGS_TRUE ]; then 336 if [ $FLAGS_mount -eq $FLAGS_TRUE ]; then
306 setup_env 337 setup_env
307 info "Make sure you run" 338 info "Make sure you run"
308 info " $0 --unmount" 339 info " $0 --unmount"
309 info "before deleting $FLAGS_chroot" 340 info "before deleting $FLAGS_chroot"
310 info "or you'll end up deleting $FLAGS_trunk too!" 341 info "or you'll end up deleting $FLAGS_trunk too!"
311 exit 0 342 exit 0
312 fi 343 fi
313 344
314 if [ $FLAGS_unmount -eq $FLAGS_TRUE ]; then 345 if [ $FLAGS_unmount -eq $FLAGS_TRUE ]; then
315 teardown_env 346 teardown_env
316 exit 0 347 exit 0
317 fi 348 fi
318 349
319 # Apply any hacks needed to update the chroot. 350 # Apply any hacks needed to update the chroot.
320 chroot_hacks_from_outside "${FLAGS_chroot}" 351 chroot_hacks_from_outside "${FLAGS_chroot}"
352 chroot_hacks_too
321 353
322 354
323 # Make sure we unmount before exiting 355 # Make sure we unmount before exiting
324 trap teardown_env EXIT 356 trap teardown_env EXIT
325 setup_env 357 setup_env
326 358
327 # Get the git revision to pass into the chroot. 359 # Get the git revision to pass into the chroot.
328 # 360 #
329 # This must be determined outside the chroot because (1) there is no 361 # This must be determined outside the chroot because (1) there is no
330 # git inside the chroot, and (2) if there were it would likely be 362 # git inside the chroot, and (2) if there were it would likely be
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 # Run command or interactive shell. Also include the non-chrooted path to 400 # Run command or interactive shell. Also include the non-chrooted path to
369 # the source trunk for scripts that may need to print it (e.g. 401 # the source trunk for scripts that may need to print it (e.g.
370 # build_image.sh). 402 # build_image.sh).
371 sudo -- chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ 403 sudo -- chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \
372 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ 404 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \
373 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" "$@" 405 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" "$@"
374 406
375 # Remove trap and explicitly unmount 407 # Remove trap and explicitly unmount
376 trap - EXIT 408 trap - EXIT
377 teardown_env 409 teardown_env
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698