Commit Graph

58 Commits

Author SHA1 Message Date
Zdenek Behan
e28239d294 enter_chroot: introduce a sync process that synchronizes given files between chroot and host
Currently used for resolv.conf and hosts, because these files can
change during the lifetime of a chroot, for example on computers
with more dynamic network (laptops).

While this creates a persistent process in the background for the
sole purpose of syncing files, the performance impact is negligible.

BUG=12316
TEST=below
1) enter_chroot once+quit, many times + quit, verify correct exit
behaviour
2) enter_chroot, modify host resolv.conf, see chroot being updated

Change-Id: I26573570c027acc2c214a00838a6f982a7585b13

R=robotboy@chromium.org,dparker@chromium.org,sosa@chromium.org

Review URL: http://codereview.chromium.org/6720005
2011-04-07 00:37:20 +02:00
Liam McLoughlin
3b11b450ea Re-enable chroot passthru for AU server environment variable override
Change-Id: I9856fe64942d586281fee09dff15af9d8178b392

BUG=none
TEST=manual

Review URL: http://codereview.chromium.org/6633009
Patch from Liam McLoughlin <hexxeh@hexxeh.net>.
2011-03-14 16:04:07 -07:00
Chris Sosa
9d30ce80fa Ignore git config errors that may occur in enter_chroot.
git config doesn't behave well if there are multiple callers
calling it at the same time.  Since this is best effort anyway,
I'm adding an || true so that multithreads calls to this don't
fail.

I removed my previous work around to this since it wasn't generic enough.

Change-Id: I12f2d3faaa745c1ff675a297bb09c567a88aa185

BUG=chromium-os:13070
TEST=Ran it a lot

Review URL: http://codereview.chromium.org/6693001
2011-03-14 15:00:46 -07:00
Darin Petkov
47974d4216 Remove obsolete variable pass through.
BUG=chromium-os:12711
TEST=enter_chroot, build_package, build_image

Change-Id: I002ccdaba2c91421da22db2d5a52e82665eab6af

Review URL: http://codereview.chromium.org/6614027
2011-03-03 15:55:04 -08:00
Darin Petkov
87dd2be709 Remove obsolete CHROMEOS_REVISION setting in enter_chroot.
BUG=chromium-os:11647
TEST=enter_chroot, build_image

Change-Id: Ib97e27fd0e6292ec7504dbc4312254bc574ba171

Review URL: http://codereview.chromium.org/6598056
2011-03-01 09:25:09 -08:00
David Rochberg
33373ef899 Make mount points before attempting to mount on them
BUG=chromium-os:11944
TEST=the correct test for this is a complete rebuild; I have this running, but it's going to take a little while.  I have tested this on the specific cases of ssh_auth_sock and .subversion

Change-Id: I61723356c58bfb7c2090e950208b8a6ab8fa2fc9

Review URL: http://codereview.chromium.org/6519022
2011-02-16 14:48:27 -05:00
David Rochberg
351a76fc96 enter_chroot: Only mount SSH auth socket when we need to.
Also refactors some cut-and-paste code

Fix:  makes mountpoint for subversion directory

BUG=chromium-os:11944 chromium-os:12058
TEST=enter_chroot.sh with and without another enter_chroot running.  Note that there are 0 or 1 mounts of the /tmp/ssh-.... directory.  Check that /proc,/sys,/dev,$SSH_AUTH_SOCK,/dev/pts,/home/${USER}/trunk,/home/${USER}/.subversion are all mounted.   Test that subversion mountpoint is created

Change-Id: I9dada6f7f98d263345af29a5734c1c70709f6a1e

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

Review URL: http://codereview.chromium.org/6525020
2011-02-16 11:14:00 -05:00
David Rochberg
a821a8c856 Revert "enter_chroot: Only mount SSH auth socket when we need to."
This reverts commit 11753bf13442ce1da1488abb372940353f8844ff.

BUG=12058

Change-Id: I5175ea81dbf20cc3a4c290c750a7cc5c9841e3fa

TEST=

Review URL: http://codereview.chromium.org/6520012
2011-02-14 12:13:37 -05:00
David Rochberg
abaf1ccf15 enter_chroot: Only mount SSH auth socket when we need to.
Also refactors some cut-and-paste code

