mirror of
https://github.com/flatcar/scripts.git
synced 2025-12-10 20:01:36 +01:00
cros_sdk: optimize gconftool interaction
It doesn't make much sense to run gconftool when the default automount value is what we already want: false. So in this common case, skip the save/restore logic altogether since we aren't actually changing things. Further, we can merge the `which` check in by checking the exit status of the `gconftool` run. If it fails, the tool doesn't exist. BUG=None TEST=enable `set -x`; run `cros_sdk true`; see gconftool run once in common case Change-Id: I1c6aee945218a8a9df533d9ef207c750f909c252 Reviewed-on: http://gerrit.chromium.org/gerrit/7823 Commit-Ready: Mike Frysinger <vapier@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
d2631cd952
commit
da7be781c0
@ -282,16 +282,18 @@ function setup_env {
|
|||||||
# Turn off automounting of external media when we enter the
|
# Turn off automounting of external media when we enter the
|
||||||
# chroot; thus we don't have to worry about being able to unmount
|
# chroot; thus we don't have to worry about being able to unmount
|
||||||
# from inside.
|
# from inside.
|
||||||
if [ $(which gconftool-2 2>/dev/null) ]; then
|
if SAVED_PREF=$(gconftool-2 -g ${AUTOMOUNT_PREF} 2>/dev/null); then
|
||||||
gconftool-2 -g ${AUTOMOUNT_PREF} > \
|
if [ "${SAVED_PREF}" != "false" ]; then
|
||||||
"${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}"
|
if [ $(gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} false) ]; then
|
||||||
if [ $(gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} false) ]; then
|
warn "-- Note: USB sticks may be automounted by your host OS."
|
||||||
warn "-- Note: USB sticks may be automounted by your host OS."
|
warn "-- Note: If you plan to burn bootable media, you may need to"
|
||||||
warn "-- Note: If you plan to burn bootable media, you may need to"
|
warn "-- Note: unmount these devices manually, or run image_to_usb.sh"
|
||||||
warn "-- Note: unmount these devices manually, or run image_to_usb.sh"
|
warn "-- Note: outside the chroot."
|
||||||
warn "-- Note: outside the chroot."
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# Always write the temp file so we can read it when exiting
|
||||||
|
echo "${SAVED_PREF:-false}" > "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}"
|
||||||
|
|
||||||
if [ -d "$HOME/.subversion" ]; then
|
if [ -d "$HOME/.subversion" ]; then
|
||||||
TARGET="/home/${USER}/.subversion"
|
TARGET="/home/${USER}/.subversion"
|
||||||
@ -377,8 +379,8 @@ function teardown_env {
|
|||||||
# Remove any dups from lock file while installing new one
|
# Remove any dups from lock file while installing new one
|
||||||
sort -n "$TMP_LOCKFILE" | uniq > "$LOCKFILE"
|
sort -n "$TMP_LOCKFILE" | uniq > "$LOCKFILE"
|
||||||
|
|
||||||
if [ $(which gconftool-2 2>/dev/null) ]; then
|
SAVED_PREF=$(<"${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}")
|
||||||
SAVED_PREF=$(cat "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}")
|
if [ "${SAVED_PREF}" != "false" ]; then
|
||||||
gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} ${SAVED_PREF} || \
|
gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} ${SAVED_PREF} || \
|
||||||
warn "could not re-set your automount preference."
|
warn "could not re-set your automount preference."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user