xref: /OK3568_Linux_fs/kernel/scripts/prune-kernel (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/bash
2*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
5*4882a593Smuzhiyun# again, /boot and /lib/modules/ eventually fill up.
6*4882a593Smuzhiyun# Dumb script to purge that stuff:
7*4882a593Smuzhiyun
8*4882a593Smuzhiyunfor f in "$@"
9*4882a593Smuzhiyundo
10*4882a593Smuzhiyun        if rpm -qf "/lib/modules/$f" >/dev/null; then
11*4882a593Smuzhiyun                echo "keeping $f (installed from rpm)"
12*4882a593Smuzhiyun        elif [ $(uname -r) = "$f" ]; then
13*4882a593Smuzhiyun                echo "keeping $f (running kernel) "
14*4882a593Smuzhiyun        else
15*4882a593Smuzhiyun                echo "removing $f"
16*4882a593Smuzhiyun                rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
17*4882a593Smuzhiyun                rm -f "/boot/vmlinuz-$f"   "/boot/config-$f"
18*4882a593Smuzhiyun                rm -rf "/lib/modules/$f"
19*4882a593Smuzhiyun                new-kernel-pkg --remove $f
20*4882a593Smuzhiyun        fi
21*4882a593Smuzhiyundone
22