Skip to content

Commit

Permalink
Add 'quick-check' option to install-build-deps.sh
Browse files Browse the repository at this point in the history
This is a lightweight check to alert developers when their build
dependencies are out-of-date, and hopefully avoid confusing compile
errors. It takes < 1 second to run, so can be checked whenever sources
are synced, and might even by worth including as a default step in
gyp_chromium or DEPS hooks.

By definition, this is not a complete check, and in particular, will not
detect version updates of installed dependencies. It's mostly intended
to detect when entirely new dependencies have been added.

R=markus@chromium.org, sky@chromium.org

Review URL: https://codereview.chromium.org/40603004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231030 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mmoss@chromium.org committed Oct 25, 2013
1 parent f823dc3 commit ba48c4c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 12 deletions.
68 changes: 56 additions & 12 deletions build/install-build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ usage() {
echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\
"fonts"
echo "--no-prompt: silently select standard options/defaults"
echo "--quick-check: quickly try to determine if dependencies are installed"
echo " (this avoids interactive prompts and sudo commands,"
echo " so might not be 100% accurate)"
echo "--unsupported: attempt installation even on unsupported systems"
echo "Script will prompt interactively if options not given."
exit 1
}
Expand All @@ -41,6 +45,7 @@ do
--no-prompt) do_default=1
do_quietly="-qq --assume-yes"
;;
--quick-check) do_quick_check=1;;
--unsupported) do_unsupported=1;;
*) usage;;
esac
Expand All @@ -55,7 +60,7 @@ ubuntu_issue="Ubuntu ($ubuntu_versions|$ubuntu_codenames)"
# they're doing.
gcel_issue="^GCEL"

if [ 0 -eq "${do_unsupported-0}" ] ; then
if [ 0 -eq "${do_unsupported-0}" ] && [ 0 -eq "${do_quick_check-0}" ] ; then
if ! egrep -q "($ubuntu_issue|$gcel_issue)" /etc/issue; then
echo "ERROR: Only Ubuntu 12.04 (precise) through 13.04 (raring) are"\
"currently supported" >&2
Expand All @@ -68,14 +73,14 @@ if [ 0 -eq "${do_unsupported-0}" ] ; then
fi
fi

if [ "x$(id -u)" != x0 ]; then
if [ "x$(id -u)" != x0 ] && [ 0 -eq "${do_quick_check-0}" ]; then
echo "Running as non-root user."
echo "You might have to enter your password one or more times for 'sudo'."
echo
fi

# Packages needed for chromeos only
chromeos_dev_list="libbluetooth-dev libbrlapi-dev"
chromeos_dev_list="libbluetooth-dev"

# Packages need for development
dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
Expand All @@ -100,7 +105,7 @@ if [ "$(uname -m)" = "x86_64" ]; then
fi

# Run-time libraries required by chromeos only
chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
chromeos_lib_list="libpulse0 libbz2-1.0"

# Full list of required run-time libraries
lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libexpat1
Expand Down Expand Up @@ -203,7 +208,7 @@ yes_no() {
done
}

if test "$do_inst_syms" = ""
if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0}
then
echo "This script installs all tools and libraries needed to build Chromium."
echo ""
Expand All @@ -216,9 +221,9 @@ then
fi
fi
if test "$do_inst_syms" = "1"; then
echo "Installing debugging symbols."
echo "Including debugging symbols."
else
echo "Skipping installation of debugging symbols."
echo "Skipping debugging symbols."
dbg_list=
fi

Expand All @@ -229,27 +234,66 @@ if [ "$(uname -m)" = "x86_64" ]; then
arm_list="$arm_list g++-multilib"
fi

if test "$do_inst_arm" = "1"; then
if test "$do_inst_arm" = "1" ; then
. /etc/lsb-release
if test "$DISTRIB_CODENAME" != "precise"; then
if ! [ "${DISTRIB_CODENAME}" = "precise" -o \
1 -eq "${do_unsupported-0}" ]; then
echo "ERROR: Installing the ARM cross toolchain is only available on" \
"Ubuntu precise." >&2
exit 1
fi
echo "Installing ARM cross toolchain."
echo "Including ARM cross toolchain."
else
echo "Skipping installation of ARM cross toolchain."
echo "Skipping ARM cross toolchain."
arm_list=
fi

packages="$(echo "${dev_list} ${lib_list} ${dbg_list} ${arm_list}" | \
tr " " "\n" | sort -u | tr "\n" " ")"

if [ 1 -eq "${do_quick_check-0}" ] ; then
failed_check="$(dpkg-query -W -f '${PackageSpec}:${Status}\n' \
${packages} 2>&1 | grep -v "ok installed" || :)"
if [ -n "${failed_check}" ]; then
echo
nomatch="$(echo "${failed_check}" | \
sed -e "s/^No packages found matching \(.*\).$/\1/;t;d")"
missing="$(echo "${failed_check}" | \
sed -e "/^No packages found matching/d;s/^\(.*\):.*$/\1/")"
if [ "$nomatch" ]; then
# Distinguish between packages that actually aren't available to the
# system (i.e. not in any repo) and packages that just aren't known to
# dpkg (i.e. managed by apt).
unknown=""
for p in ${nomatch}; do
if apt-cache show ${p} > /dev/null 2>&1; then
missing="${p}\n${missing}"
else
unknown="${p}\n${unknown}"
fi
done
if [ -n "${unknown}" ]; then
echo "WARNING: The following packages are unknown to your system"
echo "(maybe missing a repo or need to 'sudo apt-get update'):"
echo -e "${unknown}" | sed -e "s/^/ /"
fi
fi
if [ -n "${missing}" ]; then
echo "WARNING: The following packages are not installed:"
echo -e "${missing}" | sed -e "s/^/ /"
fi
exit 1
fi
exit 0
fi

sudo apt-get update

# We initially run "apt-get" with the --reinstall option and parse its output.
# This way, we can find all the packages that need to be newly installed
# without accidentally promoting any packages from "auto" to "manual".
# We then re-run "apt-get" with just the list of missing packages.
echo "Finding missing packages..."
packages="${dev_list} ${lib_list} ${dbg_list} ${arm_list}"
# Intentionally leaving $packages unquoted so it's more readable.
echo "Packages required: " $packages
echo
Expand Down
14 changes: 14 additions & 0 deletions tools/diagnose-me.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ def CheckPathNinja():
return None


@Check("build dependencies are satisfied")
def CheckBuildDeps():
script_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'build',
'install-build-deps.sh')
proc = subprocess.Popen([script_path, '--quick-check'],
stdout=subprocess.PIPE)
stdout = proc.communicate()[0]
if 'WARNING' in stdout:
return ("Your build dependencies are out-of-date.\n"
"Run '" + script_path + "' to update.")
return None


def RunChecks():
for name, check in all_checks:
sys.stdout.write("* Checking %s: " % name)
Expand Down

0 comments on commit ba48c4c

Please sign in to comment.