Commit Graph

35 Commits

Author SHA1 Message Date
Brandon Philips
4057d5590d feat(disk_layout): follow new CoreOS partition layout
As outlined here we need a new partition layout, this patch makes the
necessary changes:
https://groups.google.com/forum/#!topic/coreos-dev/bA7gwGGoTng

The first big change is making all of the scripts obey partition numbers
based on labels in the disk_layout.json. This makes it much easier to
change later on.

The second big change is in the layout itself. The json file was updated
to reflect the document above.

And finally the grub boot configuration needed for pv-grub and pygrub
were added to the create_legacy_bootloader_templates.sh library utlity.

Everything seems to work and boot now.
2013-05-12 12:31:03 -07:00
Brandon Philips
be7a09d64d feat(image_to_vm): setup grub/menu.lst for xen
xen requires a /boot/grub/menu.lst for pygrub and pvgrub on partition 1.
Put it on the stateful partition for now and come back around and fix
this up when we redo the partition layout.
2013-05-03 18:34:45 -07:00
Mike Frysinger
79ae5b4a06 use new status=none with dd
The latest coreutils introduces a status=none option which suppresses
all information which is more than the current status=noxfer.

BUG=None
TEST=`./build_image` no longer spews any dd info

Change-Id: I3cfefed1d38e7e5ff52342c98e6a306d9a48950a
Reviewed-on: https://gerrit.chromium.org/gerrit/41930
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2013-01-24 13:58:27 -08:00
Mike Frysinger
3c74b3db97 quiet down grep/dd output
This removes some spurious noise from the build_image output.

BUG=None
TEST=`./build_image` still worked and is quieter

Change-Id: Ic5d89a462dc137a1a710f77dc16cee401e0083b2
Reviewed-on: https://gerrit.chromium.org/gerrit/35426
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-11-02 10:01:53 -07:00
Brian Harring
ece65e0633 Add a umount wrapper to suppress gvfsd/trashd breaking umount calls.
Specifically, detect if the umount failed due to current access, if so,
give it up to 9 more runs (w/ 1s pauses) continuing only if it's still
failing due to currently open files.

Via this, it should suppress the race of gvfs/trashd looking at
quick mounted/umounted pathways.

This CL is a two parter; this adds the script, and converts common.sh
consumers over to using the override.

The next CL will modify the chroot itself to ensure our script gets
picked up/used.

BUG=chromium-os:23443
TEST=trybot, manul validation.

Change-Id: I92dedd91d6133c2063b1e5dbbc1a68366844801d
Reviewed-on: https://gerrit.chromium.org/gerrit/32087
Commit-Ready: Brian Harring <ferringb@chromium.org>
Reviewed-by: Brian Harring <ferringb@chromium.org>
Tested-by: Brian Harring <ferringb@chromium.org>
2012-09-05 00:00:43 -07:00
Mike Frysinger
c17a493bcc setup DEFAULT_BOARD by default
Rather than forcing all consumers of DEFAULT_BOARD to remember to call
get_default_board, just do it for them automatically.

BUG=None
TEST=`cbuildbot {arm,amd64,x86}-generic-full` works
TEST=`./build_packages --help` shows correct default

Change-Id: I8d6ccb83babb2764a50692318eb9193c45fb3b39
Reviewed-on: https://gerrit.chromium.org/gerrit/17868
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-08-14 10:17:31 -07:00
David James
359d3e119d Simplify boilerplate common.sh code in src/scripts.
Currently, the scripts in src/scripts have multiple implementations
for handling when common.sh fails to load, some of which are buggy.
To simplify the boilerplate, these scripts now just exit if common.sh
fails to load. The shell itself will print the following message if
common.sh is not found:
  /usr/lib/crosutils/common.sh: No such file or directory

BUG=chromium-os:32442
TEST=Run these scripts with and without common.sh installed.

