projg2 / eclean-kernel

Installed kernel cleanup tool
GNU General Public License v2.0
31 stars 10 forks source link

Current implementation of bootloader processing does not work well with symlinks #42

Closed bstaletic closed 10 months ago

bstaletic commented 10 months ago

This is a followup of #41 .

Briefly, with the following LILO configuration (all bootloaders are affected, but I only have LILO installed):

image=/boot/vmlinuz
        label=default
        read-write
        root=/dev/sda1
        append="net.ifnames=0 init=/sbin/openrc-init sysrq_always_enabled=1"
image=/boot/vmlinuz.old
        label=old
        read-write
        root=/dev/sda1
        append="net.ifnames=0 init=/sbin/openrc-init sysrq_always_enabled=1"

and these files in /boot:

-rw-r--r-- 1 root root     512 Jan  3  2022 boot.0800
lrwxrwxrwx 1 root root      18 Aug 13 11:49 config -> config-6.4.10-test
-rw-r--r-- 1 root root  109325 Aug 13 11:49 config-6.4.10-test
-rw-r--r-- 1 root root  109229 Aug  4 08:24 config-6.4.8-test
-rw-r--r-- 1 root root  109324 Aug 10 16:45 config-6.4.9-test
lrwxrwxrwx 1 root root      17 Aug 10 16:45 config.old -> config-6.4.9-test
-rw-r--r-- 1 root root       0 Jan  2  2022 .keep
-rw------- 1 root root   23040 Aug 13 11:49 map
lrwxrwxrwx 1 root root      22 Aug 13 11:49 System.map -> System.map-6.4.10-test
-rw-r--r-- 1 root root 4288104 Aug 13 11:49 System.map-6.4.10-test
-rw-r--r-- 1 root root 4286603 Aug  4 08:24 System.map-6.4.8-test
-rw-r--r-- 1 root root 4287870 Aug 10 16:45 System.map-6.4.9-test
lrwxrwxrwx 1 root root      21 Aug 10 16:45 System.map.old -> System.map-6.4.9-test
lrwxrwxrwx 1 root root      19 Aug 13 11:49 vmlinuz -> vmlinuz-6.4.10-test
-rw-r--r-- 1 root root 7913168 Aug 13 11:49 vmlinuz-6.4.10-test
-rw-r--r-- 1 root root 7909136 Aug  4 08:24 vmlinuz-6.4.8-test
-rw-r--r-- 1 root root 7911952 Aug 10 16:45 vmlinuz-6.4.9-test
lrwxrwxrwx 1 root root      18 Aug 10 16:45 vmlinuz.old -> vmlinuz-6.4.9-test

then running eclean-kernel -a, the expectation is that only the following files would be deleted (everything else is used by the bootloader):

-rw-r--r-- 1 root root  109229 Aug  4 08:24 config-6.4.8-test
-rw-r--r-- 1 root root 4286603 Aug  4 08:24 System.map-6.4.8-test
-rw-r--r-- 1 root root 7909136 Aug  4 08:24 vmlinuz-6.4.8-test

Instead, the regex substitution here fails and only the currently running kernel is preserved, which means at least one more kernel is deleted.

bstaletic commented 10 months ago

Here's my new attempt at fixing this:

https://github.com/bstaletic/eclean-kernel/commit/7b5aeeaa5a22bc357a660eae7ea77f011592d111

If that is a valid approach, I can write a test and make another pull request.

mgorny commented 10 months ago

Yes, the idea looks good. I'm going to have some minor comments but please open the PR. Thank you a lot!

mgorny commented 10 months ago

Fixed in 58ee54e9988aba2a2b4a757faeae39f1d167b1e3.