*: add --usepkgonly flag to avoid building from source

This commit is contained in:
Michael Marineau 2016-02-03 18:20:37 -08:00
parent a3fceb1957
commit d327840ce8
3 changed files with 84 additions and 16 deletions

View File

@ -16,6 +16,8 @@ DEFINE_string board "${DEFAULT_BOARD}" \
"The board to build packages for."
DEFINE_boolean usepkg "${FLAGS_TRUE}" \
"Use binary packages when possible."
DEFINE_boolean usepkgonly "${FLAGS_FALSE}" \
"Only use/download binary packages. Implies --noworkon"
DEFINE_boolean getbinpkg "${FLAGS_TRUE}" \
"Download binary packages from remote repository."
DEFINE_string getbinpkgver "" \
@ -67,6 +69,19 @@ if [[ -z "${FLAGS_board}" ]]; then
exit 1
fi
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
for flag in usepkg getbinpkg; do
fvar="FLAGS_${flag}"
if [[ "${!fvar}" -ne "${FLAGS_TRUE}" ]]; then
die_notrace "--usepkgonly is incompatible with --no${flag}"
fi
done
if [[ "${FLAGS_rebuild}" -eq "${FLAGS_TRUE}" ]]; then
die_notrace "--usepkgonly is incompatible with --rebuild"
fi
FLAGS_workon="${FLAGS_FALSE}"
fi
check_gsutil_opts
CHROMITE_BIN="${GCLIENT_ROOT}/chromite/bin"
@ -75,6 +90,11 @@ CHROMITE_BIN="${GCLIENT_ROOT}/chromite/bin"
UPDATE_ARGS=( --regen_configs )
if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then
UPDATE_ARGS+=( --usepkg )
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
UPDATE_ARGS+=( --usepkgonly )
else
UPDATE_ARGS+=( --nousepkgonly )
fi
if [[ "${FLAGS_getbinpkg}" -eq "${FLAGS_TRUE}" ]]; then
UPDATE_ARGS+=( --getbinpkg )
else
@ -121,16 +141,20 @@ EMERGE_CMD+=( ${EXTRA_BOARD_FLAGS} )
if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]]; then
# Use binary packages. Include all build-time dependencies,
# so as to avoid unnecessary differences between source
# and binary builds.
# and binary builds except for --usepkgonly for speed.
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
EMERGE_FLAGS+=( --usepkgonly )
else
EMERGE_FLAGS+=( --usepkg --with-bdeps y )
if [[ "${FLAGS_getbinpkg}" -eq "${FLAGS_TRUE}" ]]; then
EMERGE_FLAGS+=( --getbinpkg )
fi
# Only update toolchain when binpkgs are available.
EMERGE_FLAGS+=( $(get_binonly_args) )
REBUILD_FLAGS+=( $(get_binonly_args) )
fi
if [[ "${FLAGS_getbinpkg}" -eq "${FLAGS_TRUE}" ]]; then
EMERGE_FLAGS+=( --getbinpkg )
fi
fi
if [[ "${FLAGS_jobs}" -ne -1 ]]; then
EMERGE_FLAGS+=( --jobs=${FLAGS_jobs} )
@ -199,11 +223,13 @@ break_dep_loop() {
sudo rm -f "${flag_file}"
}
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_FALSE}" ]]; then
# util-linux[udev] -> virtual->udev -> systemd -> util-linux
break_dep_loop sys-apps/util-linux udev,systemd sys-apps/systemd cryptsetup
# systemd[cryptsetup] -> cryptsetup -> lvm2 -> virtual/udev -> systemd
break_dep_loop sys-apps/systemd cryptsetup
fi
info "Merging board packages now"
sudo -E "${EMERGE_CMD[@]}" "${EMERGE_FLAGS[@]}" "$@"
@ -211,9 +237,11 @@ sudo -E "${EMERGE_CMD[@]}" "${EMERGE_FLAGS[@]}" "$@"
info "Removing obsolete packages"
sudo -E "${EMERGE_CMD[@]}" --quiet --depclean @unavailable
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
if "portageq-${BOARD}" list_preserved_libs "${BOARD_ROOT}" >/dev/null; then
sudo -E "${EMERGE_CMD[@]}" "${REBUILD_FLAGS[@]}" @preserved-rebuild
fi
fi
info "Checking build root"
test_image_content "${BOARD_ROOT}"

