Skip to content

Commit dd25cf1

Browse files
matthijskooijmanleggewie
authored andcommitted
WIP: Allow reusing existing kernel tree as-is
This skips all git checkout, patching, configuring and cleaning when USE_EXISTING_KERNEL_TREE=yes is passed. This can be useful when doing kernel development by making changes directly to the kernel sourcetree in `cache/sources`, while still allowing to use the `compile.sh` to use the same compilation commands, deb package building, ccache, etc. It is also useful when bisecting a kernel issue. Can be used something like this: USE_EXISTING_KERNEL_TREE=yes ./compile.sh default kernel To produce a kernel deb in a few minutes ready to be installed on a device. This is mostly a proof of concept to explore the usecase. In particular: - I am not happy with the USE_EXISTING_KERNEL_TREE name yet. - I wonder if this variable should maybe be split into different ones (e.g. for skipping git checkout, patching, config, clean already has one that can be used). - Or maybe it would be better to split off some code out of compile_kernel() and expose a kernel_build and/or kernel_package command from ./compile.sh instead?
1 parent 2b705a8 commit dd25cf1

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

lib/functions/compilation/kernel.sh

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ function compile_kernel() {
2727
declare git_kernel_oras_ref
2828
kernel_prepare_bare_repo_decide_shallow_or_full # sets kernel_git_bare_tree, git_bundles_dir, git_kernel_ball_fn, git_kernel_oras_ref
2929

30-
LOG_SECTION="kernel_prepare_bare_repo_from_oras_gitball" do_with_logging do_with_hooks \
31-
kernel_prepare_bare_repo_from_oras_gitball # this sets kernel_git_bare_tree
30+
if [[ "${USE_EXISTING_KERNEL_TREE}" != yes ]]; then
31+
LOG_SECTION="kernel_prepare_bare_repo_from_oras_gitball" do_with_logging do_with_hooks \
32+
kernel_prepare_bare_repo_from_oras_gitball # this sets kernel_git_bare_tree
33+
fi
3234

3335
# prepare the working copy; this is the actual kernel source tree for this build
3436
declare checked_out_revision_ts="" checked_out_revision="undetermined" # set by fetch_from_repo
35-
LOG_SECTION="kernel_prepare_git" do_with_logging_unless_user_terminal do_with_hooks kernel_prepare_git
37+
if [[ "${USE_EXISTING_KERNEL_TREE}" != yes ]]; then
38+
LOG_SECTION="kernel_prepare_git" do_with_logging_unless_user_terminal do_with_hooks kernel_prepare_git
39+
else
40+
checked_out_revision="$(git -C "${SRC}/cache/sources/${LINUXSOURCEDIR}" rev-parse HEAD)"
41+
checked_out_revision_ts="$(git -C "${SRC}/cache/sources/${LINUXSOURCEDIR}" log -1 --pretty=%ct HEAD)" # unix timestamp of the commit date
42+
fi
3643

3744
# Capture date variables set by fetch_from_repo; it's the date of the last kernel revision
3845
declare kernel_git_revision="${checked_out_revision}"
@@ -42,16 +49,22 @@ function compile_kernel() {
4249
display_alert "Using Kernel git revision" "${kernel_git_revision} at '${kernel_base_revision_date}'"
4350

4451
# Call extension method to prepare extra sources
45-
call_extension_method "kernel_copy_extra_sources" <<- 'ARMBIAN_KERNEL_SOURCES_EXTRA'
46-
*Hook to copy extra kernel sources to the kernel under compilation*
47-
ARMBIAN_KERNEL_SOURCES_EXTRA
52+
if [[ "${USE_EXISTING_KERNEL_TREE}" != yes ]]; then
53+
call_extension_method "kernel_copy_extra_sources" <<- 'ARMBIAN_KERNEL_SOURCES_EXTRA'
54+
*Hook to copy extra kernel sources to the kernel under compilation*
55+
ARMBIAN_KERNEL_SOURCES_EXTRA
56+
fi
4857

4958
# Possibly 'make clean'.
50-
LOG_SECTION="kernel_maybe_clean" do_with_logging do_with_hooks kernel_maybe_clean
59+
if [[ "${USE_EXISTING_KERNEL_TREE}" != yes ]]; then
60+
LOG_SECTION="kernel_maybe_clean" do_with_logging do_with_hooks kernel_maybe_clean
61+
fi
5162

5263
# Patching.
5364
declare hash pre_patch_version
54-
kernel_main_patching # has it's own logging sections inside
65+
if [[ "${USE_EXISTING_KERNEL_TREE}" != yes ]]; then
66+
kernel_main_patching # has it's own logging sections inside
67+
fi
5568

5669
# Stop after patching.
5770
if [[ "${PATCH_ONLY}" == yes ]]; then
@@ -77,7 +90,9 @@ function compile_kernel() {
7790
declare toolchain
7891
LOG_SECTION="kernel_determine_toolchain" do_with_logging do_with_hooks kernel_determine_toolchain
7992

80-
kernel_config # has it's own logging sections inside
93+
if [[ "${USE_EXISTING_KERNEL_TREE}" != yes ]]; then
94+
kernel_config # has it's own logging sections inside
95+
fi
8196

8297
# Validate dts file if flag is set and stop after validation.
8398
# Has to happen after kernel .config file was created

0 commit comments

Comments
 (0)