BUG=11944
TEST=enter_chroot.sh with and without another enter_chroot running.  Note that there are 0 or 1 mounts of the /tmp/ssh-.... directory.  Check that /proc,/sys,/dev,$SSH_AUTH_SOCK,/dev/pts,/home/${USER}/trunk,/home/${USER}/.subversion are all mounted

Change-Id: I9dada6f7f98d263345af29a5734c1c70709f6a1e

Review URL: http://codereview.chromium.org/6498001
2011-02-14 11:09:26 -05:00
Doug Anderson
ae573e7a6c Update chroot for chromite if needed.
Change-Id: I6593336a52b7298bd358f3e55531b2e6a9e6dff1

BUG=chromium-os:11883
TEST=Tried deleting the symlink and deleting the line from bashrc and things got updated; ran again w/ no problems.

Review URL: http://codereview.chromium.org/6480005
2011-02-11 12:09:02 -08:00
Don Garrett
a0e7ea185a Switch from v_info logging to debug
Change-Id: I9a3177bf295462d40a6e7045a2ffb793bbfe3166

BUG=chromium-os:11672
TEST=Manual

Review URL: http://codereview.chromium.org/6246148
2011-02-07 18:39:59 -08:00
Don Garrett
ad3f059401 Make enter_chroot not be chatty unless you use --verbose
Change-Id: I352ae16a248483da35575b5d74889b3d2e6683cc

BUG=chromium-os:11672
TEST=Ran manually.

Review URL: http://codereview.chromium.org/6250170
2011-02-04 14:59:56 -08:00
Doug Anderson
3d7fa3a0e9 Don't use sudo -v, which was having issues (hanging bots).
Change-Id: I5f76f0f27b5789d88740b36fa6ce696ef7e68e8a