Change-Id: Ie54420b6c649774f9cb039c14c80f4cf6c6ebc07
Reviewed-on: https://gerrit.chromium.org/gerrit/27058
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
Commit-Ready: David James <davidjames@chromium.org>
2012-07-12 10:55:37 -07:00
David James
c9ca3dbb0e Revert gvfs hacks to known-good state.
Originally, I patched enter_chroot.sh to stop the gvfs daemons to work
around an issue where these daemons would prevent loop devices from being
unmounted. See https://bugzilla.gnome.org/show_bug.cgi?id=677648

Unfortunately, temporarily stopping gvfs daemons has a bad side effects:
other GUI applications that rely on these daemons responding start hanging.
This can be reproduced, for example, by starting 'gedit'.

To fix these hangs, I'm just reverting my patches to enter_chroot.sh and
restoring the scripts to where they were before.

This reverts the following patches:
  1. Stop gvfs daemons earlier during enter_chroot.
     This reverts commit 0079158f73.
  2. Revert "Stop the gvfsd-trash daemon during enter_chroot."
     This reverts commit 654a00bd61.
  3. Revert "Stop the automounting daemon whenever we're inside the chroot."
     This reverts commit fae0a59e8b.
  4. Revert "Clean up update_bootloaders.sh to avoid sleeping."
     This reverts commit 0103b59138.

BUG=chromium-os:23443
TEST=Trybot run.

Change-Id: Ie9ff222fe5fc7232fd1fc39af129cc18531118c6
Reviewed-on: https://gerrit.chromium.org/gerrit/26922
Reviewed-by: Chris Wolfe <cwolfe@chromium.org>
Reviewed-by: Jon Kliegman <kliegs@chromium.org>
Reviewed-by: Brian Harring <ferringb@chromium.org>
Commit-Ready: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
2012-07-09 14:42:10 -07:00
David James
0103b59138 Clean up update_bootloaders.sh to avoid sleeping.
Right now update_bootloaders.sh occasionally sleeps for 5 seconds if the
developer machine has gvfs-gdu-volume-monitor installed. This sleep was
only necessary because the script pointlessly mounted the device and then
immediately unmounted it, thus triggering a race condition.

In this commit, I've removed the pointless mount/unmount, thus avoiding this
race. This removes the need for the sleep and for retrying the umount.

I also cleaned up the error checking so that failures to cleanup fail
the whole script now.

BUG=none
TEST=Run build_image.sh several times, verify it doesn't sleep for 5 seconds
     anymore. Also run remote trybot runs.

Change-Id: Iaa715e9644292f97356a341d17b147be2a5178d9
Reviewed-on: https://gerrit.chromium.org/gerrit/24632
Commit-Ready: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
2012-06-07 20:48:51 -07:00
Brian Harring
7f175a59e1 common.sh: output a backtrace and debug information on failure.
Currently, if set -e spots a nonzero exit we basically have
no real debug information- it just stops immediately without stating
where or why.  This forces our scripts to be stupidly verbose so
we can track roughly where they were, thus when they fail we can
use that information to localize the rough exit point.

Instead we should be traping that set -e induced exit and
outputing necessary debug information to run it down.  This includes
outputing the relevant stack trace, or at least what we can get of
it.

The 'die' function is now enhanced to automatically dump the trace
that lead to it.  For most consumers this is desired- however for
commandline parsing induced dies ("--board is missing" for example),
the trace is noise.  For those cases, a 'die_notrace' function was
added that retains the original non-backtrace behaviour.

Example output via instrumenting cros_generate_breakpad_symbols
w/ the failing command '/bin/false' (nonzero exit code).

Before:
./cros_generate_breakpad_symbols  monkeys --board=x86-alex
<no output at all, just exit code 1>

