linux-module-cleanup.script deletes all kernel modules if .old file is 'empty'
Due to the intel driver issues currently present on 5.4 kernel I decided to go back to 4.19 and 4.14. So I uninstalled all newer kernels.
I booted this morning to find out that the whole /lib/modules (respectively /usr/lib/modules) folder was deleted completely.
After restoring the modules with an USB pendrive live installation I found that this kernel-alive package kept deleting my kernel-modules. So I quickly debugged and found that my .old
file is only containing a linefeed:
$ hexdump -C /lib/modules/.old
00000000 0a |.|
00000001
The script is in such a case deleting everything but I guess that is not the desired behaviour?
I suggest to compare the actual string that is also read out afterwards.
My suggestion: change line 5 from
if [ -s /usr/lib/modules/.old ]; then
to
if [ $(cat /usr/lib/modules/.old) ]; then
then this shouldn't happen. If you let me fork this project I can send a MR if you agree.