BUG=chromium-os:11602
TEST=Tried steps in bug 11602 (but hacked a sudo -K to the start of teardown_env so I didn't need to wait 15 mins).

Review URL: http://codereview.chromium.org/6286069
2011-02-02 16:10:34 -08:00
Doug Anderson
a8d9cc18b0 Avoid problems where PW prompt in enter_chroot.sh would block other terminals.
Change-Id: Ibd32a4be12e88d183dd0acbcb156582ad946c92f

BUG=chromium-os:11602
TEST=Added a 'sudo -K' as the first line of teardown_env to simulate sudo timeout, then performed steps in bug report (without 15 minute wait).

Review URL: http://codereview.chromium.org/6250116
2011-02-02 15:47:00 -08: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
Chris Sosa
558940dddb Make git config optional to allow multiple calls to enter_chroot at the same time.
It's very rarely needed anyway but enter_chroot does everything under the sun.

Avoids:

error: could not lock config file ~/.gitconfig

Change-Id: Ide72b14fd434b182a88d2fc636559b3515905509

BUG=chromium-os:11523
TEST=Ran it ... 10x

Review URL: http://codereview.chromium.org/6312069
2011-02-01 13:07:55 -08:00
Zdenek Behan
75805716f5 enter_chroot: copy over ssh configuration
TEST=clean (first) enter_chroot.sh; repo sync

The developer instructions for setting up chroot include steps to set up
~/.ssh/config to correctly set up ports and options. And while several
attempts are made in enter_chroot to forward ssh-agent and ssh
authentication to chroot as well, the ssh config stays outside of
chroot, which prevents all attempts to contact the git servers if rw URL
is used.

This makes a copy of config on entering the chroot, allowing people to
use repo from within the chroot. That is not bulletproof and does not
reflect changes of config while inside the chroot, but that should be a
borderline case.

Change-Id: I1fcbf00c413c7af8ef14fc1e846192ac95de106d

BUG=n0ne

Review URL: http://codereview.chromium.org/6065011
2011-01-05 00:56:32 +01:00
Doug Anderson
9362fa85c7 Allow specifying environment variables w/ enter_chroot again.
Examples of how people might be using enter_chroot:

1. ./enter_chroot [chroot_flags]   VAR1=val1 VAR2=val2 -- cmd arg1 arg2
   Set env vars and run cmd w/ args
2. ./enter_chroot [chroot_flags]   VAR1=val1 VAR2=val2
   Set env vars and run shell
3. ./enter_chroot [chroot_flags]   -- cmd arg1 arg2
   Run cmd w/ args
4. ./enter_chroot [chroot_flags]   VAR1=val1 VAR2=val2 cmd arg1 arg2
   Like #1 _if_ args aren't flags (if they are, enter_chroot will claim them)
5. ./enter_chroot [chroot_flags]   cmd arg1 arg2
   Like #3 _if_ args aren't flags (if they are, enter_chroot will claim them)

I also updated the help to indicate that whole-command quoting is no longer
supported.  If you really need whole-command quoting (maybe you want in-
chroot redirection), you'll need to use sh -c like:
  ./enter_chroot.sh -- sh -c "echo \"Save me\" > /tmp/save.txt"

You should avoid single quotes in the command and arguments.  This isn't
a new limitation: it's shflags related.

Change-Id: I0452a8730ac9b8197834edc753b9eece69896135

BUG=chromium-os:7072
TEST=Tried a whole bunch of these commands.

Review URL: http://codereview.chromium.org/5840003
2010-12-16 14:44:12 -08:00
hexxeh
72d0b08d92 Added option to set ChromeOS version name, track and AU/dev server URLs via environment variables
Change-Id: I80914aa49e74edf71914aa93f310104210581ffd

BUG=none
TEST=Ran a x86-generic build and tested from USB drive

Committed: http://chrome-svn/viewvc/chromeos?view=rev&revision=4a0a239

Review URL: http://codereview.chromium.org/5760004
Patch from hexxeh <hexxeh@hexxeh.net>.
2010-12-15 13:17:37 -08:00
Raja Aluri
8f2a9950b9 passing CHROMEOS_RELEASE_APPID to the PASSTHRU list into chroot
Change-Id: Ib5296eb4d3eea6d2430cde04d855ccbefd507bf4

BUG=
TEST=

Review URL: http://codereview.chromium.org/5132002
2010-11-17 15:03:00 -08:00
Raja Aluri
e891eea06f passing CHROMEOS_RELEASE_APPID to the PASSTHRU list into chroot
Change-Id: I906f1959769ac9d7a2abc04827cad8f5201984de

BUG=chromeos:9168
TEST=Made sure that setting and unsetting this value and enter_chroot is honoring the pass thru setting.

Review URL: http://codereview.chromium.org/5008006
2010-11-16 20:12:56 -08:00
Doug Anderson
0c9e88de6c Added a function to update chroot sudoers automatically.
This function is now called by enter_chroot.sh.  A separate change
will call the function from make_chroot

Change-Id: I4fc07c413e56db3e5e7617428f20f2ffc02790d7

BUG=chromium-os:7072
TEST=Took root out of sudoers and ran enter_chroot.sh script; saw that it was re-added.

Review URL: http://codereview.chromium.org/3909001
2010-10-19 14:49:39 -07:00
David Rochberg
c1a3e56e23 Fix enter_chroot.sh so that it can be run from a cwd that is not in a git repository
BUG=none
TEST=run from within and without a repo

Change-Id: I00eb999974656450f6af24583ca2247805b5799e

Review URL: http://codereview.chromium.org/3529005
2010-10-04 09:44:57 -04:00
David James
0fd8af4a9b Configure git author name and git author email in .gitconfig.
If git author name is different in the chroot from outside the chroot, repo
may auto-delete your changes when you run repo sync. These changes can be
recovered, but their deletion is inconvenient.

BUG=chromium-os:5934
TEST=Check that git var GIT_COMMITTER_IDENT is now correct inside chroot.

Change-Id: I622cd37caa404a7482c55c4b3984877b32b3807c

Review URL: http://codereview.chromium.org/3352008
2010-09-27 10:04:57 -07:00
Sean O
cd8b1d1729 Use correct log functions for enter_chroot's console spew.
Change-Id: Ie0e05626e3619584d565ff3414f1d1b073c7fc7f

BUG=
TEST=Manually

Review URL: http://codereview.chromium.org/3318005
2010-09-02 17:34:49 +02:00
Sean O
7aace25881 Keep enter_chroot log spew on stderr.
Change-Id: I75d4a90ea703176e5773083ddec7bc687e35837f

BUG=
TEST=tested locally

Review URL: http://codereview.chromium.org/3254012
2010-09-02 15:35:54 +02:00
Elly Jones
7990a0673c scripts: bind ~/.ssh over the chroot's ~/.ssh.
This also mounts the path to our ssh-agent socket (usually in /tmp) inside the
chroot so we can use our external agent.

TEST=None

BUG=None

Change-Id: I543e8b2527be9958c1158234f39ecc34fc9dd0df
Signed-Off-By: Elly Jones <ellyjones@chromium.org>
Signed-Off-By: sosa <sosa@chromium.org>

Review URL: http://codereview.chromium.org/3277006
2010-09-02 09:23:23 -04:00
Raja Aluri
32759cfe68 Copying .subversion directory into the chroot,
so that the original users' subversion access permissions are preserved inside the chroot

Change-Id: I486070b3c1a2dda169ae0a95982ba693574e001b

BUG=
TEST=

Review URL: http://codereview.chromium.org/3249008
2010-08-30 18:44:39 -07:00
Sean O'Connor
d52c5ea1bc Make enter_chroot spew logs to stderr.
It's sometimes useful to run a command in chroot and redirect/pipe stdout. Any objections to having enter_chroot send its chatter to stderr?

Review URL: http://codereview.chromium.org/3160024
2010-08-18 21:18:23 +02:00
Allen Martin
07bfc7aa9d Separate out additional cmd line args to chroot
This fix separates out any additional command line arguments given to
the enter_chroot.sh script when passed to the interior chroot.  This
allows one to pass environment variable settings to the interior
chroot shell such as:

./enter_chroot.sh -- CHROME_ORIGIN=LOCAL_SOURCE emerge-x86-generic ...

Before this fix any of these variable settings will be sucked up by
the shell launching the chroot, not the interior shell.

BUG=chromium-os:2457
TEST=ran test cases detailed in bug report

Review URL: http://codereview.chromium.org/2855034
2010-07-13 15:44:59 -07:00
Zdenek Behan
6f17b5e5fe enter_chroot: when preparing chroot, mount devpts filesystem as well
* This also adds reverse sort into the umount list, because of cascading mounts, so that /foo/anything is always before /foo, and as such is always unmounted first. If the list were not sorted, "mount point busy" errors might occur, depending on various conditions.

TEST=
 1) With a previously created chroot, I ran enter_chroot.sh, and got the correct prompt. After logging out of that prompt, everything else was correctly unmounted, without any error messages. When entering chroot twice from two different shells, everything was correctly unmounted after the last shell exited.
 2) Repeat 1 but with cleanly created chroot just for this purpose.
 3) In the chroot, make packages for one board (x86-generic) using build_packages
 4) The messages "openpty failed: 'out of pty devices'" whenever trying to emerge anything (or other commands looking up pts) have disappeared.

Review URL: http://codereview.chromium.org/2714010
2010-06-10 16:50:52 -07:00
Anush Elangovan
587d7498a1 Use git rev-parse --short=8 to get rev
Change-Id: I842fd7c76597a3cadacdfaa3de6b61fa7cb87703

Review URL: http://codereview.chromium.org/2762011
2010-06-10 15:39:19 -07:00
Sean Parent
2898f75335 ACCESS DENIED workaround
Added chrome_root_mount option to specify the mount point to work around a permissions issue.

BUG=3464
TEST=none

Review URL: http://codereview.chromium.org/2126011
2010-05-25 15:06:33 -07:00
Chris Masone
162f654c95 disable automounting when inside the chroot
Unfortunately, bind mounting /media inside the chroot did not allow us
to programmatically unmount automounted USB sticks from within the chroot.
Instead, I disable automounting on our corporate desktops when you enter the
chroot.  Your normal setting is restored when you exit the chroot again.

TEST=run gconftool-2 -g /apps/nautilus/preferences/media_automount to print the current value of your automount pref; run this before entering the chroot, outside the chroot while you've got some other terminal that's inside the chroot, and then after exiting the chroot.

Review URL: http://codereview.chromium.org/2029009
2010-05-12 14:58:37 -07:00
Chris Masone
99c6a289f4 add the ability to umount automounted devices from within the chroot
Talked to kmixter, and we felt that bindmounting the directory in
which the host os creates mount points for automounted external
devices is the cleanest solution to the inside/outside the chroot problem.
By doing this, image_to_usb can be run from inside the chroot without concern.
That means that (as far as I understand) the factory install flow can all be
done inside the chroot, as well as modding images for test and everything else.

Review URL: http://codereview.chromium.org/1991006
2010-05-11 09:20:00 -07:00
robotboy
152a1ab50d Add a bind mount of /dev to the chroot.
This is useful for various JTAG and fastboot based flashing of
targets.  It is also useful in that we will now have access to
USB card readers and mass storage devices inside the chroot.

BUG=None
TEST=Enter and exit the chroot cleanly.

Review URL: http://codereview.chromium.org/1711016
2010-04-26 14:07:27 -07:00
robotboy
9891221b6e Add a safe_unmount function and use it in enter_chroot.
The safe_unmount function first tries a regular unmount,  If that
fails it warns and tries a lazy unmount.  If the lazy unmount fails
it dies.

Both unmounts take the -d option in case the mount is a loop device.

BUG=None
TEST=Entered and exited multiple chroots

Review URL: http://codereview.chromium.org/1593021
2010-04-12 14:08:14 -07:00
Chris Sosa
317d8eb3fd Better handling of fuse in chroot
Review URL: http://codereview.chromium.org/1582011
2010-04-05 15:45:28 -07:00
Chris Sosa
c7b65a46b4 TBR: Forgot quote 2010-04-02 14:17:55 -07:00
Chris Sosa
6bc771a50b TBR: Sorry fix for build again 2010-04-02 14:15:53 -07:00
Chris Sosa
7138f0a79b TBR:Fix build. Shouldn't do fuse stuff if fuse isn't installed on host 2010-04-02 14:12:05 -07:00
Chris Sosa
aa1a7fd63d Adds gmergefs. A method of remoting to a target and pushing new
packages using emerge from the host

Review URL: http://codereview.chromium.org/1515011
2010-04-02 14:06:29 -07:00
Antoine Labour
e9e585f330 Add a --to option to build_image
That way we can directly build an image onto a usb stick/sd card without a separate step.
Also, add mounting of /sys into the chroot that is needed by build_gpt on a block device.

Review URL: http://codereview.chromium.org/1521012
2010-04-01 15:57:57 -07:00
David James
546747b982 Update enter_chroot.sh to exit with error messages when mount/unmount fails.
This is necessary for two reasons:
   1) It's nice to get an error message when mount/unmount fails
   2) set -e mode doesn't have any effect when you're in a subshell

Note that these mount/unmount failures do happen regularly in development,
so folks who depended on mount/umount failing silently will no longer be
able to rely on this and will have to kill the mounts manually.

Also fix subtle bugs in regexes for matching mount paths. (E.g. where the
regex for $HOME/chroot also matches $HOME/chroot2).

TEST=Tested mount/unmount with concurrently open shells.
     Tested mount/unmount when mount is being used by a process but the
     lock file does not reflect this.
BUG=none

Review URL: http://codereview.chromium.org/1211001
2010-03-23 15:19:43 -07:00
Chris Sosa
9ef57d996b Enter chroot can return an error code on cleanup. We make cleanup best effort
Review URL: http://codereview.chromium.org/1158006
2010-03-23 11:15:45 -07:00
Andrew de los Reyes
e8b6315eee enter_chroot: allow depot_tools to fail to mount
Review URL: http://codereview.chromium.org/601082
2010-02-16 14:18:34 -08:00
Andrew de los Reyes
c1e8d2728f enter_choot: fix breakage some people ran into
Review URL: http://codereview.chromium.org/593102
2010-02-13 12:39:21 -08:00
Andrew de los Reyes
2832fe84e1 enter chroot: permit chrome_root to contain symlink
Review URL: http://codereview.chromium.org/596108
2010-02-12 23:47:01 -08:00
Andrew de los Reyes
5d0248feb8 enter_chroot: bind mount depot_tools if present outside chroot.
Another CL is coming to automatically add depot_tools to the PATH
inside the chroot. It's in a different repo.

Review URL: http://codereview.chromium.org/605016
2010-02-12 16:12:31 -08:00
Andrew de los Reyes
6d0ca16277 Enter_chroot: Mount chrome browser source inside chroot.
If one passes --chrome_root=.../path/to/chrome_root/outside/chroot to
enter_chroot.sh once, enter_chroot will make a note inside the croot
and mount it on all subsequent calls to enter_chroot, even if the
argument is not passed again. If ever enter_chroot can't find the
proper dir, it deletes any stored note.

chrome_root must contain a "src" subdirectory.

Review URL: http://codereview.chromium.org/596102
2010-02-12 14:36:08 -08:00