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

How to build custom Pop!_OS kernel? (with patch) #296

Closed
bluetiger9 opened this issue Feb 10, 2024 · 1 comment
Closed

How to build custom Pop!_OS kernel? (with patch) #296

bluetiger9 opened this issue Feb 10, 2024 · 1 comment

Comments

@bluetiger9
Copy link

Hi! 🙂

I would like to build and install a custom kernel version with a patch, based on the current Pop!_OS 6.6.10-76060610-generic kernel. Are there any up to date instructions on how to build and install a custom Pop!_OS kernel?

The kernel patch is a simple quirk, that should fix a microphone issue in a Lenovo laptop, similar to the 171726a commit.

A guide I trying to follow is:
https://tutorialforlinux.com/2021/01/04/step-by-step-build-kernel-pop_os-guide/

Steps:

  • clone Pop_OS! Linux kernel repository
$ git clone --depth 1 https://github.com/pop-os/linux.git; cd linux
  • use the current kernel config
$ sudo cat /boot/config-6.6.10-76060610-generic > .config
  • clean and build with deb-pkg
$ make clean
$ make deb-pkg LOCALVERSION=-custom KDEB_PKGVERSION=$(make kernelversion)-1

This last command first gives a warning about uncommitted changes, and fails with a patch related error (see bellow).

Can somebody help me with this?

Log:

➜  linux git:(master) make deb-pkg LOCALVERSION=-custom KDEB_PKGVERSION=$(make kernelversion)-1                        [10/02 | 1:36:33]

  SYNC    include/config/auto.conf.cmd
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/menu.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
  UPD     include/config/kernel.release
  GEN     debian
============================ WARNING ============================
Your working tree has diff from HEAD, and also untracked file(s).
Please make sure you did 'git add' for all new files you need in
the source package.
=================================================================
  UPD     .tmp_HEAD
  ARCHIVE linux.tar.gz
dpkg-buildpackage --build=source,binary --no-pre-clean --unsigned-changes --unsigned-source --compression=gzip --rules-file='make -f debian/rules' --jobs=1 -r'fakeroot -u' -a$(cat debian/arch)
dpkg-buildpackage: info: source package linux-upstream
dpkg-buildpackage: info: source version 6.6.10-1
dpkg-buildpackage: info: source distribution jammy
dpkg-buildpackage: info: source changed by bluetiger <bluetiger@Attila-Laptop>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --compression=gzip --before-build .
dpkg-source: info: using options from linux/debian/source/local-options: --diff-ignore --extend-diff-ignore=.*
dpkg-buildpackage: warning: building a source package without cleaning up as you asked; it might contain undesired files
 dpkg-source --compression=gzip -b .
dpkg-source: info: using options from linux/debian/source/local-options: --diff-ignore --extend-diff-ignore=.*
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building linux-upstream using existing ./linux-upstream_6.6.10.orig.tar.gz
dpkg-source: info: using patch list from debian/patches/series
The next patch would delete the file debian/canonical-certs.pem,
which does not exist!  Skipping patch.
1 out of 1 hunk ignored

....

The next patch would delete the file debian/zfs-modules.ignore,
which does not exist!  Skipping patch.
1 out of 1 hunk ignored
dpkg-source: info: the patch has fuzz which is not allowed, or is malformed
dpkg-source: info: if patch 'diff.patch' is correctly applied by quilt, use 'quilt refresh' to update it
dpkg-source: info: if the file is present in the unpacked source, make sure it is also present in the orig tarball
dpkg-source: error: LC_ALL=C patch -t -F 0 -N -p1 -u -V never -E -b -B .pc/diff.patch/ --reject-file=- < linux.orig.4EjSEs/debian/patches/diff.patch subprocess returned exit status 1
dpkg-buildpackage: error: dpkg-source --compression=gzip -b . subprocess returned exit status 2
make[2]: *** [scripts/Makefile.package:146: deb-pkg] Error 2
make[1]: *** [/home/bluetiger/kernel/linux/Makefile:1544: deb-pkg] Error 2
make: *** [Makefile:234: __sub-make] Error 2
@bluetiger9
Copy link
Author

bluetiger9 commented Feb 10, 2024

Figured this out! 🙂 Instead of make deb-pkg ..., looks like we should use make bindeb-pkg .... This fixes the patch errors mentioned above.

So, to build and install a Pop!_OS Linux kernel with a patch:

  1. Clone Pop_OS! Linux kernel repository
$ git clone --depth 1 https://github.com/pop-os/linux.git; cd linux
  1. Use the current kernel config
$ cp /boot/$(uname -r) > .config
  • and change the following settings in .config
    • remove trusted and revocation keys:
      CONFIG_SYSTEM_TRUSTED_KEYS=""
      CONFIG_SYSTEM_REVOCATION_KEYS=""
      
    • disable kernel module compression:
      (fixes random SSL signing error, ref. https://askubuntu.com/a/1497413)
      CONFIG_MODULE_COMPRESS_NONE=y
      # CONFIG_MODULE_COMPRESS_ZSTD is not set
      
  1. Apply any source code changes and patches

  2. Clean and build with bindeb-pkg

$ make clean
$ make -j12 bindeb-pkg LOCALVERSION=-custom KDEB_PKGVERSION=$(make kernelversion)-1
  1. Install the new kernel
$ cd ..
$ sudo dpkg -i linux-headers-6.6.10-custom_6.6.10-1_amd64.deb linux-image-6.6.10-custom_6.6.10-1_amd64.deb

and set it as the default with kernelstub:

sudo kernelstub -v -k /boot/vmlinuz-6.6.10-custom -i /boot/initrd.img-6.6.10-custom
  1. Reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant