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)
This commit is contained in:
Ricardo Pardini
2023-01-19 23:46:49 +01:00
parent 72c61f2f68
commit 88ff66ae11
5 changed files with 270 additions and 48 deletions

View File

@@ -1,15 +1,23 @@
#!/usr/bin/env bash
function compile_kernel() {
local kernel_work_dir="${SRC}/cache/sources/${LINUXSOURCEDIR}"
declare kernel_work_dir="${SRC}/cache/sources/${LINUXSOURCEDIR}"
display_alert "Kernel build starting" "${LINUXSOURCEDIR}" "info"
# Prepare the git bare repo for the kernel; shared between all kernel builds
declare kernel_git_bare_tree
declare git_bundles_dir="${SRC}/cache/git-bundles/kernel"
# @TODO: have a way to actually use this. It's inefficient, but might be the only way for people without ORAS/OCI for some reason.
# Important: for the bundle version, gotta use "do_with_logging_unless_user_terminal" otherwise floods logs.
# alternative # LOG_SECTION="kernel_prepare_bare_repo_from_bundle" do_with_logging_unless_user_terminal do_with_hooks \
# alternative # kernel_prepare_bare_repo_from_bundle # this sets kernel_git_bare_tree
# @TODO: Decide which kind of gitball to use: shallow or full.
declare bare_tree_done_marker_file=".git/armbian-bare-tree-done"
declare git_bundles_dir
declare git_kernel_ball_fn
declare git_kernel_oras_ref
kernel_prepare_bare_repo_decide_shallow_or_full # sets kernel_git_bare_tree, git_bundles_dir, git_kernel_ball_fn, git_kernel_oras_ref
LOG_SECTION="kernel_prepare_bare_repo_from_oras_gitball" do_with_logging do_with_hooks \
kernel_prepare_bare_repo_from_oras_gitball # this sets kernel_git_bare_tree