From 184e39019d2875c53e8536d0f4bd155f836109bb Mon Sep 17 00:00:00 2001 From: David James Date: Thu, 23 Feb 2012 20:19:28 -0800 Subject: [PATCH] Fix --jobs flags to actually work. The --jobs= option wasn't actually being passed to parallel_emerge -- which meant it didn't do anything. BUG=chromium-os:26827 TEST=Ran with --jobs=N and made sure only N parallel_emerge processes were started. Change-Id: I581fc5588b54e246acaefd0c7e528e55adf9ba8a Reviewed-on: https://gerrit.chromium.org/gerrit/16570 Reviewed-by: Michael Krebs Commit-Ready: David James Tested-by: David James --- build_packages | 5 ++++- common.sh | 3 +-- sdk_lib/make_chroot.sh | 7 +++---- setup_board | 5 +++++ update_chroot | 6 ++++++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/build_packages b/build_packages index c529f4f03d..87e98592c5 100755 --- a/build_packages +++ b/build_packages @@ -111,7 +111,7 @@ if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]]; then fi if [[ "${FLAGS_jobs}" -ne -1 ]]; then - EMERGE_JOBS="--jobs=${FLAGS_jobs}" + EMERGE_FLAGS+=" --jobs=${FLAGS_jobs}" fi if [[ "${FLAGS_withdebug}" -eq "${FLAGS_FALSE}" ]]; then @@ -132,6 +132,9 @@ if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then else UPDATE_ARGS+=" --nousepkg" fi +if [[ "${FLAGS_jobs}" -ne -1 ]]; then + UPDATE_ARGS+=" --jobs=${FLAGS_jobs}" +fi if [ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_TRUE}" ]; then UPDATE_ARGS+=" --skip_toolchain_update" fi diff --git a/common.sh b/common.sh index 826ef1d285..a1704b6a49 100644 --- a/common.sh +++ b/common.sh @@ -370,12 +370,11 @@ function check_flags_only_and_allow_null_arg { } # Retry an emerge command according to $FLAGS_retries -# The $EMERGE_JOBS flags will only be added the first time the command is run function eretry () { local i for i in $(seq $FLAGS_retries); do echo "Retrying $@" - "$@" $EMERGE_JOBS && return 0 + "$@" && return 0 done "$@" && return 0 return 1 diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh index 64d4334a74..012cbb06d3 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -216,10 +216,6 @@ EOF sudo ln -s ../../cache/distfiles/target \ "${FLAGS_chroot}/var/lib/portage/distfiles-target" - if [[ $FLAGS_jobs -ne -1 ]]; then - EMERGE_JOBS="--jobs=$FLAGS_jobs" - fi - # Add chromite/bin and depot_tools into the path globally; note that the # chromite wrapper itself might also be found in depot_tools. # We rely on 'env-update' getting called below. @@ -464,6 +460,9 @@ if [[ ${FLAGS_fast} -eq ${FLAGS_TRUE} ]]; then else UPDATE_ARGS+=( --nofast ) fi +if [[ "${FLAGS_jobs}" -ne -1 ]]; then + UPDATE_ARGS+=( --jobs=${FLAGS_jobs} ) +fi enter_chroot "${CHROOT_TRUNK}/src/scripts/update_chroot" "${UPDATE_ARGS[@]}" CHROOT_EXAMPLE_OPT="" diff --git a/setup_board b/setup_board index 044b0d72d6..bb301aceea 100755 --- a/setup_board +++ b/setup_board @@ -67,6 +67,8 @@ DEFINE_boolean quiet $FLAGS_FALSE \ "Don't print warnings when board already exists." DEFINE_boolean skip_toolchain_update $FLAGS_FALSE \ "Don't update toolchain automatically." +DEFINE_integer jobs -1 \ + "How many packages to build in parallel at maximum." # builds wrappers like equery-arm-generic. # args: @@ -459,6 +461,9 @@ if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then else UPDATE_ARGS+=" --nousepkg" fi +if [[ "${FLAGS_jobs}" -ne -1 ]]; then + UPDATE_ARGS+=" --jobs=${FLAGS_jobs}" +fi "${SRC_ROOT}/scripts"/update_chroot ${UPDATE_ARGS} get_board_and_variant $FLAGS_board $FLAGS_variant diff --git a/update_chroot b/update_chroot index 350155b211..4283474d56 100755 --- a/update_chroot +++ b/update_chroot @@ -23,6 +23,8 @@ DEFINE_boolean usepkg $FLAGS_TRUE \ DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" DEFINE_integer retries -1 \ "On build failure, the number of times to retry." +DEFINE_integer jobs -1 \ + "How many packages to build in parallel at maximum." # Parse command line flags FLAGS "$@" || exit 1 @@ -56,6 +58,10 @@ if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then EMERGE_FLAGS+=" --useoldpkg-atoms=sys-libs/glibc" fi +if [[ "${FLAGS_jobs}" -ne -1 ]]; then + EMERGE_FLAGS+=" --jobs=${FLAGS_jobs}" +fi + # Perform an update of hard-host-depends and world in the chroot. EMERGE_CMD="emerge" if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then