With this CL:
./cros_generate_breakpad_symbols  monkeys --board=x86-alex
ERROR   : script called: ./cros_generate_breakpad_symbols 'monkeys' '--board=x86-alex'
ERROR   : Backtrace:  (most recent call is last)
ERROR   :   file cros_generate_breakpad_symbols, line 207, called: main 'monkeys' '--board=x86-alex'
ERROR   :   file cros_generate_breakpad_symbols, line 163, called: die_err_trap '/bin/false' '1'
ERROR   :
ERROR   : Command failed:
ERROR   :   Command '/bin/false' exited with nonzero code: 1

BUG=chromium-os:30598
TEST=inject a failing command into a script, verify the output.
TEST=inject a 'command not found', verify the output
TEST=cbuildbot x86-generic-full --remote
TEST=cbuildbot arm-tegra2-full --remote
TEST=cbuildbot chromiumos-sdk --remote

Change-Id: I517ffde4d1bb7e2310a74f5a6455b53ba2dea86c
Reviewed-on: https://gerrit.chromium.org/gerrit/17225
Reviewed-by: Brian Harring <ferringb@chromium.org>
Tested-by: Brian Harring <ferringb@chromium.org>
Commit-Ready: Brian Harring <ferringb@chromium.org>
2012-05-07 17:19:41 -07:00
Brian Harring
aa13ea4658 Shift crosutils scripts to use the common.sh they were written against.
Rather than trying to use an old/stale common.sh, use the common.sh
from the invocation point- if invoked via /usr/lib/crosutils, use that
common.sh.  If invoked via src/scripts/, use that, etc.

Trying to intermix it just introduces potential for bugs and invalidly
freezes common.sh api, thus the efforts to revert this and ultimately
revert the existing of a crosutils ebuild.

BUG=chromium-os:27201
TEST=cbuildbot x86-generic-full

Change-Id: I4c6c5fbade3d28c71752bd4c44dccad49af52ec0
Reviewed-on: https://gerrit.chromium.org/gerrit/18303
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Brian Harring <ferringb@chromium.org>
Tested-by: Brian Harring <ferringb@chromium.org>
2012-03-15 23:35:06 -07:00
Olof Johansson
296adf0720 Install kernels on partition 12 on arm
This is needed on some ARM boards where ext2 filesystem reading isn't an option,
and where verified boot isn't in use, i.e. with legacy firmware. x86 stores the
kernel here as well.

BUG=none
TEST=build_image on an arm board and check contents for vmlinuz.A and vmlinuz.uimg.A on
partition 12

Change-Id: I89b652cb6ea7ece1627b20be30492100f8db0770
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/13441
2011-12-23 08:49:04 -08:00
Olof Johansson
ffe3b85392 Revert "Install kernels on partition 12 on arm"
This reverts commit 1d20fe6813b991899900aaa4f92b965a8f0b511d

Change-Id: I2d07c4c16e56841e397ee62d0371c5edc85c8364
Reviewed-on: https://gerrit.chromium.org/gerrit/13439
Commit-Ready: Olof Johansson <olofj@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Ryan Cui <rcui@chromium.org>
Tested-by: Ryan Cui <rcui@chromium.org>
2011-12-22 15:00:14 -08:00
Olof Johansson
2c994ad1ca Install kernels on partition 12 on arm
This is needed on some ARM boards where ext2 filesystem reading isn't an option,
and where verified boot isn't in use, i.e. with legacy firmware. x86 stores the
kernel here as well.

BUG=none
TEST=build_image on an arm board and check contents for vmlinuz.A and vmlinuz.uimg.A on
partition 12
CQ-DEPEND=I81df8471fba34e264ada8fd6f12122d87fbf22d9

Change-Id: I39541644845dde4ff6ddc288afa0ed339ab0d05b
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/12996
2011-12-22 14:08:48 -08:00
Jonathan Kliegman
ae6baa2ea7 Add retry to update_bootloaders.sh cleanup function
Race conditions could prevent /tmp/esp.* from being properly unmounted
if it was quickly mounted then unmounted.  If the umount fails,
sleep briefly and then retry.

