3
# Copyright (C) 2015, 2017 Etersoft
4
# Copyright (C) 2015, 2017 Vitaly Lipatov <lav@etersoft.ru>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
docmd apt-cache list-extras
28
[ -z "$*" ] || fatal "No arguments are allowed here"
33
assure_exists /usr/share/apt/scripts/list-extras.lua apt-scripts
34
if [ -z "$dryrun" ] ; then
35
echo "We will try remove all installed packages which are missed in repositories"
36
warning "Use with caution!"
39
info "Retrieving orphaned packages list ..."
40
local PKGLIST=$(__epm_orphan_altrpm \
41
| sed -e "s/\.32bit//g" \
42
| grep -v -- "^eepm$" \
43
| grep -v -- "^distro_info$" \
44
| grep -v -- "^kernel")
46
# TODO: implement for other PMTYPE
47
info "Retrieving packages installed via epm play ..."
48
local play_installed="$(epm play --list-installed-packages)"
49
if [ -n "$play_installed" ] ; then
50
echo "Skip follow packages installed via epm play: $(echo $play_installed | xargs -n1000 echo)"
51
PKGLIST="$(estrlist exclude "$play_installed" "$PKGLIST")"
54
# TODO: implement for other PMTYPE
55
local hold_packages="$(epm mark --short showhold)"
56
if [ -n "$hold_packages" ] ; then
57
echo "Skip follow packages on hold: $(echo $hold_packages | xargs -n1000 echo)"
58
PKGLIST="$(estrlist exclude "$hold_packages" "$PKGLIST")"
61
if [ -n "$PKGLIST" ] ; then
62
if [ -z "$dryrun" ] ; then
63
showcmd epm remove $dryrun $force $PKGLIST
64
confirm_info "We will remove packages above."
68
docmd epm remove $dryrun $force $(subst_option non_interactive --auto) $PKGLIST
70
echo "There are no orphan packages in the system."
77
apt-dpkg|aptitude-dpkg)
78
assure_exists deborphan
80
a='' deborphan | docmd epm remove $dryrun
87
assure_exists package-cleanup yum-utils
88
showcmd package-cleanup --orphans
89
local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-")
90
docmd epm remove $dryrun $PKGLIST
93
# TODO: dnf list extras
95
assure_exists package-cleanup dnf-utils
96
showcmd package-cleanup --orphans
97
local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-")
98
docmd epm remove $dryrun $PKGLIST
101
if [ -n "$dryrun" ] ; then
102
fatal "--dry-run is not supported yet"
104
showcmd urpme --report-orphans
105
sudocmd urpme --auto-orphans
109
# sudocmd emerge --depclean
110
# assure_exists revdep-rebuild
111
# sudocmd revdep-rebuild
114
if [ -n "$dryrun" ] ; then
115
info "Autoorphans packages list:"
118
sudocmd pacman -Qdtq | sudocmd pacman -Rs -
122
# clean-system removes non official packages
123
sudocmd slackpkg clean-system
126
sudocmd eopkg remove-orphans
132
# sudocmd pkg autoremove
135
# https://www.linux.org.ru/forum/desktop/11931830
136
assure_exists zypper zypper 1.9.2
137
# For zypper < 1.9.2: zypper se -si | grep 'System Packages'
138
sudocmd zypper packages --orphaned
139
# FIXME: x86_64/i586 are duplicated
140
local PKGLIST=$(zypper packages --orphaned | tail -n +5 | cut -d \| -f 3 | sort -u)
141
docmd epm remove $dryrun --clean-deps $PKGLIST
144
if [ -n "$dryrun" ] ; then
145
fatal "--dry-run is not supported yet"
147
sudocmd xbps-remove -o
151
fatal "Have no suitable command for $PMTYPE"