forked from xsuchy/fedora-upgrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-retired-packages
executable file
·70 lines (57 loc) · 2.73 KB
/
remove-retired-packages
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/bash
set -e
source /etc/os-release
if [[ ! "$1" =~ ^[0-9]*$ ]]
then
echo "usage: $(basename "$0") [fedora linux version number as digits]."
exit 1
fi
UPGRADE_FROM="$1"
if [ -z "$UPGRADE_FROM" ]; then
UPGRADE_FROM=$(("$VERSION_ID"-1))
fi
UPGRADE_TO="$VERSION_ID"
echo "Looking for retired packages between Fedora Linux $UPGRADE_FROM and Fedora Linux $UPGRADE_TO"
echo "Retired packages are no longer maintained. Answer N to the following questions to keep them,"
echo "but these packages will not get any updates. Not even security updates."
TO_REMOVE=$(mktemp --tmpdir retired-packages.XXXXXXXXX)
OLD_LIST=$(mktemp --tmpdir retired-packages.XXXXXXXXX)
NEW_LIST=$(mktemp --tmpdir retired-packages.XXXXXXXXX)
function pause() {
# clear the stdin buffer and pause with question
read -t 1 -n 10000 discard || [ $? -gt 128 ]
read -p "Hit Enter to continue with other package or Ctrl + C to interrupt."
}
#--repo={fedora,fedora-modular,updates,updates-modular}-source
echo "Gathering package list for Fedora Linux $UPGRADE_FROM"
# in case the metadata are signed and GPG key is not yet imported
dnf repoquery -q --releasever "$UPGRADE_FROM" --disableplugin=local XXXXXXXXXXXX
dnf repoquery -q --releasever "$UPGRADE_FROM" --disableplugin=local --qf="%{name}" | sort > "$OLD_LIST"
#repoquery --releasever "$UPGRADE_FROM" --arch src -a | pkgname | sort | uniq > "$OLD_LIST"
echo "Gathering package list for Fedora Linux $UPGRADE_TO"
# in case the metadata are signed and GPG key is not yet imported
dnf repoquery -q --releasever "$UPGRADE_TO" --disableplugin=local XXXXXXXXXXXX
dnf repoquery -q --releasever "$UPGRADE_TO" --disableplugin=local --qf="%{name}" | sort > "$NEW_LIST"
comm -23 "$OLD_LIST" "$NEW_LIST" > "$TO_REMOVE"
echo "Asking for super user access:"
sudo true Executed from remove-retired-packages
echo "These packages have been retired:"
for PACKAGE in $( cat "$TO_REMOVE"); do
#skip if this package is not installed
rpm -q "$PACKAGE" 2>/dev/null >&2 || continue
SUMMARY=$(rpm -q --qf "%{summary}" "$PACKAGE" | head -n1 )
echo "$PACKAGE: $SUMMARY"
done
for PACKAGE in $( cat "$TO_REMOVE"); do
#skip if this package is not installed
rpm -q "$PACKAGE" 2>/dev/null >&2 || continue
SUMMARY=$(rpm -q --qf "%{summary}" "$PACKAGE" | head -n1 )
echo "Removing $PACKAGE: $SUMMARY"
SRPMFILENAME=$(rpm -q --qf "%{sourcerpm}" "$PACKAGE")
SRPM=$(rpm-print-name-from-filename "$SRPMFILENAME")
REASON=$(curl --fail https://src.fedoraproject.org/rpms/$SRPM/raw/rawhide/f/dead.package 2>/dev/null || echo "unknow reason")
echo "Reason of retirement: $REASON"
sudo dnf remove "$PACKAGE" || pause
done
# cleanup
rm -f "$TO_REMOVE" "$OLD_LIST" "$NEW_LIST"