253

When doing an apt-get upgrade on my RPi 3, many lines of output show up like this:

Adding 'diversion of /boot/bcm2708-rpi-b-plus.dtb to /usr/share/rpikernelhack/bcm2708-rpi-b-plus.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2708-rpi-b.dtb to /usr/share/rpikernelhack/bcm2708-rpi-b.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2708-rpi-cm.dtb to /usr/share/rpikernelhack/bcm2708-rpi-cm.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2709-rpi-2-b.dtb to /usr/share/rpikernelhack/bcm2709-rpi-2-b.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2710-rpi-3-b.dtb to /usr/share/rpikernelhack/bcm2710-rpi-3-b.dtb by rpikernelhack'
Adding 'diversion of /boot/kernel.img to /usr/share/rpikernelhack/kernel.img by rpikernelhack'
Adding 'diversion of /boot/kernel7.img to /usr/share/rpikernelhack/kernel7.img by rpikernelhack'
Adding 'diversion of /boot/COPYING.linux to /usr/share/rpikernelhack/COPYING.linux by rpikernelhack'
...
...
...

I'm not very educated on Linux kernel features and this looks pretty specific to the RPi.

My question is: What is all this?

What is a 'diversion'? What do all these files (as a group) that are being referenced, actually do? What is 'rpikernelhack'?

I did a little bit of googling and couldn't easily find anything interesting. I figure I'm not the only one who's curious about this so I hope this is an appropriate question!

MD-7
  • 2,943
  • 2
  • 12
  • 12

2 Answers2

333

"rpikernelhack" is a fake package name and a directory name used as part of a hack (in the sense of a dirty but expedient solution to a problem) to work around the fact that the Raspberry Pi foundation decided to make /boot a fat32 partition and dpkg does not get on well with fat32. I was the one who initially came up with the idea, though it was refined later by others.

dpkg will install new files onto a fat32 partition (spewing some warnings along the way), but if it tries to update an existing file on a fat32 partition it will fail (iirc it tries to make a backup of the old file by creating a hardlink and fat32 doesn't support hardlinks).

When people (including me) started trying to make deb packages of Pi kernels and firmware they ran into this problem, a package would install initially but trying to upgrade it would fail, ouch.

My workaround was to (ab)use the "diversion" feature in dpkg. This feature was intended to allow files to be diverted so they could be replaced with either locally modified versions or versions from another package, but I was able to use it from the maintainer scripts in such a way that dpkg would perform its installation tasks on a Linux partition and then move the file to its final location at the end.

Diversions require you to either specify a "package name" or "local". If you specify a package name then the diversion will affect files owned by all packages except the one you specify (the intent here is to allow a package to divert a file owned by another package and then install its own versions). I also needed a directory to divert the files to.

Using the name of the kernel package being installed would have rendered the hack ineffective. Using "local" also seemed wrong, since that is supposed to be reserved for use by the local sysadmin. So I needed a fake package name that was unlikely to conflict with anything. I came up with "rpikernelhack", I also used this same string for the directory name.

Matthias Braun
  • 233
  • 2
  • 7
Peter Green
  • 6,595
  • 1
  • 21
  • 26
53

It's just the directory name given by the developers who have created a Raspberry Pi specific set of patches to the Linux kernel.

It is a fix by the Raspbian developers to fix a FAT file-system corruption issue present in the 2016 kernel, this updates to the 2017 kernel and is nothing to worry about. To make this kernel update you need to use sudo apt install -f to fix the dependency issues caused by the bug (the -f in this context means, according to the man page, apt-get(8):

-f, --fix-broken
Fix; attempt to correct a system with broken dependencies in place. ...

)

SlySven
  • 3,631
  • 1
  • 20
  • 46
Rebroad
  • 665
  • 5
  • 11