Extend modify_kernel_command_line() feature to grub and syslinux (reland)

For grub and syslinux this feature is a bit inferior to depthcharge
since it requires a full ./build_image, whereas for depthcharge a much
faster bin/cros_make_image_bootable build shortcut is enough.  Initial
attempts to implement at bin/cros_make_image_bootable time proved too
complex and brittle, involving: sed-wrangling, inconsistencies between
grub and syslinux in the installer, etc.

Some more background information in chromium:461595 #c20

With this change, in order to simplify the script, the --enable_serial
flag now defaults to "tty2". Also, the 'quiet' and 'debug' log options
are removed. There is already --loglevel flag that can be used to set
appropriate kernel log-level by boards.

TEST=Two systems are required to test both GRUB and syslinux:
- one with EFI to test GRUB
- one with SeaBIOS and depthcharge to test:
   - syslinux
   - Verified Boot (unaffected)

By choosing two systems compatible enough with each other, a single
${BOARD} can be used and build time saved.

Firstly, make sure this does not introduce any regression: images before
and after this CL both boot with the exact same /proc/cmdline and config
files (assuming they have no build_kernel_image.sh customization)

Next, actually use the feature: before building the image(s), create
one build_kernel_image.sh file per BOARD used. For instance:

cat <<"EOF" >src/overlays/overlay-${BOARD}/scripts/build_kernel_image.sh
modify_kernel_command_line() {
  # Use special characters to try to trigger quoting bugs if any.
 printf '%s\n' 'HELLO_ * " &_TEST_0003" '  >> "$1"

Board overlays can be defined in various places. The second most common
location is: src/private-overlays/overlay-${BOARD}-private/scripts/.
You may need to create the scripts/ directory.

Build and boot the image from USB (or SD). Make sure /proc/cmdline has:
- "cros_legacy" when booting USB with SeaBIOS (Ctrl-L)
- "cros_efi" when booting USB with EFI
- the HELLO_... test content above in both cases.

Inspect the /boot directory and make sure content is as expected.
Mount ESP partition 12 and inspect it too. This command is useful:
  diff -ru /boot/ /tmp/sdb12/

Next test the installer. Do NOT proceed and test the installer if any
previous testing above failed in any way no matter how small.  To
install run either:
  chromeos-install --dst /dev/sdX --target_bios efi
  chromeos-install --dst /dev/sdX --target_bios legacy
depending on the BOARD (/dev/sdX is usually: /dev/sda)

Reboot without the USB stick and run the same inspections above again,
now on the just installed hard drive. On the ${BOARD} with
depthcharge test with and without SeaBIOS.

Reverted-Change-Id: I207bed7b71f92c39229f218364c1dee63c4dcad2

Change-Id: Ibce7c0391191e2b318ff74dee936308b853b99a9
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/305740
Commit-Ready: Aditya Kali <adityakali@google.com>
Tested-by: Aditya Kali <adityakali@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2 files changed