View File

@ -21,6 +21,8 @@ DEFINE_boolean force "${FLAGS_FALSE}" \
"Force re-creating board root."
DEFINE_boolean usepkg "${FLAGS_TRUE}" \
"Use binary packages when possible."
DEFINE_boolean usepkgonly "${FLAGS_FALSE}" \
"Only use/download binary packages."
DEFINE_boolean getbinpkg "${FLAGS_TRUE}" \
"Download binary packages from remote repository."
DEFINE_string getbinpkgver "" \
@ -135,12 +137,26 @@ if [ -z "$FLAGS_board" ] ; then
exit 1
fi
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
for flag in usepkg getbinpkg; do
fvar="FLAGS_${flag}"
if [[ "${!fvar}" -ne "${FLAGS_TRUE}" ]]; then
die_notrace "--usepkgonly is incompatible with --no${flag}"
fi
done
fi
get_board_and_variant $FLAGS_board $FLAGS_variant
# Before we can run any tools, we need to update chroot
UPDATE_ARGS="--toolchain_boards=${BOARD}"
if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then
UPDATE_ARGS+=" --usepkg"
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
UPDATE_ARGS+=" --usepkgonly"
else
UPDATE_ARGS+=" --usepkgonly"
fi
if [[ "${FLAGS_getbinpkg}" -eq "${FLAGS_TRUE}" ]]; then
UPDATE_ARGS+=" --getbinpkg "
else
@ -284,7 +300,12 @@ if [[ ${FLAGS_regen_configs} -eq ${FLAGS_FALSE} ]]; then
if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" && \
"${FLAGS_getbinpkg}" -eq "${FLAGS_TRUE}" ]]
then
EMERGE_FLAGS+=" --usepkg --getbinpkg"
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
EMERGE_FLAGS+=" --usepkgonly"
else
EMERGE_FLAGS+=" --usepkg"
fi
EMERGE_FLAGS+=" --getbinpkg"
EMERGE_TOOLCHAIN_FLAGS+=" --usepkgonly --getbinpkg"
else
# When binary packages are disabled we need to make sure the cross

View File

@ -17,6 +17,10 @@ DEFINE_boolean usepkg "${FLAGS_TRUE}" \
"Use binary packages when possible."
DEFINE_boolean getbinpkg "${FLAGS_TRUE}" \
"Download binary packages from remote repository."
DEFINE_boolean usepkgonly "${FLAGS_FALSE}" \
"Only use/download binary packages. Implies --noworkon"
DEFINE_boolean workon "${FLAGS_TRUE}" \
"Automatically rebuild updated cros-workon packages."
DEFINE_integer jobs "${NUM_JOBS}" \
"How many packages to build in parallel at maximum."
DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \
@ -37,6 +41,16 @@ eval set -- "${FLAGS_ARGV}"
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
switch_to_strict_mode
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
for flag in usepkg getbinpkg; do
fvar="FLAGS_${flag}"
if [[ "${!fvar}" -ne "${FLAGS_TRUE}" ]]; then
die_notrace "--usepkgonly is incompatible with --no${flag}"
fi
done
FLAGS_workon="${FLAGS_FALSE}"
fi
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh"
PORTAGE_STABLE_OVERLAY="${REPO_ROOT}/src/third_party/portage-stable"
@ -166,6 +180,9 @@ EMERGE_FLAGS="-uNv --with-bdeps=y --select"
REBUILD_FLAGS=""
if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then
EMERGE_FLAGS="${EMERGE_FLAGS} --usepkg"
if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then
EMERGE_FLAGS+=" --usepkgonly"
fi
if [ "${FLAGS_getbinpkg}" -eq "${FLAGS_TRUE}" ]; then
EMERGE_FLAGS="${EMERGE_FLAGS} --getbinpkg"
fi
@ -210,9 +227,11 @@ fi
# Build cros_workon packages when they are changed.
CHROMITE_BIN="${GCLIENT_ROOT}/chromite/bin"
if [ "${FLAGS_workon}" -eq "${FLAGS_TRUE}" ]; then
for pkg in $("${CHROMITE_BIN}/cros_list_modified_packages" --host); do
EMERGE_FLAGS+=" --reinstall-atoms=${pkg} --usepkg-exclude=${pkg}"
done
fi
# Second pass, update everything else.
EMERGE_FLAGS+=" --deep"