File: prune-kernel

package info (click to toggle)
linux 6.12.38-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,675,544 kB
  • sloc: ansic: 25,916,840; asm: 269,589; sh: 136,393; python: 65,219; makefile: 55,714; perl: 37,750; xml: 19,284; cpp: 5,894; yacc: 4,927; lex: 2,939; awk: 1,594; sed: 28; ruby: 25
file content (25 lines) | stat: -rwxr-xr-x 912 bytes parent folder | download | duplicates (23)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
# again, /boot and /lib/modules/ eventually fill up.
# Dumb script to purge that stuff:

for f in "$@"
do
        if rpm -qf "/lib/modules/$f" >/dev/null; then
                echo "keeping $f (installed from rpm)"
        elif [ $(uname -r) = "$f" ]; then
                echo "keeping $f (running kernel) "
        else
                echo "removing $f"
                rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
                rm -f "/boot/vmlinuz-$f"   "/boot/config-$f"
                rm -rf "/lib/modules/$f"
                if [ -x "$(command -v new-kernel-pkg)" ]; then
                        new-kernel-pkg --remove $f
                elif [ -x "$(command -v kernel-install)" ]; then
                        kernel-install remove $f
                fi
        fi
done