My First Kernel Patch - Part 3

Introduction

This journal entry was written by me, Brandon Nolet, in the context of compiling the linux kernel for the second time.

Success!

So last night I left off with the kernel still compiling. I’m not surprised that it took a long time and it actually took less time than I anticipated. Compiling from Linus’ kernel source faired a lot better than that from Canonical.

I was (slightly) surprised to see that it had successfully compiled on the first try! After surprise, I was actually proud of the kernel dev team for being so good at what they do. It’s a testament to reproducable builds.

After seeing that my kernel had compiled, I transferred the .deb files to my VPS and took a snapshot of it. After the snapshot took forever to be made, it was time to install the new kernel!

So with the guide on one screen and the terminal on the other, I got to business, installed the kernel, updated grub and rebooted the VPS. To my surprised (and absolute delight) the VPS started without issue! I didn’t have to do some extra finicking about. It…just worked.

Patching

Now I’m actually able to get to patching. I know the source is good so it’s time to apply the patches.

I didn’t fully understand yet what to do so I refreshed my memory and then got to patching. When applying the patches, I kept getting this weird message:


Reversed (or previously applied) patch detected!  Assume -R? [n]

I didn’t know exactly what this meant or how this had happened but I knew that the patch couldn’t have already been applied. I said “yes” to assuming -R without thinking twice and continued. This was a mistake.

After applying the last patch, it seemed that the patches were either not being applied or were failing to be applied. I decided to look up what this -R flag meant and it turns out that I was actually reversing some patches (or making unnecessary changes that may or may not have screwed me over).

So I revised my strategy and re-applied these patches saying no to assuming -R as a flag and many less errors were had.

Compiling

So now that all the patches are applied, it’s time to actually compile. It turns out that uppercase letters are not allowed in resulting .deb file and I was presented with an error telling me so:


dpkg-source: error: source package name 'linux-5.2.0-rc5-SACKPatch' is illegal: character 'S' not allowed

So I changed the letters to lowercase and here we go, attempting another compilation. If this doesn’t work, then I might just have to re-download the source and apply the patches properly the first time.

Aaand, it failed to compile. I think it might be due to an incomplete archive existing, attempt number two after deleting the incomplete archives.

Again, failure to compile, same issue:


dpkg-source: error: cannot represent change to vmlinux-gdb.py:
dpkg-source: error:   new version is symlink to /home/brandon/Projects/linux/scripts/gdb/vmlinux-gdb.py
dpkg-source: error:   old version is nonexistent
dpkg-source: warning: ignoring deletion of file .scmversion
dpkg-source: warning: the diff modifies the following upstream files:

Seems like the way I applied the patches broke some symlinks. I’ll have to figure that out.

Conclusion

Unfortunately, the saga continues tomorrow! I have a dinner to go to tonight and I have to re-clone the source, have to re-download the patches because I accidentally deleted the patches and the source is now modified.

Though I could probably just hard reset the source, I would prefer re-cloning it.