Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an option to rebuild the kernel without downloading it again #104

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this incremetal build, it looks like we are not re-applying the patch series. what if the developer add a new kernel patch? Can you do stg pop and then re-apply all the patches?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The theory is that, the user will first try the patch by directly applying the changes to the staged repo "sonic-linux-kernel/linux-4.9.189". Re-build, test the image. In fact, to create the patch itself, the staged repo "sonic-linux-kernel/linux-4.9.189" shall be used and when all change set is ready the patches are moved to the patch directory and series file updated. The staged repo is transient in nature till the point patches are tried manually, tested and finalized.

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