mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
armbian-next: kernel: use git worktree & kernel.org clone bundles for kernel working copies
- now we've a single `.git` for all kernels with all branches; a "master" cache - back to full stable git bundle usage from kernel.org - bye bye, "gitballs" - split kernel-related git stuff into `kernel-git.sh` - introduce `ARMBIAN_MOUNTPOINTS_DEPRECATED` @TODO actually use for cleaning non-Docker - add `axel` hostdep for multi-conn download of bundle, which comes from a CDN. - deprecate old mountpoints for gitballs and linux-kernel - move cleaning of old sources/kernel to mountpoints code
This commit is contained in:
@@ -27,7 +27,7 @@ function run_kernel_make_internal() {
|
||||
common_make_envs+=("${DISTCC_EXTRA_ENVS[@]}")
|
||||
|
||||
common_make_params_quoted=(
|
||||
# @TODO: introduce O=path/to/binaries, so sources and bins are not in the same dir.
|
||||
# @TODO: introduce O=path/to/binaries, so sources and bins are not in the same dir; this has high impact in headers packaging though.
|
||||
|
||||
"${DISTCC_MAKE_J_PARALLEL[@]}" # Parallel compile, "-j X" for X cpus; determined by distcc, or is just "$CTHREADS" if distcc is not enabled.
|
||||
|
||||
@@ -76,8 +76,13 @@ function compile_kernel() {
|
||||
`${kernel_work_dir}` is set, but not yet populated with kernel sources.
|
||||
FETCH_SOURCES_FOR_KERNEL_DRIVER
|
||||
|
||||
# Prepare the git bare repo for the kernel.
|
||||
declare kernel_git_bare_tree
|
||||
LOG_SECTION="kernel_prepare_bare_repo_from_bundle" do_with_logging_unless_user_terminal do_with_hooks \
|
||||
kernel_prepare_bare_repo_from_bundle # this sets kernel_git_bare_tree
|
||||
|
||||
declare checked_out_revision_mtime="" checked_out_revision_ts="" # set by fetch_from_repo
|
||||
LOG_SECTION="kernel_prepare_git" do_with_logging do_with_hooks kernel_prepare_git
|
||||
LOG_SECTION="kernel_prepare_git" do_with_logging_unless_user_terminal do_with_hooks kernel_prepare_git
|
||||
|
||||
# Capture date variables set by fetch_from_repo; it's the date of the last kernel revision
|
||||
declare kernel_base_revision_date
|
||||
@@ -122,69 +127,6 @@ function compile_kernel() {
|
||||
return 0
|
||||
}
|
||||
|
||||
function kernel_init_git_from_http_gitball() {
|
||||
local kernel_git_dir="${1}"
|
||||
|
||||
local gitball_dir="${SRC}/cache/gitballs/kernel"
|
||||
if [[ ! -d "${gitball_dir}" ]]; then
|
||||
display_alert "Creating kernel git gitball cache dir" "${gitball_dir}" "info"
|
||||
run_host_command_logged mkdir -pv "${gitball_dir}"
|
||||
[[ -d "${SRC}/cache/gitbundles" ]] && run_host_command_logged rm -rf "${SRC}/cache/gitbundles" # remove old gitbundles dir. we won't be using those anymore; @TODO: remove this line in the future
|
||||
fi
|
||||
|
||||
local gitball_file="${gitball_dir}/linux-${KERNEL_MAJOR_MINOR}.git.tar"
|
||||
local gitball_url="https://github.com/armbian/gitutils/releases/download/latest/linux-${KERNEL_MAJOR_MINOR}.git.tar"
|
||||
|
||||
if [[ ! -f "${gitball_file}" ]]; then # Download the gitball file if it does not exist.
|
||||
display_alert "Downloading Git cold gitball via HTTP" "${gitball_url}" "info" # This gonna take a while. And waste bandwidth
|
||||
run_host_command_logged wget --continue --progress=dot:giga --output-document="${gitball_file}.tmp" "${gitball_url}"
|
||||
run_host_command_logged mv -v "${gitball_file}.tmp" "${gitball_file}"
|
||||
else
|
||||
display_alert "Cold gitball file exists, using it" "${gitball_file}" "git"
|
||||
fi
|
||||
|
||||
# Extract the gitball file to the git directory. This will create '.git'
|
||||
run_host_command_logged tar -xvf "${gitball_file}" -C "${kernel_git_dir}"
|
||||
|
||||
# Sanity check
|
||||
regular_git branch -a --list --color
|
||||
}
|
||||
|
||||
function kernel_prepare_git_pre_fetch() {
|
||||
local remote_name="kernel-stable-${KERNEL_MAJOR_MINOR}"
|
||||
local remote_url="${MAINLINE_KERNEL_SOURCE}"
|
||||
local remote_tags_to_fetch="v${KERNEL_MAJOR_MINOR}*"
|
||||
|
||||
# shellcheck disable=SC2154 # do_add_origin is defined in fetch_from_repo, and this is hook for it, so it's in context.
|
||||
if [[ "${do_add_origin}" == "yes" ]]; then
|
||||
display_alert "Fetching mainline stable tags" "${remote_name} tags: ${remote_tags_to_fetch}" "git"
|
||||
regular_git remote add "${remote_name}" "${remote_url}" # Add the remote to the warmup source
|
||||
|
||||
# Fetch the tags. This allows working -rcX versions of still-unreleased minor versions.
|
||||
improved_git_fetch "${remote_name}" "'refs/tags/${remote_tags_to_fetch}:refs/tags/${remote_tags_to_fetch}'" || true # Fetch the remote branch tags
|
||||
display_alert "After mainline stable tags, working copy size" "$(du -h -s | awk '{print $1}')" "git" # Show size after bundle pull
|
||||
fi
|
||||
}
|
||||
|
||||
function kernel_prepare_git() {
|
||||
[[ -z $KERNELSOURCE ]] && return 0 # do nothing if no kernel source... but again, why were we called then?
|
||||
|
||||
# LINUXSOURCEDIR has changed a lot, cleanup old incarnations if they exist
|
||||
if [[ -d "${SRC}/cache/sources/kernel" ]]; then
|
||||
display_alert "Cleaning up old kernel sources directory" "might take a while" "debug"
|
||||
run_host_command_logged rm -rf "${SRC}/cache/sources/kernel"
|
||||
fi
|
||||
|
||||
[[ -d "${kernel_work_dir}" ]] && cd "${kernel_work_dir}" && fasthash_debug "pre git, existing tree"
|
||||
|
||||
display_alert "Downloading sources" "kernel" "git"
|
||||
|
||||
GIT_FIXED_WORKDIR="${LINUXSOURCEDIR}" \
|
||||
GIT_INIT_REPO_HOOK=kernel_init_git_from_http_gitball \
|
||||
GIT_PRE_FETCH_HOOK=kernel_prepare_git_pre_fetch_tags \
|
||||
fetch_from_repo "$KERNELSOURCE" "unused:set via GIT_FIXED_WORKDIR" "$KERNELBRANCH" "yes"
|
||||
}
|
||||
|
||||
function kernel_maybe_clean() {
|
||||
if [[ $CLEAN_LEVEL == *make-kernel* ]]; then
|
||||
display_alert "Cleaning Kernel tree - CLEAN_LEVEL contains 'make-kernel'" "$LINUXSOURCEDIR" "info"
|
||||
|
||||
Reference in New Issue
Block a user