diff --git a/build_docker_aci b/build_docker_aci index 2916d4d3f6..cdd12dd61a 100755 --- a/build_docker_aci +++ b/build_docker_aci @@ -54,8 +54,6 @@ DEFINE_string version "" \ "Sets the docker version to build." DEFINE_integer aci_version "" \ "Sets the aci version tag identifier." -DEFINE_integer jobs "${NUM_JOBS}" \ - "How many packages to build in parallel at maximum." # Parse command line. FLAGS "$@" || exit 1 diff --git a/build_image b/build_image index 21c5b52064..ad7cf16528 100755 --- a/build_image +++ b/build_image @@ -72,8 +72,6 @@ show_help_if_requested "$@" # not needed for the typical developer workflow. DEFINE_integer build_attempt 1 \ "The build attempt for this image build." -DEFINE_integer jobs "${NUM_JOBS}" \ - "How many packages to build in parallel at maximum." DEFINE_boolean replace ${FLAGS_FALSE} \ "Overwrite existing output, if any." DEFINE_string version "" \ diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index e528aaffa1..abe3c57808 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -145,7 +145,7 @@ emerge_to_image() { sudo -E ROOT="${root_fs_dir}" \ PORTAGE_CONFIGROOT="${BUILD_DIR}"/configroot \ - emerge --root-deps=rdeps --usepkgonly --jobs=$FLAGS_jobs -v "$@" + emerge --root-deps=rdeps --usepkgonly --jobs="${NUM_JOBS}" -v "$@" # Shortcut if this was just baselayout [[ "$*" == *sys-apps/baselayout ]] && return @@ -172,7 +172,7 @@ emerge_to_image_unchecked() { sudo -E ROOT="${root_fs_dir}" \ PORTAGE_CONFIGROOT="${BUILD_DIR}"/configroot \ - emerge --root-deps=rdeps --usepkgonly --jobs=$FLAGS_jobs -v "$@" + emerge --root-deps=rdeps --usepkgonly --jobs="${NUM_JOBS}" -v "$@" # Shortcut if this was just baselayout [[ "$*" == *sys-apps/baselayout ]] && return diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index acc884de60..67c9b785e3 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -522,7 +522,6 @@ install_oem_aci() { "${SCRIPT_ROOT}/build_oem_aci" \ --board="${BOARD}" \ --build_dir="${aci_dir}" \ - --jobs="${FLAGS_jobs}" \ "${binpkgflags[@]}" \ "${oem_aci}" diff --git a/build_oem_aci b/build_oem_aci index 6e4858b680..d2fbe19a46 100755 --- a/build_oem_aci +++ b/build_oem_aci @@ -46,8 +46,6 @@ DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ "Directory in which to place image result directories (named by version)" DEFINE_string version "" \ "Overrides version number in name to this version." -DEFINE_integer jobs "${NUM_JOBS}" \ - "How many packages to build in parallel at maximum." # Parse command line. FLAGS "$@" || exit 1 diff --git a/build_packages b/build_packages index c81eaccb8c..154d322d46 100755 --- a/build_packages +++ b/build_packages @@ -30,8 +30,6 @@ DEFINE_boolean workon "${FLAGS_TRUE}" \ "Automatically rebuild updated cros-workon packages." DEFINE_boolean fetchonly "${FLAGS_FALSE}" \ "Don't build anything, instead only fetch what is needed." -DEFINE_integer jobs "${NUM_JOBS}" \ - "How many packages to build in parallel at maximum." DEFINE_boolean rebuild "${FLAGS_FALSE}" \ "Automatically rebuild dependencies." DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \ @@ -113,9 +111,6 @@ 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 @@ -161,10 +156,8 @@ if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]]; then fi fi -if [[ "${FLAGS_jobs}" -ne -1 ]]; then - EMERGE_FLAGS+=( --jobs=${FLAGS_jobs} ) - REBUILD_FLAGS+=( --jobs=${FLAGS_jobs} ) -fi +EMERGE_FLAGS+=( "--jobs=${NUM_JOBS}" ) +REBUILD_FLAGS+=( "--jobs=${NUM_JOBS}" ) if [[ "${FLAGS_rebuild}" -eq "${FLAGS_TRUE}" ]]; then EMERGE_FLAGS+=( --rebuild-if-unbuilt ) diff --git a/common.sh b/common.sh index 014b257307..a97c560fe8 100644 --- a/common.sh +++ b/common.sh @@ -8,7 +8,10 @@ # The number of jobs to pass to tools that can run in parallel (such as make # and dpkg-buildpackage -if [[ -z ${NUM_JOBS} ]]; then +case "${NUM_JOBS}" in + *[!0-9]*) NUM_JOBS='' ;; +esac +if [[ -z ${NUM_JOBS} ]] || [[ ${NUM_JOBS} -eq 0 ]]; then NUM_JOBS=$(grep -c "^processor" /proc/cpuinfo) fi # Ensure that any sub scripts we invoke get the max proc count. diff --git a/image_to_vm.sh b/image_to_vm.sh index d61c3515a4..49319ea58b 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -44,8 +44,6 @@ DEFINE_boolean getbinpkg "${FLAGS_FALSE}" \ "Download binary packages from remote repository." DEFINE_string getbinpkgver "" \ "Use binary packages from a specific version." -DEFINE_integer jobs "${NUM_JOBS}" \ - "How many packages to build in parallel at maximum." # include upload options . "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1 diff --git a/rebuild_packages b/rebuild_packages index e95040f6cc..60aae4ea79 100755 --- a/rebuild_packages +++ b/rebuild_packages @@ -15,8 +15,6 @@ assert_not_root_user # Developer-visible flags. DEFINE_string board "${DEFAULT_BOARD}" \ "The board to build packages for." -DEFINE_integer jobs "${NUM_JOBS}" \ - "How many packages to build in parallel." # include upload options . "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1 @@ -76,7 +74,7 @@ if [[ "${#rebuild_atoms[@]}" -eq 0 ]]; then info "No ebuild changes detected" else info "Rebuilding ${#rebuild_atoms[@]} packages..." - emerge-$BOARD --jobs=${FLAGS_jobs} "${rebuild_atoms[@]}" + emerge-$BOARD "--jobs=${NUM_JOBS}" "${rebuild_atoms[@]}" info "Checking build root" test_image_content "${BOARD_ROOT}" diff --git a/setup_board b/setup_board index b9f082afee..1b0bf8808b 100755 --- a/setup_board +++ b/setup_board @@ -31,8 +31,6 @@ DEFINE_string binhost "" \ "Use binary packages from a specific location (e.g. https://storage.googleapis.com/flatcar-jenkins/sdk/amd64/2000.0.0/pkgs)" DEFINE_boolean toolchainpkgonly "${FLAGS_FALSE}" \ "Use binary packages only for the board toolchain." -DEFINE_integer jobs "${NUM_JOBS}" \ - "How many packages to build in parallel at maximum." DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \ "Don't update toolchain automatically." DEFINE_boolean skip_chroot_upgrade "${FLAGS_FALSE}" \ @@ -206,9 +204,6 @@ 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 @@ -295,9 +290,7 @@ ${EMAINT_WRAPPER} --fix world if [[ ${FLAGS_regen_configs} -eq ${FLAGS_FALSE} ]]; then EMERGE_FLAGS="--select --quiet --root-deps=rdeps" - if [[ "${FLAGS_jobs}" -ne -1 ]]; then - EMERGE_FLAGS+=" --jobs=${FLAGS_jobs}" - fi + EMERGE_FLAGS+=" --jobs=${NUM_JOBS}" EMERGE_TOOLCHAIN_FLAGS="${EMERGE_FLAGS}" if [[ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" && \ diff --git a/update_chroot b/update_chroot index f590b92142..13cb67e29b 100755 --- a/update_chroot +++ b/update_chroot @@ -21,8 +21,6 @@ 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}" \ "Don't update the toolchains." DEFINE_string toolchain_boards "" \ @@ -201,10 +199,8 @@ if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then REBUILD_FLAGS+=( $(get_binonly_args $(get_chost_list)) ) fi -if [[ "${FLAGS_jobs}" -ne -1 ]]; then - EMERGE_FLAGS+=( "--jobs=${FLAGS_jobs}" ) - REBUILD_FLAGS+=( "--jobs=${FLAGS_jobs}" ) -fi +EMERGE_FLAGS+=( "--jobs=${NUM_JOBS}" ) +REBUILD_FLAGS+=( "--jobs=${NUM_JOBS}" ) # Perform an update of coreos-devel/sdk-depends and world in the chroot. EMERGE_CMD="emerge"