Skip to content

Commit

Permalink
Provide an option to rebuild the kernel without downloading it again
Browse files Browse the repository at this point in the history
Normally, rebuilding the kernel involves removing the previously built kernel
source tree, downloading the stock kernel, applying all the SONiC patches,
and compiling the kernel and the kernel modules. In a development environment,
you might want to skip downloading the kernel and applying all the patches,
and just rebuild the kernel. This option is enabled by setting the value for
DEFAULT_KERNEL_PROCURE_METHOD to "incremental" in the rules/config file.

Procedure to rebuild the kernel:

make target/debs/stretch/linux-headers-4.9.0-9-2-common_4.9.168-1+deb9u5_all.deb-clean
make target/debs/stretch/linux-headers-4.9.0-9-2-common_4.9.168-1+deb9u5_all.deb

You can then upload and install the kernel archive in the switch:
target/debs/stretch/linux-image-4.9.0-9-2-amd64_4.9.168-1+deb9u5_amd64.deb
  • Loading branch information
olivier-singla committed Oct 4, 2019
1 parent 6d55e9a commit b08ce3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LINUX_IMAGE = linux-image-$(KVERSION)_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_amd
MAIN_TARGET = $(LINUX_HEADER_COMMON)
DERIVED_TARGETS = $(LINUX_HEADER_AMD64) $(LINUX_IMAGE)

ifneq ($(kernel_procure_method), build)
ifeq ($(kernel_procure_method), download)
# Downloading kernel

# TBD, need upload the new kernel packages
Expand Down Expand Up @@ -51,16 +51,29 @@ DSC_FILE_URL = "https://sonicstorage.blob.core.windows.net/packages/kernel-sourc
DEBIAN_FILE_URL = "https://sonicstorage.blob.core.windows.net/packages/kernel-source/linux_4.9.168-1+deb9u5.debian.tar.xz?sv=2015-04-05&sr=b&sig=koCXHDvmY39smVGcI3cPJrBDZMmdpKiLkyJPfMdNPwU%3D&se=2033-04-28T06%3A14%3A51Z&sp=r"
ORIG_FILE_URL = "https://sonicstorage.blob.core.windows.net/packages/kernel-source/linux_4.9.168.orig.tar.xz?sv=2015-04-05&sr=b&sig=ArvSGD3N46WGh%2BTYF8J1JgdT9x0BrFu4JhSuyyr3nNw%3D&se=2033-04-09T01%3A00%3A47Z&sp=r"

ifneq ($(wildcard $(BUILD_DIR)),)
ifeq ($(kernel_procure_method), incremental)
INCR_BUILD = YES
endif
endif

$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Obtaining the Debian kernel source
ifeq ($(INCR_BUILD),)
rm -rf $(BUILD_DIR)
wget -O $(DSC_FILE) $(DSC_FILE_URL)
wget -O $(ORIG_FILE) $(ORIG_FILE_URL)
wget -O $(DEBIAN_FILE) $(DEBIAN_FILE_URL)

dpkg-source -x $(DSC_FILE)
endif

pushd $(BUILD_DIR)

ifneq ($(INCR_BUILD),)
# Force kernel build
rm -f debian/stamps/build_amd64_none_amd64
else
git init
git add -f *
git commit -qm "check in all loose files and diffs"
Expand All @@ -86,6 +99,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Learning new git repo head (above commit) by calling stg repair.
stg repair
stg import -s ../patch/series
endif

# Building a custom kernel from Debian kernel source
DO_DOCS=False fakeroot make -f debian/rules -j $(shell nproc) binary-indep
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ Usage:
make DEST=<destination path>

If DEST is not set, package will stay in current directory

## Incremental Kernel Build

Normally, rebuilding the kernel involves removing the previously built kernel source tree, downloading the stock kernel, applying all the SONiC patches, and compiling the kernel and the kernel modules. In a development environment, you might want to skip downloading the kernel and applying all the patches, and just rebuild the kernel. This option is enabled by setting the value for DEFAULT_KERNEL_PROCURE_METHOD to "incremental" in the rules/config file.

Procedure to rebuild the kernel:

make target/debs/stretch/linux-headers-4.9.0-9-2-common_4.9.168-1+deb9u5_all.deb-clean
make target/debs/stretch/linux-headers-4.9.0-9-2-common_4.9.168-1+deb9u5_all.deb

You can then upload and install the kernel archive in the switch:
target/debs/stretch/linux-image-4.9.0-9-2-amd64_4.9.168-1+deb9u5_amd64.deb

0 comments on commit b08ce3c

Please sign in to comment.