armbian_build/lib/functions/compilation/kernel-git.sh
Ricardo Pardini 88ff66ae11
armbian-next: adaptive shallow/full Kernel git bare git (3gb -> 300mb download)
- allows using pre-shallow-ed bare trees, specific to the KERNEL_MAJOR_MINOR
- uses shallow by default if storage is "slow" (mmc), or free disk space < 32g (@TODO tweak this)
- if full tree already there keeps using it
- allow forcing decision with `KERNEL_GIT=full` or `KERNEL_GIT=shallow`
- countdown to confirm if decision based on storage type/free space and user is interactive
  - this has some of the worst copy ever written
- @TODO refactor the device type / free space code, reuse across codebase (3-4 other spots detect free space)
- @TODO GHA self-hosted (full) vs hosted (shallow) runners decision
- sprinkle with `wait_for_disk_sync()` around clean/download/extract
- sprinkle git with debugs, and an info between fetch and checkout (otherwise it seems "fetch" takes a long time)
2023-02-18 07:43:54 -03:00

29 lines
1.0 KiB
Bash

function kernel_prepare_git() {
[[ -z $KERNELSOURCE ]] && return 0 # do nothing if no kernel source... but again, why were we called then?
# validate kernel_git_bare_tree is set
if [[ -z "${kernel_git_bare_tree}" ]]; then
exit_with_error "kernel_git_bare_tree is not set"
fi
display_alert "Downloading sources" "kernel" "git"
GIT_FIXED_WORKDIR="${LINUXSOURCEDIR}" \
GIT_BARE_REPO_FOR_WORKTREE="${kernel_git_bare_tree}" \
GIT_BARE_REPO_INITIAL_BRANCH="master" \
fetch_from_repo "${KERNELSOURCE}" "kernel:${KERNEL_MAJOR_MINOR}" "${KERNELBRANCH}" "yes"
# second parameter, "dir", is ignored, since we've passed GIT_FIXED_WORKDIR
}
function kernel_cleanup_bundle_artifacts() {
[[ -z "${git_bundles_dir}" ]] && exit_with_error "git_bundles_dir is not set"
if [[ -d "${git_bundles_dir}" ]]; then
display_alert "Cleaning up Kernel git bundle artifacts" "no longer needed" "cachehit"
display_alert "NOT CLEANING BUNDLES" "${git_bundles_dir}" "warn" # @TODO remove "soon"
#run_host_command_logged rm -rf "${git_bundles_dir}"
fi
return 0
}