BUG=chromium-os:23442,chromium-os:23443
TEST=Ran build_image --test, saw umount failure but after script finished
  saw that directory was unmounted on second attempt so no leakage

Change-Id: I5b2260f5c99fcfa66027ebcfd69b6e3d5afe4b91
Reviewed-on: https://gerrit.chromium.org/gerrit/12115
Tested-by: Jon Kliegman <kliegs@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Jon Kliegman <kliegs@chromium.org>
2011-11-28 09:07:48 -08:00
Sonny Rao
3163cf0605 Change script style for ARCH comparisons to double-bracket bash style
BUG=none
TEST=test setup_board, build_packages, build_image, image_to_vm,
on x86-generic and amd64-generic

Change-Id: I43d9d8e6e0e48cbce4d0086b78721ed86b120d4a
Reviewed-on: http://gerrit.chromium.org/gerrit/10209
Reviewed-by: Vince Laviano <vlaviano@chromium.org>
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
2011-10-17 17:53:48 -07:00
Sonny Rao
1261bc5886 fix up bootloader related scripts to treat amd64 like x86
BUG=chromium-os:21739
TEST=manually verify syslinux is being properly installed on
amd64-generic

Change-Id: I780fba2b9e90a8cf3922b48723f29d96eaf3931e
Reviewed-on: http://gerrit.chromium.org/gerrit/10168
Reviewed-by: David James <davidjames@chromium.org>
Reviewed-by: Vince Laviano <vlaviano@chromium.org>
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
2011-10-17 14:00:54 -07:00
Elly Jones
dfd369431d update_bootloaders: use uuids for legacy boot.
BUG=chromium-os:14127,chromium-os:17184
TEST=Adhoc
Build a regular image (for Alex) and boot it on a Dogfood machine (which uses
legacy boot). Check dmesg for PARTUUID. Unpack partitions, mount partition 12,
and check for root=PARTUUID= in /efi/grub/grub.cfg (it should be there instead
of root=/dev/$linuxpart).

Change-Id: Ie403632f227d514a5876f8338afa4ad80708ed55
Signed-off-by: Elly Jones <ellyjones@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/5668
Reviewed-by: Will Drewry <wad@chromium.org>
2011-08-11 13:57:49 -07:00
Brian Harring
d5d5dbffa1 Fix/standardize exiting if common.sh can't be found
The problem here is that most were doing their exiting w/in a subshell;
exit within a subshell kills the subshell, not the parent.  Not all scripts
were using set -e (which would pick up the failing subshell); as such
just rewriting them to remove the potential via eliminateing the subshelling.

Beyond that, removed a couple of custom (working, although non-standard)
approaches, and removed a duplicate common.sh sourc'ing w/in mk_memento_images.sh

TEST=force 'find_common_sh' to fail, note the scripts fails to exit
BUG=none

Change-Id: Ia1108a091a6399ad6aedd3cade4a107f4411686c
Reviewed-on: http://gerrit.chromium.org/gerrit/3905
Reviewed-by: Brian Harring <ferringb@chromium.org>
Tested-by: Brian Harring <ferringb@chromium.org>
2011-07-22 12:06:59 -07:00
David James
8b9643f7d8 Fix losetup race condition.
The following pattern creates a race condition:

   LOOP_DEV=$(sudo losetup -f)
   ...
   sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}"

If two steps similar to the above run in parallel, and both steps pick up
the same free loop device, they may try to mount different images with the
same loop device and one of the two stages will get a "device is busy" error.

To fix this, we should switch to the following pattern:
   LOOP_DEV=$(sudo losetup --show -f "${ROOT_FS_IMG}")

