This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xm-purge
executable file
·41 lines (37 loc) · 1.6 KB
/
xm-purge
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# -----------------------------------------------------------------------
# Purge packages.
# Author: Mario Roy - http://github.com/marioroy
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 or later of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------
for pkg in $(
rpm -qa | grep -E "^linux-xm(clear|bore|echo|edge|main|lts|rt)" |\
grep -Ev "(license|extra|dev|cpio)"
); do
dir=$( rpm -ql "$pkg" | grep "modules" | head -1 )
# The "clr-boot-manager update" command removes older kernel version.
# Purge packages for kernels no longer present in /usr/lib/modules/.
if [[ ! -e "$dir" ]]; then
v=${pkg#*-}; v=${v#*-}; [[ "$v" == *"rt-"* ]] && v=${v#*-}
p=${pkg%-*}; p=${p%-*}
# Uninstall the packages separately.
echo "Uninstalling ${pkg} packages"
( sudo rpm -e "${p}-cpio-${v}"
sudo rpm -e "${p}-dev-${v}"
sudo rpm -e "${p}-extra-${v}"
sudo rpm -e "${p}-${v}"
sudo rpm -e "${p}-license-${v}"
) 2>/dev/null
fi
done