diff --git a/lib/functions/cli/cli-patch.sh b/lib/functions/cli/cli-patch.sh index 658c4238e..dc539c508 100644 --- a/lib/functions/cli/cli-patch.sh +++ b/lib/functions/cli/cli-patch.sh @@ -1,6 +1,13 @@ function cli_patch_kernel_pre_run() { declare -g ARMBIAN_COMMAND_REQUIRE_BASIC_DEPS="yes" # Require prepare_host_basic to run before the command. declare -g DOCKER_PASS_SSH_AGENT="yes" # Pass SSH agent to docker + declare -g DOCKER_PASS_GIT="yes" # mount .git dir to docker; for archeology + + # inside-function-function: a dynamic hook, only triggered if this CLI runs. + # install openssh-client, we'll need it to push the patched tree. + function add_host_dependencies__ssh_client_for_patch_pushing_over_ssh() { + export EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} openssh-client" + } # "gimme root on a Linux machine" cli_standard_relaunch_docker_or_sudo @@ -8,13 +15,14 @@ function cli_patch_kernel_pre_run() { function cli_patch_kernel_run() { display_alert "Patching kernel" "$BRANCH" "info" - declare -g SYNC_CLOCK=no # don't waste time syncing the clock - declare -g JUST_KERNEL=yes # only for kernel. - declare -g KERNEL_ONLY=yes # don't build images - declare -g PATCHES_TO_GIT=yes # commit to git. - declare -g PATCH_ONLY=yes # stop after patching. - declare -g DEBUG_PATCHING=yes # debug patching. - declare -g GIT_ARCHEOLOGY=yes # do archeology + declare -g SYNC_CLOCK=no # don't waste time syncing the clock + declare -g JUST_KERNEL=yes # only for kernel. + declare -g KERNEL_ONLY=yes # don't build images + declare -g PATCHES_TO_GIT=yes # commit to git. + declare -g PATCH_ONLY=yes # stop after patching. + declare -g DEBUG_PATCHING=yes # debug patching. + declare -g GIT_ARCHEOLOGY=yes # do archeology + declare -g FAST_ARCHEOLOGY=yes # do archeology, but only for the exact path we need. #declare -g REWRITE_PATCHES=yes # rewrite the patches after git commiting. Very cheap compared to the rest. declare -g KERNEL_CONFIGURE=no # no menuconfig declare -g RELEASE=jammy # or whatever, not relevant, just fool the configuration diff --git a/lib/functions/compilation/kernel-patching.sh b/lib/functions/compilation/kernel-patching.sh index bcf2c1062..e95bf3626 100644 --- a/lib/functions/compilation/kernel-patching.sh +++ b/lib/functions/compilation/kernel-patching.sh @@ -33,8 +33,9 @@ function kernel_main_patching_python() { "BASE_GIT_REVISION=${kernel_git_revision}" # The revision we're building/patching. Python will reset and clean to this. "BRANCH_FOR_PATCHES=kernel-${LINUXFAMILY}-${KERNEL_MAJOR_MINOR}" # When applying patches-to-git, use this branch. # Lenience: allow problematic patches to be applied. - "ALLOW_RECREATE_EXISTING_FILES=yes" # Allow patches to recreate files that already exist. - "GIT_ARCHEOLOGY=${GIT_ARCHEOLOGY:-no}" # Allow git to do some archaeology to find the original patch's owners + "ALLOW_RECREATE_EXISTING_FILES=yes" # Allow patches to recreate files that already exist. + "GIT_ARCHEOLOGY=${GIT_ARCHEOLOGY:-no}" # Allow git to do some archaeology to find the original patch's owners; used when patching to git/rewriting. + "FAST_ARCHEOLOGY=${FAST_ARCHEOLOGY:-yes}" # Does archeology even further by looking for history from other patch files with the same name # Pass the maintainer info, used for commits. "MAINTAINER_NAME=${MAINTAINER}" # Name of the maintainer "MAINTAINER_EMAIL=${MAINTAINERMAIL}" # Email of the maintainer diff --git a/lib/functions/compilation/uboot-patching.sh b/lib/functions/compilation/uboot-patching.sh index 3bbbc21d9..2a909819f 100644 --- a/lib/functions/compilation/uboot-patching.sh +++ b/lib/functions/compilation/uboot-patching.sh @@ -27,6 +27,13 @@ function uboot_main_patching_python() { "GIT_WORK_DIR=${uboot_work_dir}" # "Where to apply patches?" "BASE_GIT_REVISION=${uboot_git_revision}" # The revision we're building/patching. Python will reset and clean to this. "BRANCH_FOR_PATCHES=u-boot-${BRANCH}-${BOARD}" # When applying patches-to-git, use this branch. + # Lenience: allow problematic patches to be applied. + "ALLOW_RECREATE_EXISTING_FILES=yes" # Allow patches to recreate files that already exist. + "GIT_ARCHEOLOGY=${GIT_ARCHEOLOGY:-no}" # Allow git to do some archaeology to find the original patch's owners; used when patching to git/rewriting. + "FAST_ARCHEOLOGY=${FAST_ARCHEOLOGY:-yes}" # Does archeology even further by looking for history from other patch files with the same name + # Pass the maintainer info, used for commits. + "MAINTAINER_NAME=${MAINTAINER}" # Name of the maintainer + "MAINTAINER_EMAIL=${MAINTAINERMAIL}" # Email of the maintainer ) display_alert "Calling Python patching script" "for u-boot target" "info" diff --git a/lib/functions/host/docker.sh b/lib/functions/host/docker.sh index 3587f61e3..625945d08 100755 --- a/lib/functions/host/docker.sh +++ b/lib/functions/host/docker.sh @@ -202,6 +202,14 @@ function docker_cli_prepare() { esac fi + declare un_ignore_dot_git="" + declare include_dot_git_dir="" + if [[ "${DOCKER_PASS_GIT}" == "yes" ]]; then + display_alert "git/docker:" "adding static copy of .git to Dockerfile" "info" + un_ignore_dot_git="!.git" + include_dot_git_dir="COPY .git ${DOCKER_ARMBIAN_TARGET_PATH}/.git" + fi + # Info summary message. Thank you, GitHub Co-pilot! display_alert "Docker info" "Docker ${DOCKER_SERVER_VERSION} Kernel:${DOCKER_SERVER_KERNEL_VERSION} RAM:${DOCKER_SERVER_TOTAL_RAM} CPUs:${DOCKER_SERVER_CPUS} OS:'${DOCKER_SERVER_OS}' hostname '${DOCKER_SERVER_NAME_HOST}' under '${DOCKER_ARMBIAN_HOST_OS_UNAME}' - buildx:${DOCKER_HAS_BUILDX} - loop-hacks:${DOCKER_SERVER_REQUIRES_LOOP_HACKS} static-loops:${DOCKER_SERVER_USE_STATIC_LOOPS}" "sysinfo" @@ -212,7 +220,7 @@ function docker_cli_prepare() { # Start by ignoring everything * - # Include certain files and directories; mostly the build system, but not other parts. + # Include certain files and directories; mostly the build system, and some of the config. when run, those are bind-mounted in. !/VERSION !/LICENSE !/compile.sh @@ -220,6 +228,7 @@ function docker_cli_prepare() { !/extensions !/config/sources !/config/templates + ${un_ignore_dot_git} # Ignore unnecessary files inside include directories # This should go after the include directories @@ -250,6 +259,7 @@ function docker_cli_prepare() { ${c}RUN echo "--> CACHE MISS IN DOCKERFILE: running Armbian requirements initialization." && \\ ${c} ARMBIAN_INSIDE_DOCKERFILE_BUILD="yes" /bin/bash "${DOCKER_ARMBIAN_TARGET_PATH}/compile.sh" requirements SHOW_LOG=yes && \\ ${c} rm -rf "${DOCKER_ARMBIAN_TARGET_PATH}/output" "${DOCKER_ARMBIAN_TARGET_PATH}/.tmp" "${DOCKER_ARMBIAN_TARGET_PATH}/cache" + ${include_dot_git_dir} INITIAL_DOCKERFILE # For debugging: RUN rm -fv /usr/bin/pip3 # Remove pip3 symlink to make sure we're not depending on it; non-Dockers may not have it