armbian_build/lib/functions/compilation/uboot-git.sh
Ricardo Pardini 074857ede3
armbian-next: u-boot: use git worktree for u-boot; full mainline clone for bare
- share a single `.git` for all u-boots
- all fetches are done against it, maximizing cache hit ratio drastically
- also reduces the size of each working copy by more than 70%
- split uboot's git stuff into uboot-git.sh
- split `uboot_prepare_git()` from `compile_uboot()`
2023-02-18 07:40:39 -03:00

41 lines
1.7 KiB
Bash

function uboot_prepare_bare_repo() {
uboot_git_bare_tree="${SRC}/cache/git-bare/u-boot" # sets the outer scope variable
declare uboot_git_bare_tree_done_marker="${uboot_git_bare_tree}/.git/armbian-bare-tree-done"
if [[ ! -d "${uboot_git_bare_tree}" || ! -f "${uboot_git_bare_tree_done_marker}" ]]; then
if [[ -d "${uboot_git_bare_tree}" ]]; then
display_alert "Removing old u-boot bare tree" "${uboot_git_bare_tree}" "info"
rm -rf "${uboot_git_bare_tree}"
fi
# get the mainline u-boot repo completely; use clone, not fetch.
display_alert "Cloning u-boot from mainline into bare tree" "this might take a somewhat-long time" "info"
declare -a verbose_params=() && if_user_on_terminal_and_not_logging_add verbose_params "--verbose" "--progress"
run_host_command_logged git clone "${verbose_params[@]}" --tags --no-checkout \
"${MAINLINE_UBOOT_SOURCE}" "${uboot_git_bare_tree}"
# write the marker file
touch "${uboot_git_bare_tree_done_marker}"
fi
return 0
}
function uboot_prepare_git() {
display_alert "Preparing git for u-boot" "BOOTSOURCE: ${BOOTSOURCE}" "debug"
if [[ -n $BOOTSOURCE ]] && [[ "${BOOTSOURCE}" != "none" ]]; then
# Prepare the git bare repo for u-boot.
declare uboot_git_bare_tree
uboot_prepare_bare_repo # this sets uboot_git_bare_tree
display_alert "Downloading sources" "u-boot; BOOTSOURCEDIR=${BOOTSOURCEDIR}" "git"
GIT_FIXED_WORKDIR="${BOOTSOURCEDIR}" \
GIT_BARE_REPO_FOR_WORKTREE="${uboot_git_bare_tree}" \
GIT_BARE_REPO_INITIAL_BRANCH="master" \
GIT_SKIP_SUBMODULES="${UBOOT_GIT_SKIP_SUBMODULES}" \
fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes" # fetch_from_repo <url> <dir> <ref> <subdir_flag>
fi
return 0
}