| #!/bin/sh | |
| # Copyright 2012 The ChromiumOS Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| # This script is called after an AutoUpdate or USB install. This script is a | |
| # simple wrapper to convert from the hardcoded command line to the new | |
| # executable command line. | |
| # NOTE: This script is called by installers like `chromeos-install` or | |
| # `update_engine` from inside the mounted rootfs of the target image. So it is | |
| # perfectly fine to modify this script without caring about backward/forward | |
| # compatibility. But it can never be migrated to a non-shell script because it | |
| # is being called by the original installer and that can break things badly. | |
| INSTALL_ROOT=$(dirname "$0") | |
| # Set up the mount points userland needs/expects. | |
| MOUNTS="/proc /dev /sys /tmp /run /var /mnt/stateful_partition" | |
| # Include chromeos-config, which is a submount of /run | |
| MOUNTS="${MOUNTS} /run/chromeos-config/v1" | |
| # Include efivarfs, which is a submount of /sys, if it's present. | |
| # This will only exist on efi systems with the appropriate kernel module. On | |
| # those systems this is needed for efi boot entry management. | |
| EFIVARS="/sys/firmware/efi/efivars" | |
| if [ -d "${EFIVARS}" ]; then | |
| MOUNTS="${MOUNTS} ${EFIVARS}" | |
| fi | |
| cleanup() { | |
| local d | |
| for d in ${MOUNTS}; do | |
| umount -lf "./${d}" || : | |
| done | |
| } | |
| main() { | |
| cd "${INSTALL_ROOT}" || exit 1 | |
| if [ "${INSTALL_ROOT}" != "/" ]; then | |
| echo "Setting up mounts for chroot postinst" | |
| trap cleanup EXIT | |
| local d | |
| for d in ${MOUNTS}; do | |
| mount -n --bind "${d}" "./${d}" | |
| mount --make-slave "./${d}" | |
| done | |
| fi | |
| local install_dev="$1" | |
| shift | |
| chroot . /usr/bin/cros_installer --type="postinst" \ | |
| --install_dev="${install_dev}" --install_dir="/" "$@" | |
| } | |
| main "$@" |