Commit 07c65a5e authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-autoremove: big rewrite, add confirm before removing

parent a81a5008
#!/bin/sh
#
# Copyright (C) 2012, 2017, 2018 Etersoft
# Copyright (C) 2012, 2017, 2018 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2017, 2018, 2021 Etersoft
# Copyright (C) 2012, 2017, 2018, 2021 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -36,15 +36,11 @@ __epm_autoremove_altrpm_pp()
local pkgs fullpkgs
info "Removing unused python/perl modules..."
#[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force
local libexclude="$1"
local flag=
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
pkgs=$(skip_manually_installed $fullpkgs)
......@@ -56,9 +52,16 @@ __epm_autoremove_altrpm_pp()
return 0
fi
__epm_print_excluded "$pkgs" "$fullpkgs"
if [ -n "$pkgs" ] ; then
info "The command we will run:"
showcmd rpm -v -e $pkgs
__epm_print_excluded "$pkgs" "$fullpkgs"
confirm_info "We will remove unused (without dependencies) packages above."
sudocmd rpm -v -e $pkgs && flag=1
fi
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then
info ""
......@@ -107,17 +110,15 @@ __epm_autoremove_altrpm_lib()
return 0
fi
__epm_print_excluded "$pkgs" "$fullpkgs"
if [ -n "$pkgs" ] ; then
info "The command we will run:"
showcmd rpm -v -e $pkgs
__epm_print_excluded "$pkgs" "$fullpkgs"
confirm_info "We will remove unused (without dependencies) packages above."
# commented, with hi probability user install i586- manually
# workaround against missed i586- handling in apt-cache list-nodeps
if epmqp i586-lib >/dev/null ; then
info "You can try removing all i586- with follow command"
showcmd rpm -v -e $(epmqp i586-lib)
sudocmd rpm -v -e $pkgs && flag=1
fi
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then
info ""
info "call again for next cycle until all libs will be removed"
......@@ -197,10 +198,11 @@ case $DISTRNAME in
epm_autoremove_print_help
return 0
fi
if [ -z "$direct" ] ; then
fatal "Run autoremove without args or with --direct. Check epm autoremove --help to available commands."
sudocmd apt-get $(subst_option non_interactive -y) autoremove $dryrun
local RET=$?
info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)"
[ "$RET" = 0 ] || return
else
__epm_autoremove_altrpm "$@"
......@@ -208,6 +210,9 @@ case $DISTRNAME in
[ -n "$dryrun" ] && return
# remove old kernels only by a default way
[ -n "$@" ] && return
docmd epm remove-old-kernels $(subst_option non_interactive --auto)
if which nvidia-clean-driver 2>/dev/null ; then
......@@ -218,6 +223,11 @@ case $DISTRNAME in
fi
fi
if [ -z "$direct" ] ; then
echo
info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)"
fi
return
;;
*)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment