mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-05 04:06:33 +02:00
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
This commit is contained in:
parent
18ff72b913
commit
6d0ca16277
@ -22,6 +22,8 @@ DEFINE_string trunk "$GCLIENT_ROOT" \
|
||||
"The source trunk to bind mount within the chroot." "s"
|
||||
DEFINE_string build_number "" \
|
||||
"The build-bot build number (when called by buildbot only)." "b"
|
||||
DEFINE_string chrome_root "" \
|
||||
"The root of your chrome browser source. Should contain a 'src' subdir."
|
||||
|
||||
DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release builds."
|
||||
DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts."
|
||||
@ -59,6 +61,9 @@ fi
|
||||
# TODO: replace shflags with something less error-prone, or contribute a fix.
|
||||
set -e
|
||||
|
||||
INNER_CHROME_ROOT="/home/$USER/chrome_root" # inside chroot
|
||||
CHROME_ROOT_CONFIG="/var/cache/chrome_root" # inside chroot
|
||||
|
||||
sudo chmod 0777 "$FLAGS_chroot/var/lock"
|
||||
|
||||
LOCKFILE="$FLAGS_chroot/var/lock/enter_chroot"
|
||||
@ -88,6 +93,26 @@ function setup_env {
|
||||
then
|
||||
sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH"
|
||||
fi
|
||||
|
||||
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_CHROME_ROOT}")"
|
||||
if [ -z "$(mount | grep -F "on $MOUNTED_PATH")" ]
|
||||
then
|
||||
CHROME_ROOT="$FLAGS_chrome_root"
|
||||
if [ -z "$CHROME_ROOT" ]; then
|
||||
! CHROME_ROOT="$(cat "${FLAGS_chroot}${CHROME_ROOT_CONFIG}" \
|
||||
2>/dev/null)"
|
||||
fi
|
||||
if [[ ( -z "$CHROME_ROOT" ) || ( ! -d "${CHROME_ROOT}/src" ) ]]; then
|
||||
echo "Not mounting chrome source"
|
||||
sudo rm -f "${FLAGS_chroot}${CHROME_ROOT_CONFIG}"
|
||||
else
|
||||
echo "Mounting chrome source at: $INNER_CHROME_ROOT"
|
||||
echo "$CHROME_ROOT" | \
|
||||
sudo dd of="${FLAGS_chroot}${CHROME_ROOT_CONFIG}"
|
||||
mkdir -p "$MOUNTED_PATH"
|
||||
sudo mount --bind "$CHROME_ROOT" "$MOUNTED_PATH"
|
||||
fi
|
||||
fi
|
||||
) 200>>"$LOCKFILE"
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user