init: Move developer logic into dev_utils.sh and load on demand.

The chromeos_startup has been bloated with many developer-specific logic
that should be ignored in normal path.

This change tries to move them to a new utility library (dev_utils.sh)
and only loaded if the system boots with CROS_DEBUG=1. Also changed most
shell variables to local variables in functions.

BUG=chromium:705414
TEST=Manually boots a device in normal mode and developer mode.
     Tested dev_gather_logs:
       - echo '/var/log' >/mnt/stateful_partition/.gatherme
       - reboot and found files in unencrypted/prior_lots
     Tested dev_mount_packages:
       - boot and see /usr/local, and symlink of /var/lib/portage
     Tested dev_check_block_dev_mode:
       - crossystem block_devmode=1; reboot
       - See blocking messages.

Change-Id: Ic170fc6f58df5e2fd3cbd3b979f4faaf1e202d9f
Reviewed-on: https://chromium-review.googlesource.com/448440
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
2 files changed