flatcar-scripts/rebuild_packages
Krzesimir Nowak 6ed7cd66d5 *: Drop jobs parameter
The `--jobs` parameter that some scripts defined was not used anywhere
in jenkins or mantle. So the value of the parameter always ended up
being equal to `${NUM_JOBS}` set by `common.sh`. Also, even if the
`--jobs` parameter was used for some script, that script usually
didn't forward the jobs value to other scripts, so the other scripts
ended up using `${NUM_JOBS}` again. Also, the `${FLAGS_jobs}` variable
was used by some functions in the build library, and those functions
were sometimes invoked by scripts that didn't define the
`${FLAGS_jobs}` variable. It is tedious to track which script should
actually define the parameter, and where it should be forwarded.

Just get rid of this half-working pretense. If you want to affect how
many jobs `emerge` uses, export the `NUM_JOBS` environment variable
before calling any script.

For `EMERGE_FLAGS` and `REBUILD_FLAGS` we unconditionally specify the
`--jobs` flag's value to `${NUM_JOBS}` because they are passed to
`emerge`. On the other hand we drop the `--jobs` parameter from the
`UPDATE_ARGS` variable, because this variable passed to `setup_board`
or `update_chroot`, which don't have this flag any more.
2021-02-17 13:26:36 +01:00

87 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Copyright (c) 2016 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
# Script must run inside the chroot
assert_inside_chroot
assert_not_root_user
# Developer-visible flags.
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to build packages for."
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
# Parse flags
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
switch_to_strict_mode
if [[ -z "${FLAGS_board}" ]]; then
echo "Error: --board is required."
exit 1
fi
check_gsutil_opts
# set BOARD and BOARD_ROOT
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1
declare -A repo_paths
for repo_name in $(portageq-$BOARD get_repos "${BOARD_ROOT}"); do
repo_paths[$repo_name]=$(portageq-$BOARD \
get_repo_path "${BOARD_ROOT}" "$repo_name")
done
rebuild_atoms=()
# a crazy format I can eval inside the loop
list_format='cp="$cp";cpv="$cpv";repo="$repo"'
for pkg_info in $(equery-$BOARD list --format="${list_format}" '*'); do
eval "$pkg_info"
pvr="${cpv#*/}"
pkg_ebuild="${BOARD_ROOT}/var/db/pkg/${cpv}/${pvr}.ebuild"
repo_ebuild="${repo_paths[$repo]}/${cp}/${pvr}.ebuild"
if [[ ! -f "${pkg_ebuild}" ]]; then
die "${pvr} installed but ${pkg_ebuild} is missing!!!"
fi
if [[ ! -f "${repo_ebuild}" ]]; then
error "${pvr} is installed but ${repo_ebuild} is missing."
error "Perhaps run build_packages --board=$BOARD"
exit 1
fi
if cmp -s "${pkg_ebuild}" "${repo_ebuild}"; then
continue
fi
info "${pvr}.ebuild has changed"
rebuild_atoms+=( "=${cpv}" )
done
if [[ "${#rebuild_atoms[@]}" -eq 0 ]]; then
info "No ebuild changes detected"
else
info "Rebuilding ${#rebuild_atoms[@]} packages..."
emerge-$BOARD "--jobs=${NUM_JOBS}" "${rebuild_atoms[@]}"
info "Checking build root"
test_image_content "${BOARD_ROOT}"
# upload packages if enabled
upload_packages
fi
command_completed