This CL implements the above.`

BUG=chromium-os:18046
TEST=Run buildbot run. Test case where we run out of loop devices and verify
     logic still works.

Change-Id: Ie457701fda61e5fc3b9112c1bfef9fb9713ea265
Reviewed-on: http://gerrit.chromium.org/gerrit/4555
Tested-by: David James <davidjames@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
2011-07-22 00:02:53 -07:00
Arkaitz Ruiz Alvarez
e2f33fb50a Fix cros_debug not being passed to VMs
When building a VM or USB-run image the boot args come from a preset template
which does not include the cros_debug flag. If this flag is present we maintain
it in this new boot configuration. The way we do it is by replacing the string
"cros_legacy" (which originates with the template) with
"cros_legacy cros_debug".

TEST=Build VM from a developer and test image and check grep "cros_debug"
/proc/cmdline.
BUG=chromium-os:17392

Change-Id: I2cb578274cf9596bf863ec835b1c921fff252a04
Reviewed-on: http://gerrit.chromium.org/gerrit/3808
Reviewed-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Tested-by: Arkaitz Ruiz Alvarez <arkaitzr@chromium.org>
2011-07-11 17:15:41 -07:00
Che-Liang Chiou
d7d79fed66 Revert "Install VbNvContext storage file"
This reverts commit dc2cb4b8f6.

This commit is reverted because it is not needed.

R=rongchang@chromium.org
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6882115

Change-Id: If21b788986c878c5d0e3e29487b6d58b86532775
2011-04-22 15:55:53 +08:00
Che-Liang Chiou
dc2cb4b8f6 Install VbNvContext storage file
R=rongchang@chromium.org
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6883046

Change-Id: I8818938f9e40120c0e88d80a9452641518a6ba44
2011-04-20 15:08:48 +08:00
Will Drewry
b910de849c kernel build: use %U+1 for dm-verity booting
Using %U+1 will ensure that we avoid device enumeration issues during recovery mode
boots.

TEST=build_image+dev recovery kernel and boot to it on new cros fw / fixed enumeration problem
         used build with mp recovery kernel on cr-48 -> installed then booted fine
         used dev recovery kernel on a legacy machine; installed fine, booted fine
         tested with cr-48, mp recovery kernel, and noenable_rootfs_verification to ensure /dev/sd%D%P still worked as normal.

Change-Id: I5b1277a47536738a78c18988fd912cc05ebddd4b

BUG=chromium-os:5470

Review URL: http://codereview.chromium.org/6549034
2011-02-23 13:26:50 -06:00
Greg Spencer
798d75f3be This starts to fix the scripts so that they load from /usr/lib/crosutils
from within the chroot.

It also fixes a number of style issues.

It changes the meaning of cros_workon "list-all" to list all available
packages, and adds "list-live" to list all live packages.

It changes things that load chromeos-common.sh from the installer to
load it from /usr/lib/installer.

BUG=chromium-os:4230
TEST=synced, rebuilt chroot, made packages, made images, built chrome
from source, and wrote an image to a USB stick.

Review URL: http://codereview.chromium.org/6240018

Change-Id: I90c34420af1a64020402bafef8e9e77f56837c02
2011-02-01 22:04:49 -08:00
Hung-Te Lin
df4fc212a8 crosutils: fix "umount: /tmp/XXX: not mounted" in build_image
The update_bootloaders needs to unmount file system first for syslinux to
manipulate the raw device file, but the real "umount+losetup -d" in
cleanup stage would cause failure.

This CL remounts partition again so that cleanup can be executed
successfully.

BUG=chromium-os:9278
TEST=Manually executed ./build_image;
 Before fix: seeing "umount: /tmp/esp.2q8fSn: not mounted" in last page.
 After fix: no such error.
 The output image is verified to be bootable successfully.

Change-Id: I19e2e062ad814e7bcd54777b5c3cee31f2b92e81

Review URL: http://codereview.chromium.org/5165001
2010-11-18 17:27:17 +08:00
Kenneth Waters
e3049de00f build_image: Merge x86 and ARM where possible.
- I looked at all of the x86 and ARM paths through out build image scripts,
  these changes clean up stale comments, stale code, and unforks some small
  things.

BUG=none
TEST=Built images for x86-generic, arm-generic and tegra2-seaboard, booted tegra2-seaboard image.

Review URL: http://codereview.chromium.org/3448022

Change-Id: Ibad2774ff2cbf5f15528454506542b87e43e24a2
2010-09-30 14:20:34 -07:00
Kenneth Waters
ed54d93e2c build_image: Add verity support for ARM.
- Build a "kernel image" which contains a uboot script and a uboot kernel
  image.
- Fix some sd* assumptions.
- Remove cruft that has never done anything usefull from update_bootloaders

BUG=none
TEST=Built, booted, and updated on tegra2_dev-board

Review URL: http://codereview.chromium.org/3396011

Change-Id: I00ecf57faa5fe64c8e33dd4c042f1dbed806c10a
2010-09-21 10:29:54 -07:00
Kenneth Waters
cb39f9929b update_bootloaders.sh: Fix arm-generic build.
BUG=None
TEST=Passes bash -n

Review URL: http://codereview.chromium.org/3161029
2010-08-18 14:35:22 -07:00
Kenneth Waters
eca76464c7 make_image: Install u-boot scripts to ESP partition.
BUG=1150
TEST=Built image for tegra2_dev_board, and x86-generic

Review URL: http://codereview.chromium.org/3109018
2010-08-18 11:17:01 -07:00
Will Drewry
78992a33f4 build_image, build_kernel_image, update_bootloaders: fix up rootfs_verification
This change adds
- --rootfs_hash_pad to specify the MBs reserved for the pad
- the implementation of the above flag
- check if total fs size + pad size exceeds the partition size
- hash appending in make_image_bootable()

Fixes:
- a style for ROOT_FS_HASH usage
- bad mount|grep
- bad bash subst for root devices in all boot paths
- fixed a typo in the update_bootloaders table creation
- disables verified usb for now

Adding the padding argument ensures that the generated hash tree for the root filesystem is appended to the image.  Assuming the rootfs is _never_ mounted read-write
again, that hash tree will be valid and vboot will be able to proceed.

BUG=chromium-os:2693
TEST=manual build_image

Review URL: http://codereview.chromium.org/3043011

Change-Id: I67d9b0f91cacdefa309c0cc2dd7fed1d2eddd7a7
2010-07-21 14:02:20 -05:00
Will Drewry
721d94f429 build_image,update_bootloaders: directly update the built image
Instead of playing mount and loop device games, this change adds support for
update_bootloaders.sh to directly update the EFI system partition living in the
image if a file, offset, and size is supplied.

TEST=build_image for x86-generic; booted resulting image
BUG=broken build

Change-Id: I3d891fd965df6fb4abfc63d660e314c497a4184d

Review URL: http://codereview.chromium.org/3006006
2010-07-16 14:39:45 -05:00
Will Drewry
ce2caf47e4 TBR: fix up arm portion of update_bootloaders
Removed two errant locals in the arm section

TEST=manual build_image on tegra1-dev-board
BUG=none
TBR=fes
2010-07-03 19:09:09 -07:00
Will Drewry
82780e5c37 TBR: clean up arm
Right now, the created arm.mbr is the size of the ESP
partition. It should be truncated though to just the mbr size.

In addition, dm= doesnt do anything on arm yet so replacing use with a todo and adding a check if it isn't there.

TEST=manually ran
BUG=none
TBR=fes
2010-07-03 18:27:10 -07:00
Will Drewry
d3c938b85d [PATCH 4/5] update_bootloaders.sh, create_esp.sh: add two helpers
Adds two helpers that are not used yet.  They will be
used in the next CL to unify the bootloaders in use
in build_image.

TEST=used in the next CL but otherwise not called.
BUG=chromium-os:327

Review URL: http://codereview.chromium.org/2829039
2010-07-03 13:32:26 -05:00