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>
To avoid needing to migrate fresh dev images's /var contents when
using the encrypted partition, move the /var bits out of the old
stateful_partition/var location into stateful_partition/var_overlay.
The (initially empty) system /var will continue to either live
in stateful_partition/var (in the unencrypted case), or in
stateful_partition/encrypted/var (in the encrypted case).
The contents needed for gmerge will be symlinked into place at runtime
(via CL I6e68b1f334f5d5b3c4d2977008435bd929191ce7). While the installer
already makes sure that /var is not shipped on an image, this change
additionally make sure that the other contents installed by the ebuilds
will not show up in the actual /var either.
BUG=chromium-os:22172
TEST=link build, boot, install, manual testing.
Change-Id: Ie6480a59929818fe5d36a46abf533b648fb78850
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26355
Reviewed-by: Chris Sosa <sosa@chromium.org>
The "function" keyword is superfluous, not in POSIX, is inconsistent
between bash files, and generally makes me angry. So convert every
instance to the form:
foo() {
BUG=None
TEST=`cbuildbot x86-generic-paladin` works
Change-Id: I97f5ca30a3edfef7222b1e08ac23917dc613b556
Reviewed-on: https://gerrit.chromium.org/gerrit/22467
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
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>
Currently if you use -m and -i chromiumos_test_image.bin, you get an error
saying that -i and --from=<block_device> are incompatible. -m
changes --from to the most recent folder but does this after the check so
this is broken. This change re-orders the calls to fix this bug.
BUG=None
TEST=Ran it with args that were broken.
Change-Id: I367a74f7b77f127b6ad8eeeb92ab72ae00e5235e
Reviewed-on: https://gerrit.chromium.org/gerrit/17760
Commit-Ready: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
The -d option to umount is unnecessary in cases where the original
mount was created with '-o loop' (it says so in the man page).
Moreover, there's a demonstrable bug when using 'umount -d' in this
case: umount complains that it's unable to delete the loop device
in this case. This change silences those messages.
The demonstrated bug in umount is a plausible explanation for build
failures characterized by unexpected failures of 'mount -o loop';
see the BUG, below.
BUG=chromium-os:24975
TEST=run the changed commands, see no loopback devices leaked
Change-Id: I1df9f60b40eabd279164b79ee66994ff9f644ee9
Reviewed-on: https://gerrit.chromium.org/gerrit/15998
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
We have helper funcs already for displaying messages, so convert
some raw `echo` calls to them.
BUG=None
TEST=build_image still works and boots
Change-Id: Ie66cc59d0362ef6aa19011fa6cb0bc64a6a4fce8
Reviewed-on: https://gerrit.chromium.org/gerrit/14478
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Buildbots are periodically failing to build images; the evidence
points to failures in mount_gpt_image.sh, but it's inconclusive.
Add detailed error messages to mount failures so as to be able
to debug more the next time it happens.
BUG=chromium-os:24975
TEST=build_image, to see that successful cases still work
TEST=repeatedly mount new images with mount_gpt_image until it fails
Change-Id: I711fb0dec62dbab3817a62895b53e14376702544
Reviewed-on: https://gerrit.chromium.org/gerrit/14410
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Change helper invocation to use discovered script path so image_to_vm.sh
and mount_gpt_image.sh can be run outside of ~/trunk/src/scripts.
Additionally, minimize SCRIPT_ROOT boilerplate to not potentially mix
execution locations, as suggested by David James.
BUG=None
TEST=Built images from outside of ~/trunk/src/scripts
Change-Id: I4851cc74e7da8e08b4e7be79651fb41ce8868aed
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/10241
Reviewed-by: David James <davidjames@chromium.org>
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>
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
Change-Id: Ib9b6b9ba7787fba337e71e4968a5c152b5a21e14
BUG=chromiumos:8885
TEST=Ran with default options and setting --rootfs_mountpt and stateful_mountpt
to dirs in my current workig directory ... saw cleanup correctly on unmount
Review URL: http://codereview.chromium.org/4853001
This is being remounted ro in cros_make_image_bootable so I should be checking
for the stateful mount pt not the rootfs mountpt
Change-Id: I1ee64489516fae10a6246c5d79236c8b5df090ee
BUG=8116
TEST=Ran it and ran bin/cros_start vm and inspected /usr/local
Review URL: http://codereview.chromium.org/4148013
Right now we're not fixing symlinks because mount_gpt_image thinks it's mounted ro.
Change-Id: Ie61536cd8d7bc276831c488e7ab892db14b05a94
BUG=8116
TEST=Mounted image from device and locally with both rw, and ro options.
Review URL: http://codereview.chromium.org/4048006
This change makes more of the root filesyste metadata static across builds, but
more can be done there. It also changes the root filesystem to use ext2 as
we don't need journaling in normal mode. Optionally we could use ext3 for
non-verified if desired (it's an easy change).
In particular, this change cleans up the following:
- clears the rootfs uuid
- labels it C-ROOT (instead of C-KEYFOB)
- removes reserved inodes and blocks
The major feature of this change, however, is that it adds two simple
helpers to common.sh: disable_rw_mount and enable_rw_mount. They will
set high order byte (le) in the ro compat field to be 0xff. This will
tell the kernel that the filesystem uses features R24-R31 which are safe
for use on the running kernel iff the filesystem is mounted read-only.
These functions are called in cros_make_image_bootable and
mount_gpt_image, respectively. mount_gpt_image will always
enable_rw_mount and cros_make_image_bootable will disable_rw_mount if
--enable_rootfs_verification is true.
The approach is ugly but reasonably well contained. If ext2 ever gets a
new revision and new features in the same range are introduced, then we
would be getting inconsistent behavior. That said, it is unlikely that
that churmn will happen and if the impact is negative, it will ideally
show up during testing.
N.B., this will likely result in changes needing to be made to the
signing scripts in vboot_reference to ensure that rw mounting is
enabled/disabled in the same way (E.g., during stamping).
BUG=chromium-os:7468
TEST=- built x86-generic, imaged to usb stick, attempted to mount rw /dev/sdc3 on the host and was properly bounced.
- booted to the image just fine on a dogfood device.
- mod'd for recovery, then installed and booted.
- mod_image_for_test runs with no errors; booted the resulting image as well
- booted a factory_install with the pending dm changes
- BVT passed with build_image x86-generic (vboot enabled)
- [in progress] autotest that checks if the rootdev = /dev/dm-0 and
then does a dumpe2fs | grep -q FEATURE_R31
Review URL: http://codereview.chromium.org/3916002
Change-Id: If4dcba7568a110f4e32627c916d9e5741e5e5414
Change-Id: I33ea8b2148a3e49a6c5de25f2957306130ff092e
BUG=
TEST=Ran and verified with and without flag. Checked mount and tried writing
file to rootfs (to verify it was ro). Also re-ran cros_make_image_bootable
to make sure it worked fine after changes.
Review URL: http://codereview.chromium.org/3479007
Missing check during mkdir causes failure with -e empty.
The tree broke prior to this commit, but this will break the dev
build so bypassing hooks. sorry.
TEST=reran build_image
BUG=none
TBR=adlr
Adds support for mounting the esp image.
In the future, all legacy boot loaders will live on
the ESP partition (#12) to avoid modifying the rootfs
partition with bootloader changes in the configuration or
preamble. This is needed.
TEST=manually reran mount_gpt_image.sh users.
BUG=chromium-os:327
Review URL: http://codereview.chromium.org/2811042
TEST=Tested with building a new image, looking in the output directory, running
the image and running vi.
Review URL: http://codereview.chromium.org/2075019
TEST=Tested build process. Tested dev image, test image and base image by booting all three and logging in.
Review URL: http://codereview.chromium.org/2106009
In addition unifies changes in mount_gpt_image and one-offs in mod_image_for_test
to consolidate gpt / var mounting.
Review URL: http://codereview.chromium.org/2064001